diff options
| -rw-r--r-- | src/fileio.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/fileio.c b/src/fileio.c index cc1c7a5a33d..2b9d87d54df 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -336,7 +336,8 @@ use the standard functions without calling themselves recursively. */) | |||
| 336 | Lisp_Object filename, operation; | 336 | Lisp_Object filename, operation; |
| 337 | { | 337 | { |
| 338 | /* This function must not munge the match data. */ | 338 | /* This function must not munge the match data. */ |
| 339 | Lisp_Object chain, inhibited_handlers; | 339 | Lisp_Object chain, inhibited_handlers, result = Qnil; |
| 340 | int pos = -1; | ||
| 340 | 341 | ||
| 341 | CHECK_STRING (filename); | 342 | CHECK_STRING (filename); |
| 342 | 343 | ||
| @@ -353,21 +354,26 @@ use the standard functions without calling themselves recursively. */) | |||
| 353 | if (CONSP (elt)) | 354 | if (CONSP (elt)) |
| 354 | { | 355 | { |
| 355 | Lisp_Object string; | 356 | Lisp_Object string; |
| 357 | int match_pos; | ||
| 356 | string = XCAR (elt); | 358 | string = XCAR (elt); |
| 357 | if (STRINGP (string) && fast_string_match (string, filename) >= 0) | 359 | if (STRINGP (string) |
| 360 | && (match_pos = fast_string_match (string, filename)) > pos) | ||
| 358 | { | 361 | { |
| 359 | Lisp_Object handler, tem; | 362 | Lisp_Object handler, tem; |
| 360 | 363 | ||
| 361 | handler = XCDR (elt); | 364 | handler = XCDR (elt); |
| 362 | tem = Fmemq (handler, inhibited_handlers); | 365 | tem = Fmemq (handler, inhibited_handlers); |
| 363 | if (NILP (tem)) | 366 | if (NILP (tem)) |
| 364 | return handler; | 367 | { |
| 368 | result = handler; | ||
| 369 | pos = match_pos; | ||
| 370 | } | ||
| 365 | } | 371 | } |
| 366 | } | 372 | } |
| 367 | 373 | ||
| 368 | QUIT; | 374 | QUIT; |
| 369 | } | 375 | } |
| 370 | return Qnil; | 376 | return result; |
| 371 | } | 377 | } |
| 372 | 378 | ||
| 373 | DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, | 379 | DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, |
| @@ -2101,9 +2107,13 @@ duplicates what `expand-file-name' does. */) | |||
| 2101 | 2107 | ||
| 2102 | /* Get variable value */ | 2108 | /* Get variable value */ |
| 2103 | o = (unsigned char *) egetenv (target); | 2109 | o = (unsigned char *) egetenv (target); |
| 2104 | if (!o) goto badvar; | 2110 | if (o) |
| 2105 | total += strlen (o); | 2111 | { |
| 2106 | substituted = 1; | 2112 | total += strlen (o); |
| 2113 | substituted = 1; | ||
| 2114 | } | ||
| 2115 | else if (*p == '}') | ||
| 2116 | goto badvar; | ||
| 2107 | } | 2117 | } |
| 2108 | 2118 | ||
| 2109 | if (!substituted) | 2119 | if (!substituted) |
| @@ -2153,9 +2163,11 @@ duplicates what `expand-file-name' does. */) | |||
| 2153 | /* Get variable value */ | 2163 | /* Get variable value */ |
| 2154 | o = (unsigned char *) egetenv (target); | 2164 | o = (unsigned char *) egetenv (target); |
| 2155 | if (!o) | 2165 | if (!o) |
| 2156 | goto badvar; | 2166 | { |
| 2157 | 2167 | *x++ = '$'; | |
| 2158 | if (STRING_MULTIBYTE (filename)) | 2168 | strcpy (x, target); x+= strlen (target); |
| 2169 | } | ||
| 2170 | else if (STRING_MULTIBYTE (filename)) | ||
| 2159 | { | 2171 | { |
| 2160 | /* If the original string is multibyte, | 2172 | /* If the original string is multibyte, |
| 2161 | convert what we substitute into multibyte. */ | 2173 | convert what we substitute into multibyte. */ |