comparison dmd/root.c @ 1193:c271eca933fb

Don't expand tilde ('~') in paths unless it's the first character of the path in question. This should fix #255.
author Frits van Bommel <fvbommel wxs.nl>
date Fri, 03 Apr 2009 16:35:47 +0200
parents 0f8aeb31678c
children
comparison
equal deleted inserted replaced
1192:3251ce06c820 1193:c271eca933fb
365 { char instring = 0; 365 { char instring = 0;
366 366
367 while (isspace(*p)) // skip leading whitespace 367 while (isspace(*p)) // skip leading whitespace
368 p++; 368 p++;
369 buf.reserve(strlen(p) + 1); // guess size of path 369 buf.reserve(strlen(p) + 1); // guess size of path
370 // LDC remember first character
371 const char* start = p;
370 for (; ; p++) 372 for (; ; p++)
371 { 373 {
372 c = *p; 374 c = *p;
373 switch (c) 375 switch (c)
374 { 376 {
396 case '\r': 398 case '\r':
397 continue; // ignore carriage returns 399 continue; // ignore carriage returns
398 400
399 #if POSIX 401 #if POSIX
400 case '~': 402 case '~':
403 // LDC don't expand unless first character of path
404 if (p != start)
405 goto Ldefault;
401 buf.writestring(getenv("HOME")); 406 buf.writestring(getenv("HOME"));
402 continue; 407 continue;
403 #endif 408 #endif
404 409
405 case ' ': 410 case ' ':
406 case '\t': // tabs in filenames? 411 case '\t': // tabs in filenames?
407 if (!instring) // if not in string 412 if (!instring) // if not in string
408 break; // treat as end of path 413 break; // treat as end of path
409 default: 414 default:
415 Ldefault:
410 buf.writeByte(c); 416 buf.writeByte(c);
411 continue; 417 continue;
412 } 418 }
413 break; 419 break;
414 } 420 }