[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 |
Hi,
If i do: locate *.pc
i get:
/usr/lib/pkgconfig/libxml.pc
/usr/lib/pkgconfig/openssl.pc
/usr/lib/pkgconfig/ORBit-2.0.pc
/usr/lib/pkgconfig/pango.pc
/usr/lib/pkgconfig/render.pc
/usr/lib/pkgconfig/xcursor.pc
/usr/local/lib/pkgconfig/atk.pc
/usr/local/lib/pkgconfig/gdk-2.0.pc
...
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:
/usr/lib/pkgconfig/xcursor.pc
/usr/lib/pkgconfig/xft.pc
/usr/lib/pkgconfig/xrender.pc
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)
- Glob fix in locate.c,
Russell Shaw <=