better test for solaris broken readdir
authorAndrew Tridgell <tridge@samba.org>
Wed, 6 May 1998 07:18:06 +0000 (07:18 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 6 May 1998 07:18:06 +0000 (07:18 +0000)
configure.in
syscall.c

index f740073..14d8056 100644 (file)
@@ -69,14 +69,16 @@ main() { char c; c=250; exit((c > 0)?0:1); }],
 echo yes;AC_DEFINE(HAVE_UNSIGNED_CHAR), 
 echo no)
 
-echo $ac_n "checking for utimbuf ... $ac_c"
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <utime.h>],
-[struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);],
-echo yes;AC_DEFINE(HAVE_UTIMBUF), 
+echo $ac_n "checking for broken readdir ... $ac_c"
+AC_TRY_RUN([#include <sys/types.h>
+#include <dirent.h>
+main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
+if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
+di->d_name[0] == 0) return 0; return 1;} ],
+echo yes;AC_DEFINE(HAVE_BROKEN_READDIR), 
 echo no)
 
-echo $ac_n "checking for broken readdir ... $ac_c"
+echo $ac_n "checking for utimbuf ... $ac_c"
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <utime.h>],
 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);],
index 5bf3e47..96b42b6 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -136,18 +136,9 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
 
 char *d_name(struct dirent *di)
 {
-#if defined(SunOS) && SunOS >= 50
-       static int first = 1;
-       static int broken;
-       if (first) {
-               first = 0;
-               if (!di->d_name[0] && strcmp(".", di->d_name-2)==0) {
-                       fprintf(stderr,"WARNING: broken readdir\n");
-                       broken = 1;
-               }
-       }
-       if (broken)
-               return (di->d_name - 2);
-#endif
+#if HAVE_BROKEN_READDIR
+       return (di->d_name - 2);
+#else
        return di->d_name;
+#endif
 }