Mercurial > hg > xemacs-beta
comparison src/fileio.c @ 298:70ad99077275 r21-0b47
Import from CVS: tag r21-0b47
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:39:40 +0200 |
parents | 4b85ae5eabfb |
children | d1b52dcaa789 |
comparison
equal
deleted
inserted
replaced
297:deca3c1083ac | 298:70ad99077275 |
---|---|
896 /* If we see "c://somedir", we want to strip the first slash after the | 896 /* If we see "c://somedir", we want to strip the first slash after the |
897 colon when stripping the drive letter. Otherwise, this expands to | 897 colon when stripping the drive letter. Otherwise, this expands to |
898 "//somedir". */ | 898 "//somedir". */ |
899 if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) | 899 if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) |
900 nm++; | 900 nm++; |
901 | |
902 /* Discard any previous drive specifier if nm is now in UNC format. */ | |
903 if (IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) | |
904 { | |
905 drive = 0; | |
906 } | |
907 #endif /* WINDOWSNT */ | 901 #endif /* WINDOWSNT */ |
908 | 902 |
909 /* If nm is absolute, look for /./ or /../ sequences; if none are | 903 /* If nm is absolute, look for /./ or /../ sequences; if none are |
910 found, we can probably return right away. We will avoid allocating | 904 found, we can probably return right away. We will avoid allocating |
911 a new string if name is already fully expanded. */ | 905 a new string if name is already fully expanded. */ |
1102 /* Detect MSDOS file names with drive specifiers. */ | 1096 /* Detect MSDOS file names with drive specifiers. */ |
1103 ! (IS_DRIVE (newdir[0]) | 1097 ! (IS_DRIVE (newdir[0]) |
1104 && IS_DEVICE_SEP (newdir[1]) && IS_DIRECTORY_SEP (newdir[2])) | 1098 && IS_DEVICE_SEP (newdir[1]) && IS_DIRECTORY_SEP (newdir[2])) |
1105 /* Detect Windows file names in UNC format. */ | 1099 /* Detect Windows file names in UNC format. */ |
1106 && ! (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1])) | 1100 && ! (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1])) |
1101 /* Detect drive spec by itself */ | |
1102 && ! (IS_DEVICE_SEP (newdir[1]) && newdir[2] == 0) | |
1107 ) | 1103 ) |
1108 { | 1104 { |
1109 /* Effectively, let newdir be (expand-file-name newdir cwd). | 1105 /* Effectively, let newdir be (expand-file-name newdir cwd). |
1110 Because of the admonition against calling expand-file-name | 1106 Because of the admonition against calling expand-file-name |
1111 when we have pointers into lisp strings, we accomplish this | 1107 when we have pointers into lisp strings, we accomplish this |
1237 /* Keep initial / only if this is the whole name. */ | 1233 /* Keep initial / only if this is the whole name. */ |
1238 if (o == target && IS_ANY_SEP (*o) && p[3] == 0) | 1234 if (o == target && IS_ANY_SEP (*o) && p[3] == 0) |
1239 ++o; | 1235 ++o; |
1240 p += 3; | 1236 p += 3; |
1241 } | 1237 } |
1238 #ifdef WINDOWSNT | |
1239 /* if drive is set, we're not dealing with an UNC, so | |
1240 multiple dir-seps are redundant (and reportedly cause trouble | |
1241 under win95) */ | |
1242 else if (drive && IS_DIRECTORY_SEP (p[0]) && IS_DIRECTORY_SEP (p[1])) | |
1243 ++p; | |
1244 #endif | |
1242 else | 1245 else |
1243 { | 1246 { |
1244 *o++ = *p++; | 1247 *o++ = *p++; |
1245 } | 1248 } |
1246 } | 1249 } |
1247 | 1250 |
1248 #ifdef WINDOWSNT | 1251 #ifdef WINDOWSNT |
1249 /* At last, set drive name, except for network file name. */ | 1252 /* At last, set drive name, except for network file name. */ |
1250 if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) | 1253 if (drive) |
1251 { | 1254 { |
1252 if (!drive) abort (); | |
1253 target -= 2; | 1255 target -= 2; |
1254 target[0] = DRIVE_LETTER (drive); | 1256 target[0] = DRIVE_LETTER (drive); |
1255 target[1] = ':'; | 1257 target[1] = ':'; |
1258 } | |
1259 else | |
1260 { | |
1261 if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) | |
1262 abort (); | |
1256 } | 1263 } |
1257 CORRECT_DIR_SEPS (target); | 1264 CORRECT_DIR_SEPS (target); |
1258 #endif /* WINDOWSNT */ | 1265 #endif /* WINDOWSNT */ |
1259 | 1266 |
1260 return make_string (target, o - target); | 1267 return make_string (target, o - target); |
1412 if (!NILP (handler)) | 1419 if (!NILP (handler)) |
1413 return call2_check_string_or_nil (handler, Qsubstitute_in_file_name, | 1420 return call2_check_string_or_nil (handler, Qsubstitute_in_file_name, |
1414 string); | 1421 string); |
1415 | 1422 |
1416 nm = XSTRING_DATA (string); | 1423 nm = XSTRING_DATA (string); |
1417 #ifdef WINDOWSNT | |
1418 nm = strcpy (alloca (strlen (nm) + 1), nm); | |
1419 CORRECT_DIR_SEPS (nm); | |
1420 substituted = (strcmp (nm, XSTRING_DATA (string)) != 0); | |
1421 #endif | |
1422 endp = nm + XSTRING_LENGTH (string); | 1424 endp = nm + XSTRING_LENGTH (string); |
1423 | 1425 |
1424 /* If /~ or // appears, discard everything through first slash. */ | 1426 /* If /~ or // appears, discard everything through first slash. */ |
1425 | 1427 |
1426 for (p = nm; p != endp; p++) | 1428 for (p = nm; p != endp; p++) |
1427 { | 1429 { |
1428 if ((p[0] == '~' | 1430 if ((p[0] == '~' |
1429 #if defined (APOLLO) || defined (WINDOWSNT) | 1431 #if defined (APOLLO) || defined (WINDOWSNT) || defined (__CYGWIN32__) |
1430 /* // at start of file name is meaningful in Apollo and | 1432 /* // at start of file name is meaningful in Apollo and |
1431 WindowsNT systems */ | 1433 WindowsNT systems */ |
1432 || (IS_DIRECTORY_SEP (p[0]) && p - 1 != nm) | 1434 || (IS_DIRECTORY_SEP (p[0]) && p - 1 != nm) |
1433 #else /* not (APOLLO || WINDOWSNT) */ | 1435 #else /* not (APOLLO || WINDOWSNT || __CYGWIN32__) */ |
1434 || IS_DIRECTORY_SEP (p[0]) | 1436 || IS_DIRECTORY_SEP (p[0]) |
1435 #endif /* not (APOLLO || WINDOWSNT) */ | 1437 #endif /* not (APOLLO || WINDOWSNT || __CYGWIN32__) */ |
1436 ) | 1438 ) |
1437 && p != nm | 1439 && p != nm |
1438 && (IS_DIRECTORY_SEP (p[-1]))) | 1440 && (IS_DIRECTORY_SEP (p[-1]))) |
1439 { | 1441 { |
1440 nm = p; | 1442 nm = p; |