Prechádzať zdrojové kódy

dpkg-query: Only trim trailing "/" and "/." from pathnames in --search

We should not be trimming those characters from substring matches, or we
might get very confusing results.

This was actually the intention behind commit
af9e264518c4cab8e70788d0724d362ef25534d6, but somehow failed at it.
Guillem Jover 11 rokov pred
rodič
commit
a70815c94a
2 zmenil súbory, kde vykonal 11 pridanie a 14 odobranie
  1. 2 0
      debian/changelog
  2. 9 14
      src/querycmd.c

+ 2 - 0
debian/changelog

@@ -13,6 +13,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
   * Document that current build flag feature areas only work on Debian and
     derivatives in dpkg-buildflags(1).
   * Use “wildcard characters” instead of “wildchars” in dpkg-query(1).
+  * Only trim trailing “/” and “/.” from «dpkg-query --search» arguments if
+    they are a pathname, and not a pattern or a substring match.
 
  -- Guillem Jover <guillem@debian.org>  Tue, 09 Dec 2014 23:53:18 +0100
 

+ 9 - 14
src/querycmd.c

@@ -4,7 +4,7 @@
  *
  * Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2000,2001 Wichert Akkerman <wakkerma@debian.org>
- * Copyright © 2006-2014 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-2015 Guillem Jover <guillem@debian.org>
  * Copyright © 2011 Linaro Limited
  * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
  *
@@ -392,18 +392,6 @@ searchfiles(const char *const *argv)
   while ((thisarg = *argv++) != NULL) {
     found= 0;
 
-    /* Trim trailing ‘/’ and ‘/.’ from the argument if it's
-     * not a pattern, just a path. */
-    if (!strpbrk(thisarg, "*[?\\")) {
-      varbuf_reset(&path);
-      varbuf_add_str(&path, thisarg);
-      varbuf_end_str(&path);
-
-      varbuf_trunc(&path, path_trim_slash_slashdot(path.buf));
-
-      thisarg = path.buf;
-    }
-
     if (!strchr("*[?/",*thisarg)) {
       varbuf_reset(&vb);
       varbuf_add_char(&vb, '*');
@@ -413,7 +401,14 @@ searchfiles(const char *const *argv)
       thisarg= vb.buf;
     }
     if (!strpbrk(thisarg, "*[?\\")) {
-      namenode= findnamenode(thisarg, 0);
+      /* Trim trailing ‘/’ and ‘/.’ from the argument if it is not
+       * a pattern, just a pathname. */
+      varbuf_reset(&path);
+      varbuf_add_str(&path, thisarg);
+      varbuf_end_str(&path);
+      varbuf_trunc(&path, path_trim_slash_slashdot(path.buf));
+
+      namenode = findnamenode(path.buf, 0);
       found += searchoutput(namenode);
     } else {
       iter = files_db_iter_new();