echo yes;AC_DEFINE(HAVE_UTIMBUF),
echo no)
+echo $ac_n "checking for broken readdir ... $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 no)
+
AC_OUTPUT(Makefile lib/dummy)
}
for (di=readdir(d); di; di=readdir(d)) {
- if (strcmp(di->d_name,".")==0 ||
- strcmp(di->d_name,"..")==0)
+ char *dname = d_name(di);
+ if (strcmp(dname,".")==0 ||
+ strcmp(dname,"..")==0)
continue;
- strncpy(p,di->d_name,MAXPATHLEN-(l+1));
+ strncpy(p,dname,MAXPATHLEN-(l+1));
send_file_name(f,flist,fname,recurse,FLAG_DELETE);
}
}
for (di=readdir(d); di; di=readdir(d)) {
- if (strcmp(di->d_name,".")==0 ||
- strcmp(di->d_name,"..")==0)
+ char *dname = d_name(di);
+ if (strcmp(dname,".")==0 ||
+ strcmp(dname,"..")==0)
continue;
- strncpy(buf, fname, (MAXPATHLEN-strlen(di->d_name))-2);
+ strncpy(buf, fname, (MAXPATHLEN-strlen(dname))-2);
strcat(buf, "/");
- strcat(buf, di->d_name);
+ strcat(buf, dname);
buf[MAXPATHLEN-1] = 0;
if (verbose > 0)
fprintf(FINFO,"deleting %s\n", buf);
return i;
}
+#if HAVE_DIRENT_H
+# include <dirent.h>
+#else
+# define dirent direct
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
#include "byteorder.h"
#include "version.h"
# define strrchr rindex
#endif
-#if HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# define dirent direct
-# if HAVE_SYS_NDIR_H
-# include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-# include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-# include <ndir.h>
-# endif
-#endif
-
#ifndef HAVE_ERRNO_DECL
extern int errno;
#endif
return lseek(fd, offset, whence);
#endif
}
+
+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
+ return di->d_name;
+}