[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Glob fix in locate.c

From: Russell Shaw
Subject: Glob fix in locate.c
Date: Sun, 13 Jun 2004 04:48:17 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040122 Debian/1.6-1

If i do: locate *.pc
i get:


However, if i do: locate x*.pc, i get nothing.

I found that locate tries to match against full path
names. This patch makes it match against the path with
leading directories removed. Now i can do: locate x*.pc
and get:


diff -apru findutils-4.1.20/locate/locate.c findutils-4.1.20-old/locate/locate.c
--- findutils-4.1.20/locate/locate.c    Mon May 26 23:39:54 2003
+++ findutils-4.1.20-old/locate/locate.c        Sun Jun 13 04:36:22 2004
@@ -438,7 +438,7 @@ locate (pathpart, dbfile, ignore_case)
                /* Success on the fast match.  Compare the whole pattern
                   if it contains globbing characters.  */
                prev_fast_match = true;
-               if (globflag == false || fnmatch (pathpart, path,
+               if (globflag == false || fnmatch (pathpart, basename(path),
                                                  0) == 0)
                    if (!check_existence || stat(path, &st) == 0)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]