diff options
| author | Kenichi Handa | 1998-08-06 05:38:11 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-08-06 05:38:11 +0000 |
| commit | e23f810c3eae579db8b75d33dcffc75be54d1fc7 (patch) | |
| tree | 8a66fbb8677d265e120eb8e8edb3d2261f7a25ff /src/dired.c | |
| parent | d86ad277e5236fd51646bcb2a88626f9c3b89eb7 (diff) | |
| download | emacs-e23f810c3eae579db8b75d33dcffc75be54d1fc7.tar.gz emacs-e23f810c3eae579db8b75d33dcffc75be54d1fc7.zip | |
(Fdirectory_files): If MATCH is non-nil, decode filenames
before checking them against MATCH.
Diffstat (limited to 'src/dired.c')
| -rw-r--r-- | src/dired.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/dired.c b/src/dired.c index 2e72c4706de..eb743c58a3b 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -187,13 +187,13 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 187 | report_file_error ("Opening directory", Fcons (directory, Qnil)); | 187 | report_file_error ("Opening directory", Fcons (directory, Qnil)); |
| 188 | 188 | ||
| 189 | list = Qnil; | 189 | list = Qnil; |
| 190 | dirnamelen = STRING_BYTES (XSTRING (encoded_directory)); | 190 | dirnamelen = STRING_BYTES (XSTRING (directory)); |
| 191 | re_match_object = Qt; | 191 | re_match_object = Qt; |
| 192 | 192 | ||
| 193 | /* Decide whether we need to add a directory separator. */ | 193 | /* Decide whether we need to add a directory separator. */ |
| 194 | #ifndef VMS | 194 | #ifndef VMS |
| 195 | if (dirnamelen == 0 | 195 | if (dirnamelen == 0 |
| 196 | || !IS_ANY_SEP (XSTRING (encoded_directory)->data[dirnamelen - 1])) | 196 | || !IS_ANY_SEP (XSTRING (directory)->data[dirnamelen - 1])) |
| 197 | needsep = 1; | 197 | needsep = 1; |
| 198 | #endif /* not VMS */ | 198 | #endif /* not VMS */ |
| 199 | 199 | ||
| @@ -203,38 +203,41 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.\n\ | |||
| 203 | while (1) | 203 | while (1) |
| 204 | { | 204 | { |
| 205 | DIRENTRY *dp = readdir (d); | 205 | DIRENTRY *dp = readdir (d); |
| 206 | int len; | ||
| 207 | 206 | ||
| 208 | if (!dp) break; | 207 | if (!dp) break; |
| 209 | len = NAMLEN (dp); | ||
| 210 | if (DIRENTRY_NONEMPTY (dp)) | 208 | if (DIRENTRY_NONEMPTY (dp)) |
| 211 | { | 209 | { |
| 210 | int len; | ||
| 211 | |||
| 212 | len = NAMLEN (dp); | ||
| 213 | name = DECODE_FILE (make_string (dp->d_name, len)); | ||
| 214 | len = STRING_BYTES (XSTRING (name)); | ||
| 215 | |||
| 212 | if (NILP (match) | 216 | if (NILP (match) |
| 213 | || (0 <= re_search (bufp, dp->d_name, len, 0, len, 0))) | 217 | || (0 <= re_search (bufp, XSTRING (name)->data, len, 0, len, 0))) |
| 214 | { | 218 | { |
| 215 | if (!NILP (full)) | 219 | if (!NILP (full)) |
| 216 | { | 220 | { |
| 217 | int afterdirindex = dirnamelen; | 221 | int afterdirindex = dirnamelen; |
| 218 | int total = len + dirnamelen; | 222 | int total = len + dirnamelen; |
| 219 | int nchars; | 223 | int nchars; |
| 224 | Lisp_Object fullname; | ||
| 220 | 225 | ||
| 221 | name = make_uninit_multibyte_string (total + needsep, | 226 | fullname = make_uninit_multibyte_string (total + needsep, |
| 222 | total + needsep); | 227 | total + needsep); |
| 223 | bcopy (XSTRING (encoded_directory)->data, XSTRING (name)->data, | 228 | bcopy (XSTRING (directory)->data, XSTRING (fullname)->data, |
| 224 | dirnamelen); | 229 | dirnamelen); |
| 225 | if (needsep) | 230 | if (needsep) |
| 226 | XSTRING (name)->data[afterdirindex++] = DIRECTORY_SEP; | 231 | XSTRING (fullname)->data[afterdirindex++] = DIRECTORY_SEP; |
| 227 | bcopy (dp->d_name, | 232 | bcopy (XSTRING (name)->data, |
| 228 | XSTRING (name)->data + afterdirindex, len); | 233 | XSTRING (fullname)->data + afterdirindex, len); |
| 229 | nchars = chars_in_text (XSTRING (name)->data, | 234 | nchars = chars_in_text (XSTRING (fullname)->data, |
| 230 | afterdirindex + len); | 235 | afterdirindex + len); |
| 231 | XSTRING (name)->size = nchars; | 236 | XSTRING (fullname)->size = nchars; |
| 232 | if (nchars == STRING_BYTES (XSTRING (name))) | 237 | if (nchars == STRING_BYTES (XSTRING (fullname))) |
| 233 | SET_STRING_BYTES (XSTRING (name), -1); | 238 | SET_STRING_BYTES (XSTRING (fullname), -1); |
| 239 | name = fullname; | ||
| 234 | } | 240 | } |
| 235 | else | ||
| 236 | name = make_string (dp->d_name, len); | ||
| 237 | name = DECODE_FILE (name); | ||
| 238 | list = Fcons (name, list); | 241 | list = Fcons (name, list); |
| 239 | } | 242 | } |
| 240 | } | 243 | } |