mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 20:32:00 -08:00
Simplify read_dirent's MSDOS hacks
* dired.c (read_dirent): Simplify by removing the need for the DIR_ENTRY argument. All callers changed. This separates the MS-DOS idiosyncrasies better from the rest of the code.
This commit is contained in:
parent
e0be229d5f
commit
512cdb9f2b
2 changed files with 15 additions and 13 deletions
|
|
@ -1,3 +1,10 @@
|
|||
2015-01-31 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Simplify read_dirent's MSDOS hacks
|
||||
* dired.c (read_dirent): Simplify by removing the need for the
|
||||
DIR_ENTRY argument. All callers changed. This separates the
|
||||
MS-DOS idiosyncrasies better from the rest of the code.
|
||||
|
||||
2015-01-30 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* dired.c (read_dirent): Accept an additional argument
|
||||
|
|
|
|||
21
src/dired.c
21
src/dired.c
|
|
@ -124,11 +124,10 @@ directory_files_internal_unwind (void *dh)
|
|||
|
||||
/* Return the next directory entry from DIR; DIR's name is DIRNAME.
|
||||
If there are no more directory entries, return a null pointer.
|
||||
Signal any unrecoverable errors. FIRST_ENTRY true means this is
|
||||
the first call after open_directory. */
|
||||
Signal any unrecoverable errors. */
|
||||
|
||||
static struct dirent *
|
||||
read_dirent (DIR *dir, Lisp_Object dirname, bool first_entry)
|
||||
read_dirent (DIR *dir, Lisp_Object dirname)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -138,14 +137,15 @@ read_dirent (DIR *dir, Lisp_Object dirname, bool first_entry)
|
|||
return dp;
|
||||
if (! (errno == EAGAIN || errno == EINTR))
|
||||
{
|
||||
#ifdef MSDOS
|
||||
/* The MS-Windows implementation of 'opendir' doesn't
|
||||
actually open a directory until the first call to
|
||||
'readdir'. If 'readdir' fails to open the directory, it
|
||||
sets errno to ENOENT or EACCES, see w32.c. */
|
||||
if (first_entry && (errno == ENOENT || errno == EACCES))
|
||||
if (errno == ENOENT || errno == EACCES)
|
||||
report_file_error ("Opening directory", dirname);
|
||||
else
|
||||
report_file_error ("Reading directory", dirname);
|
||||
#endif
|
||||
report_file_error ("Reading directory", dirname);
|
||||
}
|
||||
QUIT;
|
||||
}
|
||||
|
|
@ -249,8 +249,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
|
|||
needsep = 1;
|
||||
|
||||
/* Loop reading directory entries. */
|
||||
bool first_entry = true;
|
||||
for (struct dirent *dp; (dp = read_dirent (d, directory, first_entry)); )
|
||||
for (struct dirent *dp; (dp = read_dirent (d, directory)); )
|
||||
{
|
||||
ptrdiff_t len = dirent_namelen (dp);
|
||||
Lisp_Object name = make_unibyte_string (dp->d_name, len);
|
||||
|
|
@ -258,8 +257,6 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
|
|||
struct gcpro gcpro1, gcpro2;
|
||||
GCPRO2 (finalname, name);
|
||||
|
||||
first_entry = false;
|
||||
|
||||
/* Note: DECODE_FILE can GC; it should protect its argument,
|
||||
though. */
|
||||
name = DECODE_FILE (name);
|
||||
|
|
@ -499,13 +496,11 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
|
|||
record_unwind_protect_ptr (directory_files_internal_unwind, d);
|
||||
|
||||
/* Loop reading directory entries. */
|
||||
bool first_entry = true;
|
||||
for (struct dirent *dp; (dp = read_dirent (d, dirname, first_entry)); )
|
||||
for (struct dirent *dp; (dp = read_dirent (d, dirname)); )
|
||||
{
|
||||
ptrdiff_t len = dirent_namelen (dp);
|
||||
bool canexclude = 0;
|
||||
|
||||
first_entry = false;
|
||||
QUIT;
|
||||
if (len < SCHARS (encoded_file)
|
||||
|| (scmp (dp->d_name, SSDATA (encoded_file),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue