diff options
| author | Stefan Monnier | 2005-09-02 18:42:54 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-09-02 18:42:54 +0000 |
| commit | 9d291bdfdfc8c1431628183cec604ba27c1cc05a (patch) | |
| tree | 37af9dfb5218bbab6dcee5fc383cbfeaad45fdda /src | |
| parent | 6d75d6666b8660f36f1200a32b59f794b88380cc (diff) | |
| download | emacs-9d291bdfdfc8c1431628183cec604ba27c1cc05a.tar.gz emacs-9d291bdfdfc8c1431628183cec604ba27c1cc05a.zip | |
(directory_files_internal_unwind, directory_files_internal)
(file_name_completion): Use a Save_Value object rather than a cons of
two 16bit ints to store the DIR*.
(directory_files_internal, file_name_completion): Handle both EINTR and
EAGAIN consistently after `readdir'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dired.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/dired.c b/src/dired.c index edf666d2a5f..927276e15c0 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -131,7 +131,7 @@ Lisp_Object | |||
| 131 | directory_files_internal_unwind (dh) | 131 | directory_files_internal_unwind (dh) |
| 132 | Lisp_Object dh; | 132 | Lisp_Object dh; |
| 133 | { | 133 | { |
| 134 | DIR *d = (DIR *) ((XINT (XCAR (dh)) << 16) + XINT (XCDR (dh))); | 134 | DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer; |
| 135 | closedir (d); | 135 | closedir (d); |
| 136 | return Qnil; | 136 | return Qnil; |
| 137 | } | 137 | } |
| @@ -155,7 +155,6 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) | |||
| 155 | int count = SPECPDL_INDEX (); | 155 | int count = SPECPDL_INDEX (); |
| 156 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 156 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 157 | DIRENTRY *dp; | 157 | DIRENTRY *dp; |
| 158 | int retry_p; | ||
| 159 | 158 | ||
| 160 | /* Because of file name handlers, these functions might call | 159 | /* Because of file name handlers, these functions might call |
| 161 | Ffuncall, and cause a GC. */ | 160 | Ffuncall, and cause a GC. */ |
| @@ -189,12 +188,6 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) | |||
| 189 | /* Now *bufp is the compiled form of MATCH; don't call anything | 188 | /* Now *bufp is the compiled form of MATCH; don't call anything |
| 190 | which might compile a new regexp until we're done with the loop! */ | 189 | which might compile a new regexp until we're done with the loop! */ |
| 191 | 190 | ||
| 192 | /* Do this opendir after anything which might signal an error; if | ||
| 193 | an error is signaled while the directory stream is open, we | ||
| 194 | have to make sure it gets closed, and setting up an | ||
| 195 | unwind_protect to do so would be a pain. */ | ||
| 196 | retry: | ||
| 197 | |||
| 198 | d = opendir (SDATA (dirfilename)); | 191 | d = opendir (SDATA (dirfilename)); |
| 199 | if (d == NULL) | 192 | if (d == NULL) |
| 200 | report_file_error ("Opening directory", Fcons (directory, Qnil)); | 193 | report_file_error ("Opening directory", Fcons (directory, Qnil)); |
| @@ -203,8 +196,7 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) | |||
| 203 | file-attributes on filenames, both of which can throw, so we must | 196 | file-attributes on filenames, both of which can throw, so we must |
| 204 | do a proper unwind-protect. */ | 197 | do a proper unwind-protect. */ |
| 205 | record_unwind_protect (directory_files_internal_unwind, | 198 | record_unwind_protect (directory_files_internal_unwind, |
| 206 | Fcons (make_number (((unsigned long) d) >> 16), | 199 | make_save_value (d, 0)); |
| 207 | make_number (((unsigned long) d) & 0xffff))); | ||
| 208 | 200 | ||
| 209 | directory_nbytes = SBYTES (directory); | 201 | directory_nbytes = SBYTES (directory); |
| 210 | re_match_object = Qt; | 202 | re_match_object = Qt; |
| @@ -222,10 +214,15 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) | |||
| 222 | errno = 0; | 214 | errno = 0; |
| 223 | dp = readdir (d); | 215 | dp = readdir (d); |
| 224 | 216 | ||
| 217 | if (dp == NULL && (0 | ||
| 225 | #ifdef EAGAIN | 218 | #ifdef EAGAIN |
| 226 | if (dp == NULL && errno == EAGAIN) | 219 | || errno == EAGAIN |
| 227 | continue; | 220 | #endif |
| 221 | #ifdef EINTR | ||
| 222 | || errno == EINTR | ||
| 228 | #endif | 223 | #endif |
| 224 | )) | ||
| 225 | { QUIT; continue; } | ||
| 229 | 226 | ||
| 230 | if (dp == NULL) | 227 | if (dp == NULL) |
| 231 | break; | 228 | break; |
| @@ -316,22 +313,11 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) | |||
| 316 | } | 313 | } |
| 317 | } | 314 | } |
| 318 | 315 | ||
| 319 | retry_p = 0; | ||
| 320 | #ifdef EINTR | ||
| 321 | retry_p |= errno == EINTR; | ||
| 322 | #endif | ||
| 323 | |||
| 324 | closedir (d); | 316 | closedir (d); |
| 325 | 317 | ||
| 326 | /* Discard the unwind protect. */ | 318 | /* Discard the unwind protect. */ |
| 327 | specpdl_ptr = specpdl + count; | 319 | specpdl_ptr = specpdl + count; |
| 328 | 320 | ||
| 329 | if (retry_p) | ||
| 330 | { | ||
| 331 | list = Qnil; | ||
| 332 | goto retry; | ||
| 333 | } | ||
| 334 | |||
| 335 | if (NILP (nosort)) | 321 | if (NILP (nosort)) |
| 336 | list = Fsort (Fnreverse (list), | 322 | list = Fsort (Fnreverse (list), |
| 337 | attrs ? Qfile_attributes_lessp : Qstring_lessp); | 323 | attrs ? Qfile_attributes_lessp : Qstring_lessp); |
| @@ -519,8 +505,7 @@ file_name_completion (file, dirname, all_flag, ver_flag) | |||
| 519 | report_file_error ("Opening directory", Fcons (dirname, Qnil)); | 505 | report_file_error ("Opening directory", Fcons (dirname, Qnil)); |
| 520 | 506 | ||
| 521 | record_unwind_protect (directory_files_internal_unwind, | 507 | record_unwind_protect (directory_files_internal_unwind, |
| 522 | Fcons (make_number (((unsigned long) d) >> 16), | 508 | make_save_value (d, 0)); |
| 523 | make_number (((unsigned long) d) & 0xffff))); | ||
| 524 | 509 | ||
| 525 | /* Loop reading blocks */ | 510 | /* Loop reading blocks */ |
| 526 | /* (att3b compiler bug requires do a null comparison this way) */ | 511 | /* (att3b compiler bug requires do a null comparison this way) */ |
| @@ -532,8 +517,19 @@ file_name_completion (file, dirname, all_flag, ver_flag) | |||
| 532 | #ifdef VMS | 517 | #ifdef VMS |
| 533 | dp = (*readfunc) (d); | 518 | dp = (*readfunc) (d); |
| 534 | #else | 519 | #else |
| 520 | errno = 0; | ||
| 535 | dp = readdir (d); | 521 | dp = readdir (d); |
| 522 | if (dp == NULL && (0 | ||
| 523 | # ifdef EAGAIN | ||
| 524 | || errno == EAGAIN | ||
| 525 | # endif | ||
| 526 | # ifdef EINTR | ||
| 527 | || errno == EINTR | ||
| 528 | # endif | ||
| 529 | )) | ||
| 530 | { QUIT; continue; } | ||
| 536 | #endif | 531 | #endif |
| 532 | |||
| 537 | if (!dp) break; | 533 | if (!dp) break; |
| 538 | 534 | ||
| 539 | len = NAMLEN (dp); | 535 | len = NAMLEN (dp); |