mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-03 08:30:09 +00:00
(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'.
This commit is contained in:
parent
6d75d6666b
commit
9d291bdfdf
46
src/dired.c
46
src/dired.c
@ -131,7 +131,7 @@ Lisp_Object
|
||||
directory_files_internal_unwind (dh)
|
||||
Lisp_Object dh;
|
||||
{
|
||||
DIR *d = (DIR *) ((XINT (XCAR (dh)) << 16) + XINT (XCDR (dh)));
|
||||
DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer;
|
||||
closedir (d);
|
||||
return Qnil;
|
||||
}
|
||||
@ -155,7 +155,6 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format)
|
||||
int count = SPECPDL_INDEX ();
|
||||
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
|
||||
DIRENTRY *dp;
|
||||
int retry_p;
|
||||
|
||||
/* Because of file name handlers, these functions might call
|
||||
Ffuncall, and cause a GC. */
|
||||
@ -189,12 +188,6 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format)
|
||||
/* Now *bufp is the compiled form of MATCH; don't call anything
|
||||
which might compile a new regexp until we're done with the loop! */
|
||||
|
||||
/* Do this opendir after anything which might signal an error; if
|
||||
an error is signaled while the directory stream is open, we
|
||||
have to make sure it gets closed, and setting up an
|
||||
unwind_protect to do so would be a pain. */
|
||||
retry:
|
||||
|
||||
d = opendir (SDATA (dirfilename));
|
||||
if (d == NULL)
|
||||
report_file_error ("Opening directory", Fcons (directory, Qnil));
|
||||
@ -203,8 +196,7 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format)
|
||||
file-attributes on filenames, both of which can throw, so we must
|
||||
do a proper unwind-protect. */
|
||||
record_unwind_protect (directory_files_internal_unwind,
|
||||
Fcons (make_number (((unsigned long) d) >> 16),
|
||||
make_number (((unsigned long) d) & 0xffff)));
|
||||
make_save_value (d, 0));
|
||||
|
||||
directory_nbytes = SBYTES (directory);
|
||||
re_match_object = Qt;
|
||||
@ -222,10 +214,15 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format)
|
||||
errno = 0;
|
||||
dp = readdir (d);
|
||||
|
||||
if (dp == NULL && (0
|
||||
#ifdef EAGAIN
|
||||
if (dp == NULL && errno == EAGAIN)
|
||||
continue;
|
||||
|| errno == EAGAIN
|
||||
#endif
|
||||
#ifdef EINTR
|
||||
|| errno == EINTR
|
||||
#endif
|
||||
))
|
||||
{ QUIT; continue; }
|
||||
|
||||
if (dp == NULL)
|
||||
break;
|
||||
@ -316,22 +313,11 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format)
|
||||
}
|
||||
}
|
||||
|
||||
retry_p = 0;
|
||||
#ifdef EINTR
|
||||
retry_p |= errno == EINTR;
|
||||
#endif
|
||||
|
||||
closedir (d);
|
||||
|
||||
/* Discard the unwind protect. */
|
||||
specpdl_ptr = specpdl + count;
|
||||
|
||||
if (retry_p)
|
||||
{
|
||||
list = Qnil;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
if (NILP (nosort))
|
||||
list = Fsort (Fnreverse (list),
|
||||
attrs ? Qfile_attributes_lessp : Qstring_lessp);
|
||||
@ -519,8 +505,7 @@ file_name_completion (file, dirname, all_flag, ver_flag)
|
||||
report_file_error ("Opening directory", Fcons (dirname, Qnil));
|
||||
|
||||
record_unwind_protect (directory_files_internal_unwind,
|
||||
Fcons (make_number (((unsigned long) d) >> 16),
|
||||
make_number (((unsigned long) d) & 0xffff)));
|
||||
make_save_value (d, 0));
|
||||
|
||||
/* Loop reading blocks */
|
||||
/* (att3b compiler bug requires do a null comparison this way) */
|
||||
@ -532,8 +517,19 @@ file_name_completion (file, dirname, all_flag, ver_flag)
|
||||
#ifdef VMS
|
||||
dp = (*readfunc) (d);
|
||||
#else
|
||||
errno = 0;
|
||||
dp = readdir (d);
|
||||
if (dp == NULL && (0
|
||||
# ifdef EAGAIN
|
||||
|| errno == EAGAIN
|
||||
# endif
|
||||
# ifdef EINTR
|
||||
|| errno == EINTR
|
||||
# endif
|
||||
))
|
||||
{ QUIT; continue; }
|
||||
#endif
|
||||
|
||||
if (!dp) break;
|
||||
|
||||
len = NAMLEN (dp);
|
||||
|
Loading…
Reference in New Issue
Block a user