diff options
| author | Kenichi Handa | 2003-03-19 11:54:57 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-03-19 11:54:57 +0000 |
| commit | d7231f93e6870b531536e4d0c716b68759241ebc (patch) | |
| tree | 24f580dec0f6f86491d07234b5a64d2f0ca7bf9a /src | |
| parent | f9babe52503eef3360b966bfe8c03752e26a78d0 (diff) | |
| download | emacs-d7231f93e6870b531536e4d0c716b68759241ebc.tar.gz emacs-d7231f93e6870b531536e4d0c716b68759241ebc.zip | |
(Ffile_name_directory): Reconstruct file name by
make_specified_string.
(Ffile_name_nondirectory, Ffile_name_as_directory)
(Fdirectory_file_name, Fexpand_file_name)
(Fsubstitute_in_file_name): Likewise.
(Fread_file_name): Compare decoded homedir with DIR and
DEFAULT_FILENAME.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/src/fileio.c b/src/fileio.c index 02b45ed077c..f7bfdc16f9d 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -447,9 +447,7 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'. */) | |||
| 447 | CORRECT_DIR_SEPS (beg); | 447 | CORRECT_DIR_SEPS (beg); |
| 448 | #endif /* DOS_NT */ | 448 | #endif /* DOS_NT */ |
| 449 | 449 | ||
| 450 | if (STRING_MULTIBYTE (filename)) | 450 | return make_specified_string (beg, -1, p - beg, STRING_MULTIBYTE (filename)); |
| 451 | return make_string (beg, p - beg); | ||
| 452 | return make_unibyte_string (beg, p - beg); | ||
| 453 | } | 451 | } |
| 454 | 452 | ||
| 455 | DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, | 453 | DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, |
| @@ -488,9 +486,7 @@ or the entire name if it contains no slash. */) | |||
| 488 | ) | 486 | ) |
| 489 | p--; | 487 | p--; |
| 490 | 488 | ||
| 491 | if (STRING_MULTIBYTE (filename)) | 489 | return make_specified_string (p, -1, end - p, STRING_MULTIBYTE (filename)); |
| 492 | return make_string (p, end - p); | ||
| 493 | return make_unibyte_string (p, end - p); | ||
| 494 | } | 490 | } |
| 495 | 491 | ||
| 496 | DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory, | 492 | DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory, |
| @@ -631,7 +627,9 @@ On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc. */) | |||
| 631 | return call2 (handler, Qfile_name_as_directory, file); | 627 | return call2 (handler, Qfile_name_as_directory, file); |
| 632 | 628 | ||
| 633 | buf = (char *) alloca (SBYTES (file) + 10); | 629 | buf = (char *) alloca (SBYTES (file) + 10); |
| 634 | return build_string (file_name_as_directory (buf, SDATA (file))); | 630 | file_name_as_directory (buf, SDATA (file)); |
| 631 | return make_specified_string (buf, -1, strlen (buf), | ||
| 632 | STRING_MULTIBYTE (file)); | ||
| 635 | } | 633 | } |
| 636 | 634 | ||
| 637 | /* | 635 | /* |
| @@ -831,7 +829,8 @@ it returns a file name such as \"[X]Y.DIR.1\". */) | |||
| 831 | buf = (char *) alloca (SBYTES (directory) + 20); | 829 | buf = (char *) alloca (SBYTES (directory) + 20); |
| 832 | #endif | 830 | #endif |
| 833 | directory_file_name (SDATA (directory), buf); | 831 | directory_file_name (SDATA (directory), buf); |
| 834 | return build_string (buf); | 832 | return make_specified_string (buf, -1, strlen (buf), |
| 833 | STRING_MULTIBYTE (directory)); | ||
| 835 | } | 834 | } |
| 836 | 835 | ||
| 837 | static char make_temp_name_tbl[64] = | 836 | static char make_temp_name_tbl[64] = |
| @@ -1275,7 +1274,11 @@ See also the function `substitute-in-file-name'. */) | |||
| 1275 | { | 1274 | { |
| 1276 | #ifdef VMS | 1275 | #ifdef VMS |
| 1277 | if (index (nm, '/')) | 1276 | if (index (nm, '/')) |
| 1278 | return build_string (sys_translate_unix (nm)); | 1277 | { |
| 1278 | nm = sys_translate_unix (nm); | ||
| 1279 | return make_specified_string (nm, -1, strlen (nm), | ||
| 1280 | STRING_MULTIBYTE (name)); | ||
| 1281 | } | ||
| 1279 | #endif /* VMS */ | 1282 | #endif /* VMS */ |
| 1280 | #ifdef DOS_NT | 1283 | #ifdef DOS_NT |
| 1281 | /* Make sure directories are all separated with / or \ as | 1284 | /* Make sure directories are all separated with / or \ as |
| @@ -1286,14 +1289,18 @@ See also the function `substitute-in-file-name'. */) | |||
| 1286 | if (IS_DIRECTORY_SEP (nm[1])) | 1289 | if (IS_DIRECTORY_SEP (nm[1])) |
| 1287 | { | 1290 | { |
| 1288 | if (strcmp (nm, SDATA (name)) != 0) | 1291 | if (strcmp (nm, SDATA (name)) != 0) |
| 1289 | name = build_string (nm); | 1292 | name |
| 1293 | = make_specified_string (nm, -1, strlen (nm), | ||
| 1294 | STRING_MULTIBYTE (name)); | ||
| 1290 | } | 1295 | } |
| 1291 | else | 1296 | else |
| 1292 | #endif | 1297 | #endif |
| 1293 | /* drive must be set, so this is okay */ | 1298 | /* drive must be set, so this is okay */ |
| 1294 | if (strcmp (nm - 2, SDATA (name)) != 0) | 1299 | if (strcmp (nm - 2, SDATA (name)) != 0) |
| 1295 | { | 1300 | { |
| 1296 | name = make_string (nm - 2, p - nm + 2); | 1301 | name |
| 1302 | = make_specified_string (nm, -1, strlen (nm), | ||
| 1303 | STRING_MULTIBYTE (name)); | ||
| 1297 | SSET (name, 0, DRIVE_LETTER (drive)); | 1304 | SSET (name, 0, DRIVE_LETTER (drive)); |
| 1298 | SSET (name, 1, ':'); | 1305 | SSET (name, 1, ':'); |
| 1299 | } | 1306 | } |
| @@ -1301,7 +1308,8 @@ See also the function `substitute-in-file-name'. */) | |||
| 1301 | #else /* not DOS_NT */ | 1308 | #else /* not DOS_NT */ |
| 1302 | if (nm == SDATA (name)) | 1309 | if (nm == SDATA (name)) |
| 1303 | return name; | 1310 | return name; |
| 1304 | return build_string (nm); | 1311 | return make_specified_string (nm, -1, strlen (nm), |
| 1312 | STRING_MULTIBYTE (name)); | ||
| 1305 | #endif /* not DOS_NT */ | 1313 | #endif /* not DOS_NT */ |
| 1306 | } | 1314 | } |
| 1307 | } | 1315 | } |
| @@ -1670,7 +1678,8 @@ See also the function `substitute-in-file-name'. */) | |||
| 1670 | CORRECT_DIR_SEPS (target); | 1678 | CORRECT_DIR_SEPS (target); |
| 1671 | #endif /* DOS_NT */ | 1679 | #endif /* DOS_NT */ |
| 1672 | 1680 | ||
| 1673 | return make_string (target, o - target); | 1681 | return make_specified_string (target, -1, o - target, |
| 1682 | STRING_MULTIBYTE (name)); | ||
| 1674 | } | 1683 | } |
| 1675 | 1684 | ||
| 1676 | #if 0 | 1685 | #if 0 |
| @@ -2101,7 +2110,8 @@ duplicates what `expand-file-name' does. */) | |||
| 2101 | } | 2110 | } |
| 2102 | 2111 | ||
| 2103 | #ifdef VMS | 2112 | #ifdef VMS |
| 2104 | return build_string (nm); | 2113 | return make_specified_string (nm, -1, strlen (nm), |
| 2114 | STRING_MULTIBYTE (filename)); | ||
| 2105 | #else | 2115 | #else |
| 2106 | 2116 | ||
| 2107 | /* See if any variables are substituted into the string | 2117 | /* See if any variables are substituted into the string |
| @@ -2244,9 +2254,7 @@ duplicates what `expand-file-name' does. */) | |||
| 2244 | xnm = p; | 2254 | xnm = p; |
| 2245 | #endif | 2255 | #endif |
| 2246 | 2256 | ||
| 2247 | if (STRING_MULTIBYTE (filename)) | 2257 | return make_specified_string (xnm, -1, x - xnm, STRING_MULTIBYTE (filename)); |
| 2248 | return make_string (xnm, x - xnm); | ||
| 2249 | return make_unibyte_string (xnm, x - xnm); | ||
| 2250 | 2258 | ||
| 2251 | badsubst: | 2259 | badsubst: |
| 2252 | error ("Bad format environment-variable substitution"); | 2260 | error ("Bad format environment-variable substitution"); |
| @@ -6023,6 +6031,7 @@ provides a file dialog box. */) | |||
| 6023 | Lisp_Object val, insdef, tem; | 6031 | Lisp_Object val, insdef, tem; |
| 6024 | struct gcpro gcpro1, gcpro2; | 6032 | struct gcpro gcpro1, gcpro2; |
| 6025 | register char *homedir; | 6033 | register char *homedir; |
| 6034 | Lisp_Object decoded_homedir; | ||
| 6026 | int replace_in_history = 0; | 6035 | int replace_in_history = 0; |
| 6027 | int add_to_history = 0; | 6036 | int add_to_history = 0; |
| 6028 | int count; | 6037 | int count; |
| @@ -6045,25 +6054,29 @@ provides a file dialog box. */) | |||
| 6045 | CORRECT_DIR_SEPS (homedir); | 6054 | CORRECT_DIR_SEPS (homedir); |
| 6046 | } | 6055 | } |
| 6047 | #endif | 6056 | #endif |
| 6057 | if (homedir != 0) | ||
| 6058 | decoded_homedir | ||
| 6059 | = DECODE_FILE (make_unibyte_string (homedir, strlen (homedir))); | ||
| 6048 | if (homedir != 0 | 6060 | if (homedir != 0 |
| 6049 | && STRINGP (dir) | 6061 | && STRINGP (dir) |
| 6050 | && !strncmp (homedir, SDATA (dir), strlen (homedir)) | 6062 | && !strncmp (SDATA (decoded_homedir), SDATA (dir), |
| 6051 | && IS_DIRECTORY_SEP (SREF (dir, strlen (homedir)))) | 6063 | SBYTES (decoded_homedir)) |
| 6064 | && IS_DIRECTORY_SEP (SREF (dir, SBYTES (decoded_homedir)))) | ||
| 6052 | { | 6065 | { |
| 6053 | dir = make_string (SDATA (dir) + strlen (homedir) - 1, | 6066 | dir = Fsubstring (dir, make_number (SCHARS (decoded_homedir) + 1), Qnil); |
| 6054 | SBYTES (dir) - strlen (homedir) + 1); | 6067 | dir = concat2 (build_string ("~"), dir); |
| 6055 | SSET (dir, 0, '~'); | ||
| 6056 | } | 6068 | } |
| 6057 | /* Likewise for default_filename. */ | 6069 | /* Likewise for default_filename. */ |
| 6058 | if (homedir != 0 | 6070 | if (homedir != 0 |
| 6059 | && STRINGP (default_filename) | 6071 | && STRINGP (default_filename) |
| 6060 | && !strncmp (homedir, SDATA (default_filename), strlen (homedir)) | 6072 | && !strncmp (SDATA (decoded_homedir), SDATA (default_filename), |
| 6061 | && IS_DIRECTORY_SEP (SREF (default_filename, strlen (homedir)))) | 6073 | SBYTES (decoded_homedir)) |
| 6074 | && IS_DIRECTORY_SEP (SREF (default_filename, SBYTES (decoded_homedir)))) | ||
| 6062 | { | 6075 | { |
| 6063 | default_filename | 6076 | default_filename |
| 6064 | = make_string (SDATA (default_filename) + strlen (homedir) - 1, | 6077 | = Fsubstring (default_filename, |
| 6065 | SBYTES (default_filename) - strlen (homedir) + 1); | 6078 | make_number (SCHARS (decoded_homedir) + 1), Qnil); |
| 6066 | SSET (default_filename, 0, '~'); | 6079 | default_filename = concat2 (build_string ("~"), default_filename); |
| 6067 | } | 6080 | } |
| 6068 | if (!NILP (default_filename)) | 6081 | if (!NILP (default_filename)) |
| 6069 | { | 6082 | { |