diff -Ndrup curr/findutils/doc/find.texi mine2/findutils/doc/find.texi --- findutils/doc/find.texi 2005-03-02 00:17:00.000000000 +0100 +++ findutils/doc/find.texi 2005-03-08 00:48:20.000000000 +0100 @@ -2673,17 +2673,26 @@ down the program a lot, if there are man The way in which broken symbolic links are treated is affected by the @samp{-L}, @samp{-P} and @samp{-H} options. address@hidden --non-existing address@hidden -E +Only print out such names which currently do not exist (instead of such +names which existed when the database was created). +Note that this may slow down the program a lot, if there are many matches +in the database. +The way in which broken symbolic links are treated is affected by the address@hidden, @samp{-P} and @samp{-H} options. + @item --follow @itemx -L -If testing for the existence of files (with the @samp{-e} option), -omit broken symbolic links. This is the default. +If testing for the existence of files (with the @samp{-e} or @samp(-E) options), +consider broken symbolic links to be non-existing. This is the default. @item --nofollow @itemx -P @itemx -H -If testing for the existence of files (with the @samp{-e} option), -treat broken symbolic links count as if they were exiting files. The +If testing for the existence of files (with the @samp{-e} or @samp(-E) options), +treat broken symbolic links as if they were existing files. The @samp{-H} form of this option is provided purely for similarity with @code{find}; the use of @samp{-P} is recommended over @samp{-H}. diff -Ndrup curr/findutils/locate/locate.1 mine2/findutils/locate/locate.1 --- findutils/locate/locate.1 2005-04-01 21:13:10.000000000 +0200 +++ findutils/locate/locate.1 2005-03-08 00:48:20.000000000 +0100 @@ -3,10 +3,11 @@ locate \- list files in databases that match a pattern .SH SYNOPSIS .B locate -[\-d path | \-\-database=path] [\-e | \-\-existing] [\-i | \-\-ignore-case] -[\-0 | \-\-null] [\-c | \-\-count] [\-w | \-\-wholename] [\-b | \-\-basename] -[\-l N | \-\-limit=N] [\-S | \-\-statistics] [\-r | \-\-regex ] -[\-P | \-H | \-\-nofollow] [\-L | \-\-follow] [\-\-version] [\-\-help] pattern... +[\-d path | \-\-database=path] [\-e | \-E | \-\-[non\-]existing] [\-i +| \-\-ignore-case] [\-0 | \-\-null] [\-c | \-\-count] [\-w | \-\-wholename] +|\-b | \-\-basename] [\-l N | \-\-limit=N] [\-S | \-\-statistics] [\-r +| \-\-regex ] [\-P | \-H | \-\-nofollow] [\-L | \-\-follow] [\-\-version] +[\-\-help] pattern... .SH DESCRIPTION This manual page documents the GNU version of @@ -80,13 +81,19 @@ please note that it is possible for the .B locate has checked that it exists, but before you use it. .TP +.I "\-E, \-\-non\-existing" +Only print out such names that currently do not exist (instead of such names +that existed when the database was created). +Note that this may slow down the program a lot, if there are many matches +in the database. +.TP .I "\-L, \-\-follow" -If testing for the existence of files (with the \-e option), omit -broken symbolic links. This is the default. +If testing for the existence of files (with the \-e or \-E options), +consider broken symbolic links to be non-existing. This is the default. .TP .I "\-P, \-H, \-\-nofollow" -If testing for the existence of files (with the \-e option), treat -broken symbolic links count as if they were exiting files. The \-H +If testing for the existence of files (with the \-e or \-E options), treat +broken symbolic links as if they were existing files. The \-H form of this option is provided purely for similarity with .BR find ; the use of \-P is recommended over \-H. diff -Ndrup curr/findutils/locate/locate.c mine2/findutils/locate/locate.c --- findutils/locate/locate.c 2005-03-06 00:16:16.000000000 +0100 +++ findutils/locate/locate.c 2005-03-08 03:42:10.000000000 +0100 @@ -331,7 +331,7 @@ visit_justprint(const char *munged_filen } static int -visit_exists_follow(const char *munged_filename, +visit_existing_follow(const char *munged_filename, const char *original_filename, void *context) { struct stat st; @@ -354,7 +354,30 @@ visit_exists_follow(const char *munged_f } static int -visit_exists_nofollow(const char *munged_filename, +visit_non_existing_follow(const char *munged_filename, + const char *original_filename, void *context) +{ + struct stat st; + (void) context; + (void) munged_filename; + + /* munged_filename has been converted in some way (to lower case, + * or is just the base name of the file), and original_filename has not. + * Hence only original_filename is still actually the name of the file + * whose existence we would need to check. + */ + if (stat(original_filename, &st) == 0) + { + return VISIT_REJECTED; + } + else + { + return VISIT_CONTINUE; + } +} + +static int +visit_existing_nofollow(const char *munged_filename, const char *original_filename, void *context) { struct stat st; @@ -377,6 +400,29 @@ visit_exists_nofollow(const char *munged } static int +visit_non_existing_nofollow(const char *munged_filename, + const char *original_filename, void *context) +{ + struct stat st; + (void) context; + (void) munged_filename; + + /* munged_filename has been converted in some way (to lower case, + * or is just the base name of the file), and original_filename has not. + * Hence only original_filename is still actually the name of the file + * whose existence we would need to check. + */ + if (lstat(original_filename, &st) == 0) + { + return VISIT_REJECTED; + } + else + { + return VISIT_CONTINUE; + } +} + +static int visit_substring_match_nocasefold(const char *munged_filename, const char *original_filename, void *context) { const char *pattern = context; @@ -611,21 +657,21 @@ new_locate (char *pathpart, } } - /* We add visit_exists_*() as late as possible to reduce the + /* We add visit_existing_*() as late as possible to reduce the * number of stat() calls. */ - if (check_existence) - { - visitfunc f; - if (follow_symlinks) - f = visit_exists_follow; - else - f = visit_exists_nofollow; - - add_visitor(f, NULL); - } - + if (check_existence==1) + if (follow_symlinks) + add_visitor(visit_existing_follow, NULL); + else + add_visitor(visit_existing_nofollow, NULL); + if (check_existence==2) + if (follow_symlinks) + add_visitor(visit_non_existing_follow, NULL); + else + add_visitor(visit_non_existing_nofollow, NULL); + if (enable_print) add_visitor(visit_justprint, NULL); } @@ -778,7 +824,7 @@ usage (stream) FILE *stream; { fprintf (stream, _("\ -Usage: %s [-d path | --database=path] [-e | --existing]\n\ +Usage: %s [-d path | --database=path] [-e | -E | --[non-]existing]\n\ [-i | --ignore-case] [-w | --wholename] [-b | --basename] \n\ [--limit=N | -l N] [-S | --statistics] [-0 | --null] [-c | --count]\n\ [-P | -H | --nofollow] [-L | --follow] [-m | --mmap ] [ -s | --stdio ]\n\ @@ -791,6 +837,7 @@ static struct option const longopts[] = { {"database", required_argument, NULL, 'd'}, {"existing", no_argument, NULL, 'e'}, + {"non-existing", no_argument, NULL, 'E'}, {"ignore-case", no_argument, NULL, 'i'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, @@ -841,7 +888,7 @@ main (argc, argv) check_existence = 0; - while ((optc = getopt_long (argc, argv, "bcd:eil:rsm0SwHPL", longopts, (int *) 0)) != -1) + while ((optc = getopt_long (argc, argv, "bcd:eEil:rsm0SwHPL", longopts, (int *) 0)) != -1) switch (optc) { case '0': @@ -865,6 +912,10 @@ main (argc, argv) check_existence = 1; break; + case 'E': + check_existence = 2; + break; + case 'i': ignore_case = 1; break;