rpmFindByFile() removes duplicate and trailing / providing weak filename
authorewt <devnull@localhost>
Mon, 28 Apr 1997 21:01:01 +0000 (21:01 +0000)
committerewt <devnull@localhost>
Mon, 28 Apr 1997 21:01:01 +0000 (21:01 +0000)
canonicaliaztion.

CVS patchset: 1557
CVS date: 1997/04/28 21:01:01

CHANGES
lib/rpmdb.c

diff --git a/CHANGES b/CHANGES
index 3868e24..b735160 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,7 @@
        - include <time.h> in build/spec.c for various platforms
        - added update-po rule to po/Makefile.in
        - updated de.po (thanks to Karl Eichwalder)
+       - rpmFindByFile() removes trailing and duplicate /'s
 
 2.3.10 -> 2.3.11:
        - fixed newlines in --scripts output
index 1dc87b4..264a84c 100644 (file)
@@ -254,7 +254,27 @@ Header rpmdbGetRecord(rpmdb db, unsigned int offset) {
 }
 
 int rpmdbFindByFile(rpmdb db, char * filespec, dbiIndexSet * matches) {
-    return dbiSearchIndex(db->fileIndex, filespec, matches);
+    char * fs;
+    char * src, * dst;
+
+    /* we try and canonicalize the filespec a bit before doing the search */
+
+    fs = alloca(strlen(filespec) + 1);
+    for (src = filespec, dst = fs; *src; ) { 
+       switch (*src) {
+         case '/':
+           if ((dst == fs) || (*(dst - 1) != '/'))
+               *dst++ = *src;
+           src++;
+           break;
+         default:
+           *dst++ = *src++;
+       }
+    }
+    *dst-- = '\0';
+    if (*dst == '/') *dst = '\0';
+
+    return dbiSearchIndex(db->fileIndex, fs, matches);
 }
 
 int rpmdbFindByProvides(rpmdb db, char * filespec, dbiIndexSet * matches) {