Mail Archives: djgpp-workers/2002/11/30/20:43:43
I have investigated why Grep 2.5.1 reads directories and traced the problem
down to a change in the src\system.h header for the EISDIR macro. The
following is the change that I made to get it to not read directory names. I
have made the change only applicable for DJGPP.
Does anyone have any problems with this change?
New code:
#if defined(HAVE_DIR_EACCES_BUG) || defined(DJGPP)
# ifdef EISDIR
# define is_EISDIR(e, f) \
((e) == EISDIR \
|| ((e) == EACCES && isdir (f) && ((e) = EISDIR, 1)))
# else
# define is_EISDIR(e, f) ((e) == EACCES && isdir (f))
# endif
#endif
Old code:
#ifdef HAVE_DIR_EACCES_BUG
# ifdef EISDIR
Old Grep 2.4 code:
/* This assumes _WIN32, like DJGPP, has D_OK. Does it? In what header? */
#ifdef D_OK
# ifdef EISDIR
# define is_EISDIR(e, f) \
((e) == EISDIR \
|| ((e) == EACCES && access (f, D_OK) == 0 && ((e) = EISDIR, 1)))
# else
# define is_EISDIR(e, f) ((e) == EACCES && access (f, D_OK) == 0)
# endif
#endif
Notes on the changes:
1) I greped all of the grep 2.5.1 source and could not find any references
to HAVE_DIR_EACCES_BUG.
2) The isdir() is a new for 2.5.1 and consists of the following :-
int isdir (const char *path)
{
struct stat stats;
return stat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
}
- Raw text -