Mercurial > emacs
comparison src/dired.c @ 22916:596fa4fbae13
(Fdirectory_files): If MATCH is non-nil, decode filenames
before checking them against MATCH.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 06 Aug 1998 05:38:11 +0000 |
parents | fa9ff387d260 |
children | d968067e4580 |
comparison
equal
deleted
inserted
replaced
22915:ef9dd93e3077 | 22916:596fa4fbae13 |
---|---|
185 d = opendir (XSTRING (dirfilename)->data); | 185 d = opendir (XSTRING (dirfilename)->data); |
186 if (! d) | 186 if (! d) |
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 |
200 GCPRO2 (encoded_directory, list); | 200 GCPRO2 (encoded_directory, list); |
201 | 201 |
202 /* Loop reading blocks */ | 202 /* Loop reading blocks */ |
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; |
220 | 224 Lisp_Object fullname; |
221 name = make_uninit_multibyte_string (total + needsep, | 225 |
222 total + needsep); | 226 fullname = make_uninit_multibyte_string (total + needsep, |
223 bcopy (XSTRING (encoded_directory)->data, XSTRING (name)->data, | 227 total + needsep); |
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 } |
241 } | 244 } |
242 closedir (d); | 245 closedir (d); |