changeset 14155:583d3d6f6fde stable

use gnulib::readdir * build-aux/bootstrap.conf (gnulib_modules): Include readdir and rewinddir in the list. * lo-sysdep.h, lo-sysdep.cc (struct __DIR, opendir, rewinddir, closedir, readdir): Delete declarations and functions. * dir-ops.cc (dir_entry::read): Use gnulib::readdir. * kpse.cc (do_subdir): Likewise.
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2012 10:51:11 -0500
parents f15007a6c642
children d5d3037cbc11
files build-aux/bootstrap.conf liboctave/dir-ops.cc liboctave/kpse.cc liboctave/lo-sysdep.cc liboctave/lo-sysdep.h
diffstat 5 files changed, 4 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/bootstrap.conf	Fri Jan 06 10:25:00 2012 -0500
+++ b/build-aux/bootstrap.conf	Fri Jan 06 10:51:11 2012 -0500
@@ -48,8 +48,10 @@
   opendir
   pathmax
   progname
+  readdir
   readlink
   rename
+  rewinddir
   rmdir
   round
   roundf
--- a/liboctave/dir-ops.cc	Fri Jan 06 10:25:00 2012 -0500
+++ b/liboctave/dir-ops.cc	Fri Jan 06 10:51:11 2012 -0500
@@ -77,7 +77,7 @@
 
       struct dirent *dir_ent;
 
-      while ((dir_ent = readdir (static_cast<DIR *> (dir))))
+      while ((dir_ent = gnulib::readdir (static_cast<DIR *> (dir))))
         {
           if (dir_ent)
             dirlist.push_back (dir_ent->d_name);
--- a/liboctave/kpse.cc	Fri Jan 06 10:25:00 2012 -0500
+++ b/liboctave/kpse.cc	Fri Jan 06 10:51:11 2012 -0500
@@ -2282,7 +2282,7 @@
       name.resize (elt_length);
     }
 
-  while ((e = readdir (dir)))
+  while ((e = gnulib::readdir (dir)))
     {
       /* If it begins with a `.', never mind.  (This allows ``hidden''
          directories that the algorithm won't find.)  */
--- a/liboctave/lo-sysdep.cc	Fri Jan 06 10:25:00 2012 -0500
+++ b/liboctave/lo-sysdep.cc	Fri Jan 06 10:51:11 2012 -0500
@@ -141,73 +141,3 @@
 }
 
 #endif
-
-#if defined (_MSC_VER) && ! defined (HAVE_DIRENT_H)
-
-// FIXME -- it would probably be better to adapt the versions of
-// opendir, readdir, and closedir from Emacs as they appear to be more
-// complete implementations (do the functions below work for network
-// paths, for example)?  We can probably get along without rewinddir.
-
-struct __DIR
-{
-  HANDLE hnd;
-  WIN32_FIND_DATA fd;
-  int dirty;
-  struct direct d;
-  const char *current;
-};
-
-DIR *
-opendir (const char *name)
-{
-  DIR *d = static_cast<DIR *> (malloc (sizeof (DIR)));
-  static char buffer[MAX_PATH];
-
-  strncpy (buffer, name, MAX_PATH);
-  if (buffer[strnlen(buffer, MAX_PATH)-1] != '\\')
-    strncat (buffer, "\\*", MAX_PATH);
-  else
-    strncat (buffer, "*", MAX_PATH);
-  d->current = buffer;
-  d->hnd = FindFirstFile (buffer, &(d->fd));
-  if (d->hnd == INVALID_HANDLE_VALUE)
-    {
-      free (d);
-      return 0;
-    }
-  d->dirty = 1;
-  return d;
-}
-
-void
-rewinddir (DIR *d)
-{
-  if (d->hnd != INVALID_HANDLE_VALUE)
-    FindClose (d->hnd);
-  d->hnd = FindFirstFile (d->current, &(d->fd));
-  d->dirty = 1;
-}
-
-void
-closedir (DIR *d)
-{
-  if (d->hnd != INVALID_HANDLE_VALUE)
-    FindClose (d->hnd);
-  free (d);
-}
-
-struct direct *
-readdir (DIR *d)
-{
-  if (! d->dirty)
-    {
-      if (! FindNextFile(d->hnd, &(d->fd)))
-        return 0;
-    }
-  d->d.d_name = d->fd.cFileName;
-  d->dirty = 0;
-  return &(d->d);
-}
-
-#endif
--- a/liboctave/lo-sysdep.h	Fri Jan 06 10:25:00 2012 -0500
+++ b/liboctave/lo-sysdep.h	Fri Jan 06 10:51:11 2012 -0500
@@ -37,25 +37,4 @@
     bool, int *, std::string&);
 #endif
 
-#if defined (_MSC_VER) && ! defined (HAVE_DIRENT_H)
-
-// FIXME -- it would probably be better to adapt the versions of
-// opendir, readdir, and closedir from Emacs as they appear to be more
-// complete implementations.  We can probably get along without
-// rewinddir.
-
-struct direct
-{
-  char *d_name;
-};
-
-typedef struct __DIR DIR;
-
-extern DIR* opendir (const char *name);
-extern void rewinddir (DIR *d);
-extern void closedir (DIR *d);
-extern struct direct *readdir (DIR *d);
-
 #endif
-
-#endif