If i do: locate g*.pc, it does not find /usr/share/doc/gdk-2.0.pc. This patch fixes that. I've tested it a couple of times. Most of the change is just to make the code easier to read. The logic is (should be) the same as the old locate.c, except in the old file on line 413, "basename" is added to strip the dir prefix. Same also on line 442. Only in findutils.orig: findutils diff -apru findutils.orig/locate/locate.c findutils/locate/locate.c --- findutils.orig/locate/locate.c Sat Aug 2 22:16:14 2003 +++ findutils/locate/locate.c Sun Oct 19 22:58:01 2003 @@ -59,7 +59,10 @@ #undef PACKAGE #include <config.h> #include <stdio.h> + +/* isupper/islower: implicit declaration */ #include <ctype.h> + #include <sys/types.h> #include <sys/stat.h> #include <time.h> @@ -393,66 +396,47 @@ locate (pathpart, dbfile, ignore_case) /* Search backward starting at the end of the path we just read in, for the character at the end of the last glob-free subpattern in PATHPART. */ - if (ignore_case) - { - for (prev_fast_match = false; s >= cutoff; s--) - /* Fast first char check. */ - if (TOLOWER(*s) == *patend) - { - char *s2; /* Scan the path we read in. */ - register char *p2; /* Scan `patend'. */ - - for (s2 = s - 1, p2 = patend - 1; *p2 != '\0' && TOLOWER(*s2) == *p2; - s2--, p2--) - ; - if (*p2 == '\0') - { - /* Success on the fast match. Compare the whole pattern - if it contains globbing characters. */ - prev_fast_match = true; - if (globflag == false || fnmatch (pathpart, path, FNM_CASEFOLD) == 0) - { - if (!check_existence || stat(path, &st) == 0) - { - puts (path); - ++printed; - } - } - break; - } - } - } - else { - - for (prev_fast_match = false; s >= cutoff; s--) - /* Fast first char check. */ - if (*s == *patend) - { - char *s2; /* Scan the path we read in. */ - register char *p2; /* Scan `patend'. */ - - for (s2 = s - 1, p2 = patend - 1; *p2 != '\0' && *s2 == *p2; - s2--, p2--) - ; - if (*p2 == '\0') - { - /* Success on the fast match. Compare the whole pattern - if it contains globbing characters. */ - prev_fast_match = true; - if (globflag == false || fnmatch (pathpart, path, - 0) == 0) - { - if (!check_existence || stat(path, &st) == 0) - { - puts (path); - ++printed; - } - } - break; - } - } - } - + for(prev_fast_match=false; s>=cutoff; s--) + { + char *s2; /* Scan the path we read in. */ + register char *p2; /* Scan `patend'. */ + + /* Fast first char check. */ + if(ignore_case) + { + if(TOLOWER(*s)!=*patend) + continue; + } + else if(*s!=*patend) + continue; + + if(ignore_case) + for(s2=s-1, p2=patend-1; *p2!='\0' && TOLOWER(*s2)==*p2; s2--, p2--); + else + for(s2=s-1, p2=patend-1; *p2!='\0' && *s2==*p2; s2--, p2--); + + if(*p2!='\0') + continue; + /* Success on the fast match. Compare the whole pattern + if it contains globbing characters. */ + prev_fast_match = true; + if(globflag) + { + if(ignore_case) + { + if(fnmatch(pathpart,basename(path),FNM_CASEFOLD)!=0) + break; + } + else + if(fnmatch(pathpart,basename(path),0)!=0) + break; + } + if(check_existence && stat(path,&st)!=0) + break; + puts(path); + ++printed; + break; + } } if (ferror (fp))