]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Sat, 8 Feb 2003 18:29:49 +0000 (18:29 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 8 Feb 2003 18:29:49 +0000 (18:29 +0000)
2003-02-08  Ulrich Drepper  <drepper@redhat.com>

* io/ftwtest.c: Get current working directory before and after the
nftw call and make sure they match.

2003-02-08  Jim Meyering  <jim@meyering.net>

* ftw.c (ftw_startup): When using FTW_CHDIR, always remember
the current directory, not just when DIR contains a slash.
Reported by Manoj Srivastava.

ChangeLog
io/ftw.c
io/ftwtest.c

index 183e5f95f602a31841a6a0a51603f04e69e2a454..d41458ad19c32476b237ab7c075b4e262f163036 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-02-08  Ulrich Drepper  <drepper@redhat.com>
+
+       * io/ftwtest.c: Get current working directory before and after the
+       nftw call and make sure they match.
+
+2003-02-08  Jim Meyering  <jim@meyering.net>
+
+       * ftw.c (ftw_startup): When using FTW_CHDIR, always remember
+       the current directory, not just when DIR contains a slash.
+       Reported by Manoj Srivastava.
+
 2003-02-07  Jim Meyering  <jim@meyering.net>
 
        * io/ftw.c: Add autoconf-recommended block of alloca-related code.
index 227f3f3b52c7bb334047804cdce02f707dbfb152..3d2d940cd884fa2911792f09c50d4d8bfcff35f3 100644 (file)
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -629,13 +629,13 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
   data.known_objects = NULL;
 
   /* Now go to the directory containing the initial file/directory.  */
-  if ((flags & FTW_CHDIR) && data.ftw.base > 0)
+  if (flags & FTW_CHDIR)
     {
       /* GNU extension ahead.  */
       cwd =  __getcwd (NULL, 0);
       if (cwd == NULL)
        result = -1;
-      else
+      else if (data.ftw.base > 0)
        {
          /* Change to the directory the file is in.  In data.dirbuf
             we have a writable copy of the file name.  Just NUL
index 851ed1d5870ef462f7ed5645a3662a8a81a78f6d..4f527997df1db2bdbe8e9d04b9a0e8468fe2fb6a 100644 (file)
@@ -70,9 +70,22 @@ main (int argc, char *argv[])
   if (do_phys)
     flag |= FTW_PHYS;
 
+  char *cw1 = getcwd (NULL, 0);
+
   r = nftw (optind < argc ? argv[optind] : ".", cb, do_exit ? 1 : 3, flag);
   if (r < 0)
     perror ("nftw");
+
+  char *cw2 = getcwd (NULL, 0);
+
+  if (strcmp (cw1, cw2) != 0)
+    {
+      printf ("current working directory before and after nftw call differ:\n"
+             "before: %s\n"
+             "after:  %s\n", cw1, cw2);
+      exit (1);
+    }
+
   if (do_exit)
     {
       puts (r == 26 ? "succeeded" : "failed");