From b7b54b5878c72ce4fa6ba6118a2cafa690d1d609 Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Fri, 3 Apr 2009 16:35:47 +0200 Subject: [PATCH] Don't expand tilde ('~') in paths unless it's the first character of the path in question. This should fix #255. --- dmd/root.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dmd/root.c b/dmd/root.c index f473a254..d97f1ced 100644 --- a/dmd/root.c +++ b/dmd/root.c @@ -367,6 +367,8 @@ Array *FileName::splitPath(const char *path) while (isspace(*p)) // skip leading whitespace p++; buf.reserve(strlen(p) + 1); // guess size of path + // LDC remember first character + const char* start = p; for (; ; p++) { c = *p; @@ -398,6 +400,9 @@ Array *FileName::splitPath(const char *path) #if POSIX case '~': + // LDC don't expand unless first character of path + if (p != start) + goto Ldefault; buf.writestring(getenv("HOME")); continue; #endif @@ -407,6 +412,7 @@ Array *FileName::splitPath(const char *path) if (!instring) // if not in string break; // treat as end of path default: + Ldefault: buf.writeByte(c); continue; }