Message-ID: <002801c298db$08c76420$0100a8c0@p4> From: "Andrew Cottrell" To: Cc: "Tim Van Holder" , "Eli Zaretskii" 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 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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); }