diff options
| author | Jason Rumney | 2008-03-05 00:20:52 +0000 |
|---|---|---|
| committer | Jason Rumney | 2008-03-05 00:20:52 +0000 |
| commit | 4e5a6f83a89701b3868a37ded7882d62398120d8 (patch) | |
| tree | 900b8078a32f447b435495e6d205250ba949bde6 /src | |
| parent | bbcedd051459ad914807c097884d70ed871690ce (diff) | |
| download | emacs-4e5a6f83a89701b3868a37ded7882d62398120d8.tar.gz emacs-4e5a6f83a89701b3868a37ded7882d62398120d8.zip | |
(Fexpand_file_name): Decode home directory names.
(Fsubstitute_in_file_name): Decode substituted variables.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/fileio.c | 47 |
2 files changed, 40 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 6da585c7a1b..c6b17b1cb20 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-03-05 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * fileio.c (Fexpand_file_name): Decode home directory names. | ||
| 4 | (Fsubstitute_in_file_name): Decode substituted variables. | ||
| 5 | |||
| 1 | 2008-03-03 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 6 | 2008-03-03 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 2 | 7 | ||
| 3 | * xdisp.c (handle_single_display_spec): Undo 2007-10-16 changes. | 8 | * xdisp.c (handle_single_display_spec): Undo 2007-10-16 changes. |
diff --git a/src/fileio.c b/src/fileio.c index c5bff5b8153..d869bb0b2b6 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1408,6 +1408,19 @@ See also the function `substitute-in-file-name'. */) | |||
| 1408 | } | 1408 | } |
| 1409 | } | 1409 | } |
| 1410 | 1410 | ||
| 1411 | /* Environment variables and pwnam entries may need decoding. */ | ||
| 1412 | if (newdir) | ||
| 1413 | { | ||
| 1414 | Lisp_Object orig, decoded; | ||
| 1415 | orig = make_unibyte_string (newdir, strlen (newdir)); | ||
| 1416 | decoded = DECODE_FILE (orig); | ||
| 1417 | if (decoded != orig) | ||
| 1418 | { | ||
| 1419 | newdir = SDATA (decoded); | ||
| 1420 | multibyte = 1; | ||
| 1421 | } | ||
| 1422 | } | ||
| 1423 | |||
| 1411 | #ifdef DOS_NT | 1424 | #ifdef DOS_NT |
| 1412 | /* On DOS and Windows, nm is absolute if a drive name was specified; | 1425 | /* On DOS and Windows, nm is absolute if a drive name was specified; |
| 1413 | use the drive's current directory as the prefix if needed. */ | 1426 | use the drive's current directory as the prefix if needed. */ |
| @@ -2149,11 +2162,14 @@ duplicates what `expand-file-name' does. */) | |||
| 2149 | unsigned char *target = NULL; | 2162 | unsigned char *target = NULL; |
| 2150 | int total = 0; | 2163 | int total = 0; |
| 2151 | int substituted = 0; | 2164 | int substituted = 0; |
| 2165 | int multibyte; | ||
| 2152 | unsigned char *xnm; | 2166 | unsigned char *xnm; |
| 2153 | Lisp_Object handler; | 2167 | Lisp_Object handler; |
| 2154 | 2168 | ||
| 2155 | CHECK_STRING (filename); | 2169 | CHECK_STRING (filename); |
| 2156 | 2170 | ||
| 2171 | multibyte = STRING_MULTIBYTE (filename); | ||
| 2172 | |||
| 2157 | /* If the file name has special constructs in it, | 2173 | /* If the file name has special constructs in it, |
| 2158 | call the corresponding file handler. */ | 2174 | call the corresponding file handler. */ |
| 2159 | handler = Ffind_file_name_handler (filename, Qsubstitute_in_file_name); | 2175 | handler = Ffind_file_name_handler (filename, Qsubstitute_in_file_name); |
| @@ -2175,8 +2191,7 @@ duplicates what `expand-file-name' does. */) | |||
| 2175 | again. Important with filenames like "/home/foo//:/hello///there" | 2191 | again. Important with filenames like "/home/foo//:/hello///there" |
| 2176 | which whould substitute to "/:/hello///there" rather than "/there". */ | 2192 | which whould substitute to "/:/hello///there" rather than "/there". */ |
| 2177 | return Fsubstitute_in_file_name | 2193 | return Fsubstitute_in_file_name |
| 2178 | (make_specified_string (p, -1, endp - p, | 2194 | (make_specified_string (p, -1, endp - p, multibyte)); |
| 2179 | STRING_MULTIBYTE (filename))); | ||
| 2180 | 2195 | ||
| 2181 | #ifdef VMS | 2196 | #ifdef VMS |
| 2182 | return filename; | 2197 | return filename; |
| @@ -2227,7 +2242,10 @@ duplicates what `expand-file-name' does. */) | |||
| 2227 | o = (unsigned char *) egetenv (target); | 2242 | o = (unsigned char *) egetenv (target); |
| 2228 | if (o) | 2243 | if (o) |
| 2229 | { | 2244 | { |
| 2230 | total += strlen (o); | 2245 | Lisp_Object orig, decoded; |
| 2246 | orig = make_unibyte_string (o, strlen (o)); | ||
| 2247 | decoded = DECODE_FILE (orig); | ||
| 2248 | total += SBYTES (decoded); | ||
| 2231 | substituted = 1; | 2249 | substituted = 1; |
| 2232 | } | 2250 | } |
| 2233 | else if (*p == '}') | 2251 | else if (*p == '}') |
| @@ -2285,21 +2303,26 @@ duplicates what `expand-file-name' does. */) | |||
| 2285 | *x++ = '$'; | 2303 | *x++ = '$'; |
| 2286 | strcpy (x, target); x+= strlen (target); | 2304 | strcpy (x, target); x+= strlen (target); |
| 2287 | } | 2305 | } |
| 2288 | else if (STRING_MULTIBYTE (filename)) | 2306 | else |
| 2289 | { | 2307 | { |
| 2290 | /* If the original string is multibyte, | 2308 | Lisp_Object orig, decoded; |
| 2291 | convert what we substitute into multibyte. */ | 2309 | orig = make_unibyte_string (o, strlen (o)); |
| 2292 | while (*o) | 2310 | decoded = DECODE_FILE (orig); |
| 2293 | { | 2311 | strncpy (x, SDATA (decoded), SBYTES (decoded)); |
| 2294 | int c = unibyte_char_to_multibyte (*o++); | 2312 | x += SBYTES (decoded); |
| 2295 | x += CHAR_STRING (c, x); | 2313 | |
| 2296 | } | 2314 | /* If environment variable needed decoding, return value |
| 2315 | needs to be multibyte. */ | ||
| 2316 | if (decoded != orig) | ||
| 2317 | multibyte = 1; | ||
| 2297 | } | 2318 | } |
| 2319 | #if 0 | ||
| 2298 | else | 2320 | else |
| 2299 | { | 2321 | { |
| 2300 | strcpy (x, o); | 2322 | strcpy (x, o); |
| 2301 | x += strlen (o); | 2323 | x += strlen (o); |
| 2302 | } | 2324 | } |
| 2325 | #endif | ||
| 2303 | } | 2326 | } |
| 2304 | 2327 | ||
| 2305 | *x = 0; | 2328 | *x = 0; |
| @@ -2311,7 +2334,7 @@ duplicates what `expand-file-name' does. */) | |||
| 2311 | need to quote some $ to $$ first. */ | 2334 | need to quote some $ to $$ first. */ |
| 2312 | xnm = p; | 2335 | xnm = p; |
| 2313 | 2336 | ||
| 2314 | return make_specified_string (xnm, -1, x - xnm, STRING_MULTIBYTE (filename)); | 2337 | return make_specified_string (xnm, -1, x - xnm, multibyte); |
| 2315 | 2338 | ||
| 2316 | badsubst: | 2339 | badsubst: |
| 2317 | error ("Bad format environment-variable substitution"); | 2340 | error ("Bad format environment-variable substitution"); |