# HG changeset patch # User John W. Eaton # Date 1325865071 18000 # Node ID 583d3d6f6fde4ec7f8435b7134966d3f51a020ab # Parent f15007a6c6428b9513a3d4b924db7af83c9a8d3a 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. diff -r f15007a6c642 -r 583d3d6f6fde build-aux/bootstrap.conf --- 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 diff -r f15007a6c642 -r 583d3d6f6fde liboctave/dir-ops.cc --- 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)))) + while ((dir_ent = gnulib::readdir (static_cast (dir)))) { if (dir_ent) dirlist.push_back (dir_ent->d_name); diff -r f15007a6c642 -r 583d3d6f6fde liboctave/kpse.cc --- 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.) */ diff -r f15007a6c642 -r 583d3d6f6fde liboctave/lo-sysdep.cc --- 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 (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 diff -r f15007a6c642 -r 583d3d6f6fde liboctave/lo-sysdep.h --- 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