www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/11/30/20:43:43

Message-ID: <002801c298db$08c76420$0100a8c0@p4>
From: "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>
To: <djgpp-workers AT delorie DOT com>
Cc: "Tim Van Holder" <tim DOT van DOT holder AT pandora DOT be>,
"Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
References: <006501c295e3$05898a90$0100a8c0 AT p4> <1038385704 DOT 25980 DOT 6 DOT camel AT leeloo>
Subject: Grep 2.5.1 directory bug
Date: Sun, 1 Dec 2002 12:42:31 +1100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1123
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1123
Reply-To: djgpp-workers AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019