bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep -- recursion on Cygwin fix


From: Charles Lane
Subject: grep -- recursion on Cygwin fix
Date: Wed, 11 Apr 2001 11:20:15 EDT

Here's the problem:

bash> grep -r * -e stuff

reports "permission" errors on directory files, and does not recurse, when
used under Cygwin...this has been reported on the Cygwin message boards, but
not fixed AFAIK.

Here's a patch to grep 2.4.2 that fixes the recursion...simply put, the
"access" function doesn't work on Cygwin, but "stat" seems to be fine.
Perhaps "stat" is the more portable solution?

--- src/system.h-orig   Wed Apr 11 10:50:54 2001
+++ src/system.h        Wed Apr 11 10:52:40 2001
@@ -91,14 +91,6 @@
 # endif
 #endif
 
-#ifndef is_EISDIR
-# ifdef EISDIR
-#  define is_EISDIR(e, f) ((e) == EISDIR)
-# else
-#  define is_EISDIR(e, f) 0
-# endif
-#endif
-
 #if STAT_MACROS_BROKEN
 # undef S_ISDIR
 # undef S_ISREG
@@ -108,6 +100,16 @@
 #endif
 #if !defined(S_ISREG) && defined(S_IFREG)
 # define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
+#endif
+
+#ifndef is_EISDIR
+static int is_EISDIR(int e, char const *f)
+{
+  struct stat st;
+  if (e == EISDIR) return 1;
+  if (stat(f,&st) < 0) return 0;
+  return S_ISDIR(st.st_mode);
+}
 #endif
 
 #ifdef STDC_HEADERS
--
 Drexel University       \V                    --Chuck Lane
======]---------->--------*------------<-------[===========
     (215) 895-1545     _/ \  Particle Physics
FAX: (215) 895-5934     /\ /~~~~~~~~~~~        address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]