fts: fts_open: do not let an empty string cause immediate failure
authorJim Meyering <meyering@redhat.com>
Tue, 1 Dec 2009 11:06:34 +0000 (12:06 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 1 Dec 2009 13:09:25 +0000 (14:09 +0100)
This is required in support of GNU rm, for which the command
"rm A '' B" must process and remove both A and B, in spite of
the empty string argument.
* lib/fts.c (fts_open): Do not let the presence of an empty string
cause fts_open to fail immediately.  Most fts-using tools must be
able to process all arguments, in order, and can be expected to
diagnose such arguments themselves.
Also, move declaration of local, "len", "down" to initialization.

ChangeLog
lib/fts.c

index 07918de20481a2d6e794d3297858e4417fac867c..6eec830ec368ab78e5b08b8c23c487b05471f7f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-12-01  Jim Meyering  <meyering@redhat.com>
+
+       fts: fts_open: do not let an empty string cause immediate failure
+       This is required in support of GNU rm, for which the command
+       "rm A '' B" must process and remove both A and B, in spite of
+       the empty string argument.
+       * lib/fts.c (fts_open): Do not let the presence of an empty string
+       cause fts_open to fail immediately.  Most fts-using tools must be
+       able to process all arguments, in order, and can be expected to
+       diagnose such arguments themselves.
+
 2009-11-30  Eric Blake  <ebb9@byu.net>
 
        utimens: fix compilation error
index 21c66583ac48c9b2e0a2b5863fe67bfb3fde5378..39922b6a43d95208b7c10767552cdc61b31763dc 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -375,7 +375,6 @@ fts_open (char * const *argv,
        register size_t nitems;
        FTSENT *parent = NULL;
        FTSENT *tmp = NULL;     /* pacify gcc */
-       size_t len;
        bool defer_stat;
 
        /* Options check. */
@@ -474,12 +473,8 @@ fts_open (char * const *argv,
 
        /* Allocate/initialize root(s). */
        for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
-               /* Don't allow zero-length file names. */
-               if ((len = strlen(*argv)) == 0) {
-                       __set_errno (ENOENT);
-                       goto mem3;
-               }
-
+               /* *Do* allow zero-length file names. */
+               size_t len = strlen(*argv);
                if ((p = fts_alloc(sp, *argv, len)) == NULL)
                        goto mem3;
                p->fts_level = FTS_ROOTLEVEL;