Mercurial > emacs
comparison src/fileio.c @ 108888:c2ac5cece5ea
Turn `directory-sep-char' into a noop.
* lisp/subr.el (directory-sep-char): Move from fileio.c and make a defconst.
* src/emacs.c (decode_env_path): Don't check DIRECTORY_SEP,
call dostounix_filename directly.
* src/fileio.c (CORRECT_DIR_SEPS): Remove.
(Ffile_name_directory, directory_file_name, Fexpand_file_name)
(Fsubstitute_in_file_name): Use dostounix_filename instead.
(file_name_as_directory): Use dostounix_filename, DIRECTORY_SEP.
(syms_of_fileio) <directory-sep-char>: Move to subr.el.
* src/lisp.h [WINDOWSNT] (Vdirectory_sep_char): Don't declare.
(DIRECTORY_SEP): Define unconditionally.
* src/w32proc.c (CORRECT_DIR_SEPS): Remove.
(Fw32_short_file_name, Fw32_long_file_name): Use dostounix_filename.
* src/s/ms-w32.h (DIRECTORY_SEP): Remove.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Fri, 04 Jun 2010 16:13:35 +0200 |
parents | 6515310887ec |
children | 2bc9a0c04c87 |
comparison
equal
deleted
inserted
replaced
108887:2c20a51413cb | 108888:c2ac5cece5ea |
---|---|
81 #include <fcntl.h> | 81 #include <fcntl.h> |
82 #include <string.h> | 82 #include <string.h> |
83 #endif | 83 #endif |
84 | 84 |
85 #ifdef DOS_NT | 85 #ifdef DOS_NT |
86 #define CORRECT_DIR_SEPS(s) \ | |
87 do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \ | |
88 else unixtodos_filename (s); \ | |
89 } while (0) | |
90 /* On Windows, drive letters must be alphabetic - on DOS, the Netware | 86 /* On Windows, drive letters must be alphabetic - on DOS, the Netware |
91 redirector allows the six letters between 'Z' and 'a' as well. */ | 87 redirector allows the six letters between 'Z' and 'a' as well. */ |
92 #ifdef MSDOS | 88 #ifdef MSDOS |
93 #define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z') | 89 #define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z') |
94 #endif | 90 #endif |
472 strcat (res, "/"); | 468 strcat (res, "/"); |
473 beg = res; | 469 beg = res; |
474 p = beg + strlen (beg); | 470 p = beg + strlen (beg); |
475 } | 471 } |
476 } | 472 } |
477 CORRECT_DIR_SEPS (beg); | 473 dostounix_filename (beg); |
478 #endif /* DOS_NT */ | 474 #endif /* DOS_NT */ |
479 | 475 |
480 return make_specified_string (beg, -1, p - beg, STRING_MULTIBYTE (filename)); | 476 return make_specified_string (beg, -1, p - beg, STRING_MULTIBYTE (filename)); |
481 } | 477 } |
482 | 478 |
559 } | 555 } |
560 | 556 |
561 /* For Unix syntax, Append a slash if necessary */ | 557 /* For Unix syntax, Append a slash if necessary */ |
562 if (!IS_DIRECTORY_SEP (out[size])) | 558 if (!IS_DIRECTORY_SEP (out[size])) |
563 { | 559 { |
564 /* Cannot use DIRECTORY_SEP, which could have any value */ | 560 out[size + 1] = DIRECTORY_SEP; |
565 out[size + 1] = '/'; | |
566 out[size + 2] = '\0'; | 561 out[size + 2] = '\0'; |
567 } | 562 } |
568 #ifdef DOS_NT | 563 #ifdef DOS_NT |
569 CORRECT_DIR_SEPS (out); | 564 dostounix_filename (out); |
570 #endif | 565 #endif |
571 return out; | 566 return out; |
572 } | 567 } |
573 | 568 |
574 DEFUN ("file-name-as-directory", Ffile_name_as_directory, | 569 DEFUN ("file-name-as-directory", Ffile_name_as_directory, |
625 && !IS_ANY_SEP (dst[slen - 2]) | 620 && !IS_ANY_SEP (dst[slen - 2]) |
626 #endif | 621 #endif |
627 ) | 622 ) |
628 dst[slen - 1] = 0; | 623 dst[slen - 1] = 0; |
629 #ifdef DOS_NT | 624 #ifdef DOS_NT |
630 CORRECT_DIR_SEPS (dst); | 625 dostounix_filename (dst); |
631 #endif | 626 #endif |
632 return 1; | 627 return 1; |
633 } | 628 } |
634 | 629 |
635 DEFUN ("directory-file-name", Fdirectory_file_name, Sdirectory_file_name, | 630 DEFUN ("directory-file-name", Fdirectory_file_name, Sdirectory_file_name, |
1030 p++; | 1025 p++; |
1031 } | 1026 } |
1032 if (!lose) | 1027 if (!lose) |
1033 { | 1028 { |
1034 #ifdef DOS_NT | 1029 #ifdef DOS_NT |
1035 /* Make sure directories are all separated with / or \ as | 1030 /* Make sure directories are all separated with /, but |
1036 desired, but avoid allocation of a new string when not | 1031 avoid allocation of a new string when not required. */ |
1037 required. */ | 1032 dostounix_filename (nm); |
1038 CORRECT_DIR_SEPS (nm); | |
1039 #ifdef WINDOWSNT | 1033 #ifdef WINDOWSNT |
1040 if (IS_DIRECTORY_SEP (nm[1])) | 1034 if (IS_DIRECTORY_SEP (nm[1])) |
1041 { | 1035 { |
1042 if (strcmp (nm, SDATA (name)) != 0) | 1036 if (strcmp (nm, SDATA (name)) != 0) |
1043 name = make_specified_string (nm, -1, strlen (nm), multibyte); | 1037 name = make_specified_string (nm, -1, strlen (nm), multibyte); |
1379 { | 1373 { |
1380 target -= 2; | 1374 target -= 2; |
1381 target[0] = '/'; | 1375 target[0] = '/'; |
1382 target[1] = ':'; | 1376 target[1] = ':'; |
1383 } | 1377 } |
1384 CORRECT_DIR_SEPS (target); | 1378 dostounix_filename (target); |
1385 #endif /* DOS_NT */ | 1379 #endif /* DOS_NT */ |
1386 | 1380 |
1387 result = make_specified_string (target, -1, o - target, multibyte); | 1381 result = make_specified_string (target, -1, o - target, multibyte); |
1388 } | 1382 } |
1389 | 1383 |
1657 data to be relocated. */ | 1651 data to be relocated. */ |
1658 nm = (unsigned char *) alloca (SBYTES (filename) + 1); | 1652 nm = (unsigned char *) alloca (SBYTES (filename) + 1); |
1659 bcopy (SDATA (filename), nm, SBYTES (filename) + 1); | 1653 bcopy (SDATA (filename), nm, SBYTES (filename) + 1); |
1660 | 1654 |
1661 #ifdef DOS_NT | 1655 #ifdef DOS_NT |
1662 CORRECT_DIR_SEPS (nm); | 1656 dostounix_filename (nm); |
1663 substituted = (strcmp (nm, SDATA (filename)) != 0); | 1657 substituted = (strcmp (nm, SDATA (filename)) != 0); |
1664 #endif | 1658 #endif |
1665 endp = nm + SBYTES (filename); | 1659 endp = nm + SBYTES (filename); |
1666 | 1660 |
1667 /* If /~ or // appears, discard everything through first slash. */ | 1661 /* If /~ or // appears, discard everything through first slash. */ |
5784 | 5778 |
5785 Fput (Qfile_date_error, Qerror_conditions, | 5779 Fput (Qfile_date_error, Qerror_conditions, |
5786 Fpurecopy (list3 (Qfile_date_error, Qfile_error, Qerror))); | 5780 Fpurecopy (list3 (Qfile_date_error, Qfile_error, Qerror))); |
5787 Fput (Qfile_date_error, Qerror_message, | 5781 Fput (Qfile_date_error, Qerror_message, |
5788 make_pure_c_string ("Cannot set file date")); | 5782 make_pure_c_string ("Cannot set file date")); |
5789 | |
5790 DEFVAR_LISP ("directory-sep-char", &Vdirectory_sep_char, | |
5791 doc: /* Directory separator character for built-in functions that return file names. | |
5792 The value is always ?/. Don't use this variable, just use `/'. */); | |
5793 XSETFASTINT (Vdirectory_sep_char, '/'); | |
5794 | 5783 |
5795 DEFVAR_LISP ("file-name-handler-alist", &Vfile_name_handler_alist, | 5784 DEFVAR_LISP ("file-name-handler-alist", &Vfile_name_handler_alist, |
5796 doc: /* *Alist of elements (REGEXP . HANDLER) for file names handled specially. | 5785 doc: /* *Alist of elements (REGEXP . HANDLER) for file names handled specially. |
5797 If a file name matches REGEXP, then all I/O on that file is done by calling | 5786 If a file name matches REGEXP, then all I/O on that file is done by calling |
5798 HANDLER. | 5787 HANDLER. |