[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bugs in dirname module - findutils portion
From: |
Eric Blake |
Subject: |
Re: bugs in dirname module - findutils portion |
Date: |
Mon, 28 Nov 2005 06:44:51 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This is my patch to findutils, rel-4-2-fixes (although it should also
apply to CVS head), to match the dirname module updates thread
on gnulib: http://lists.gnu.org/archive/html/bug-gnulib/2005-11/msg00071.html
It should be applied once the gnulib patch is applied.
Also, you may want to use emacs' whitespace-cleanup on the ChangeLog; it
is full of whitespace errors when compared to the GNU coding standards for
a change log. A number of your files have trailing whitespace; I normally
run with emacs using (add-hook 'before-save-hook 'whitespace-cleanup), but
had to disable that during my edits to avoid unrelated whitespace
cleanups. I also found it slightly annoying that import-gnulib.sh was not
stored as an executable script in CVS.
2005-11-28 Eric Blake <address@hidden>
The gnulib dirname module has changed semantics.
* find/find.c (at_top): Cleanup after base_name.
* find/pred.c (pred_fprintf, pred_iname, pred_name): Use new
last_component.
* locate/locate.c (visit_basename): Use new last_component.
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDiwnT84KuGfSFAYARAmsTAKChe9txEfpo1qFwUbmRAf6JX58a7ACfUC1B
eLQVjx7IJOVgAjMvdzVJgGc=
=xLRz
-----END PGP SIGNATURE-----
Index: find/find.c
===================================================================
RCS file: /cvsroot/findutils/findutils/find/find.c,v
retrieving revision 1.94.2.2
diff -u -p -r1.94.2.2 find.c
--- find/find.c 11 Nov 2005 07:46:20 -0000 1.94.2.2
+++ find/find.c 28 Nov 2005 13:31:12 -0000
@@ -1381,7 +1381,7 @@ at_top (char *pathname,
int dirchange;
char *parent_dir = dir_name(pathname);
char *base = base_name(pathname);
-
+
state.curdepth = 0;
state.path_length = strlen (pathname);
@@ -1389,6 +1389,7 @@ at_top (char *pathname,
|| 0 == strcmp(parent_dir, "."))
{
dirchange = 0;
+ free (base);
base = pathname;
}
else
@@ -1397,7 +1398,7 @@ at_top (char *pathname,
enum SafeChdirStatus chdir_status;
struct stat st;
boolean did_stat = false;
-
+
dirchange = 1;
if (0 == strcmp(base, ".."))
direction = TraversingUp;
@@ -1423,18 +1424,23 @@ at_top (char *pathname,
else
error (0, 0, "Failed to safely change directory into `%s'",
parent_dir);
-
+
/* We can't process this command-line argument. */
state.exit_status = 1;
+ free (parent_dir);
+ free (base);
return;
}
}
free (parent_dir);
parent_dir = NULL;
-
+
action(pathname, base, mode, pstat);
-
+
+ if (base != pathname)
+ free (base);
+
if (dirchange)
{
chdir_back();
Index: find/pred.c
===================================================================
RCS file: /cvsroot/findutils/findutils/find/pred.c,v
retrieving revision 1.67
diff -u -p -r1.67 pred.c
--- find/pred.c 4 Sep 2005 17:59:34 -0000 1.67
+++ find/pred.c 28 Nov 2005 13:31:12 -0000
@@ -654,7 +654,8 @@ pred_fprintf (char *pathname, struct sta
break;
case 'f': /* base name of path */
/* sanitised */
- print_quoted (fp, qopts, ttyflag, segment->text, base_name
(pathname));
+ print_quoted (fp, qopts, ttyflag, segment->text,
+ last_component (pathname));
break;
case 'F': /* filesystem type */
/* trusted */
@@ -969,7 +970,7 @@ pred_iname (char *pathname, struct stat
/* FNM_PERIOD is not used here because POSIX requires that it not be.
* See
http://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
*/
- base = base_name (pathname);
+ base = last_component (pathname);
if (fnmatch (pred_ptr->args.str, base, FNM_CASEFOLD) == 0)
return (true);
return (false);
@@ -1087,7 +1088,7 @@ pred_name (char *pathname, struct stat *
const char *base;
(void) stat_buf;
- base = base_name (pathname);
+ base = last_component (pathname);
/* FNM_PERIOD is not used here because POSIX requires that it not be.
* See
http://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
@@ -1920,5 +1921,3 @@ pred_sanity_check(const struct predicate
}
}
}
-
-
Index: locate/locate.c
===================================================================
RCS file: /cvsroot/findutils/findutils/locate/locate.c,v
retrieving revision 1.58
diff -u -p -r1.58 locate.c
--- locate/locate.c 1 Sep 2005 20:42:43 -0000 1.58
+++ locate/locate.c 28 Nov 2005 13:31:12 -0000
@@ -544,7 +544,7 @@ static int
visit_basename(struct process_data *procdata, void *context)
{
(void) context;
- procdata->munged_filename = base_name(procdata->original_filename);
+ procdata->munged_filename = last_component (procdata->original_filename);
return VISIT_CONTINUE;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: bugs in dirname module - findutils portion,
Eric Blake <=