Don't expand tilde ('~') in paths unless it's the first character of the path

in question.
This should fix #255.
This commit is contained in:
Frits van Bommel
2009-04-03 16:35:47 +02:00
parent 9c4b2b4036
commit b7b54b5878

View File

@@ -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;
}