Mercurial > emacs
comparison src/fileio.c @ 8185:b5cc015a3698
(Ffile_name_directory, Ffile_name_nondirectory,
file_name_as_directory, directory_file_name, Fexpand_file_name,
Ffile_name_absolute_p, Fsubstitute_in_file_name) [MSDOS]:
Allow backslashed file names.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 09 Jul 1994 19:10:16 +0000 |
parents | 3f543986a45a |
children | 0e6b7eeedc3b |
comparison
equal
deleted
inserted
replaced
8184:8ccef13ebe58 | 8185:b5cc015a3698 |
---|---|
288 while (p != beg && p[-1] != '/' | 288 while (p != beg && p[-1] != '/' |
289 #ifdef VMS | 289 #ifdef VMS |
290 && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' | 290 && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' |
291 #endif /* VMS */ | 291 #endif /* VMS */ |
292 #ifdef MSDOS | 292 #ifdef MSDOS |
293 && p[-1] != ':' | 293 && p[-1] != ':' && p[-1] != '\\' |
294 #endif | 294 #endif |
295 ) p--; | 295 ) p--; |
296 | 296 |
297 if (p == beg) | 297 if (p == beg) |
298 return Qnil; | 298 return Qnil; |
343 while (p != beg && p[-1] != '/' | 343 while (p != beg && p[-1] != '/' |
344 #ifdef VMS | 344 #ifdef VMS |
345 && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' | 345 && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' |
346 #endif /* VMS */ | 346 #endif /* VMS */ |
347 #ifdef MSDOS | 347 #ifdef MSDOS |
348 && p[-1] != ':' | 348 && p[-1] != ':' && p[-1] != '\\' |
349 #endif | 349 #endif |
350 ) p--; | 350 ) p--; |
351 | 351 |
352 return make_string (p, end - p); | 352 return make_string (p, end - p); |
353 } | 353 } |
441 out[size] = '\0'; | 441 out[size] = '\0'; |
442 } | 442 } |
443 #else /* not VMS */ | 443 #else /* not VMS */ |
444 /* For Unix syntax, Append a slash if necessary */ | 444 /* For Unix syntax, Append a slash if necessary */ |
445 #ifdef MSDOS | 445 #ifdef MSDOS |
446 if (out[size] != ':' && out[size] != '/') | 446 if (out[size] != ':' && out[size] != '/' && out[size] != '\\') |
447 #else | 447 #else |
448 if (out[size] != '/') | 448 if (out[size] != '/') |
449 #endif | 449 #endif |
450 strcat (out, "/"); | 450 strcat (out, "/"); |
451 #endif /* not VMS */ | 451 #endif /* not VMS */ |
621 #endif /* VMS */ | 621 #endif /* VMS */ |
622 /* Process as Unix format: just remove any final slash. | 622 /* Process as Unix format: just remove any final slash. |
623 But leave "/" unchanged; do not change it to "". */ | 623 But leave "/" unchanged; do not change it to "". */ |
624 strcpy (dst, src); | 624 strcpy (dst, src); |
625 if (slen > 1 | 625 if (slen > 1 |
626 #ifdef MSDOS | |
627 && (dst[slen - 1] == '/' || dst[slen - 1] == '/') | |
628 && dst[slen - 2] != ':' | |
629 #else | |
626 && dst[slen - 1] == '/' | 630 && dst[slen - 1] == '/' |
627 #ifdef MSDOS | |
628 && dst[slen - 2] != ':' | |
629 #endif | 631 #endif |
630 ) | 632 ) |
631 dst[slen - 1] = 0; | 633 dst[slen - 1] = 0; |
632 return 1; | 634 return 1; |
633 } | 635 } |
762 #endif | 764 #endif |
763 | 765 |
764 nm = XSTRING (name)->data; | 766 nm = XSTRING (name)->data; |
765 | 767 |
766 #ifdef MSDOS | 768 #ifdef MSDOS |
767 /* firstly, strip drive name. */ | 769 /* First map all backslashes to slashes. */ |
770 dostounix_filename (nm = strcpy (alloca (strlen (nm) + 1), nm)); | |
771 | |
772 /* Now strip drive name. */ | |
768 { | 773 { |
769 unsigned char *colon = rindex (nm, ':'); | 774 unsigned char *colon = rindex (nm, ':'); |
770 if (colon) | 775 if (colon) |
771 if (nm == colon) | 776 if (nm == colon) |
772 nm++; | 777 nm++; |
1485 unsigned char *xnm; | 1490 unsigned char *xnm; |
1486 | 1491 |
1487 CHECK_STRING (string, 0); | 1492 CHECK_STRING (string, 0); |
1488 | 1493 |
1489 nm = XSTRING (string)->data; | 1494 nm = XSTRING (string)->data; |
1495 #ifdef MSDOS | |
1496 dostounix_filename (nm = strcpy (alloca (strlen (nm) + 1), nm)); | |
1497 substituted = !strcmp (nm, XSTRING (string)->data); | |
1498 #endif | |
1490 endp = nm + XSTRING (string)->size; | 1499 endp = nm + XSTRING (string)->size; |
1491 | 1500 |
1492 /* If /~ or // appears, discard everything through first slash. */ | 1501 /* If /~ or // appears, discard everything through first slash. */ |
1493 | 1502 |
1494 for (p = nm; p != endp; p++) | 1503 for (p = nm; p != endp; p++) |
2137 || index (ptr, ':') || index (ptr, '<') | 2146 || index (ptr, ':') || index (ptr, '<') |
2138 || (*ptr == '[' && (ptr[1] != '-' || (ptr[2] != '.' && ptr[2] != ']')) | 2147 || (*ptr == '[' && (ptr[1] != '-' || (ptr[2] != '.' && ptr[2] != ']')) |
2139 && ptr[1] != '.') | 2148 && ptr[1] != '.') |
2140 #endif /* VMS */ | 2149 #endif /* VMS */ |
2141 #ifdef MSDOS | 2150 #ifdef MSDOS |
2142 || (*ptr != 0 && ptr[1] == ':' && ptr[2] == '/') | 2151 || (*ptr != 0 && ptr[1] == ':' && (ptr[2] == '/' || ptr[2] == '\\')) |
2143 #endif | 2152 #endif |
2144 ) | 2153 ) |
2145 return Qt; | 2154 return Qt; |
2146 else | 2155 else |
2147 return Qnil; | 2156 return Qnil; |