pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files/lib Fixed the problem with ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f5927d940c78
branches:  trunk
changeset: 534261:f5927d940c78
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Oct 14 23:24:24 2007 +0000

description:
Fixed the problem with package name matching that Klaus Heinz discovered
in http://mail-index.netbsd.org/tech-pkg/2007/10/14/0004.html

The pattern "pkg_install" matched "pkg-install-20070828", but "pkg*all"
didn't. Now it does.

diffstat:

 pkgtools/pkg_install/files/lib/opattern.c |  26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 350d1bf6bc46 -r f5927d940c78 pkgtools/pkg_install/files/lib/opattern.c
--- a/pkgtools/pkg_install/files/lib/opattern.c Sun Oct 14 22:49:43 2007 +0000
+++ b/pkgtools/pkg_install/files/lib/opattern.c Sun Oct 14 23:24:24 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opattern.c,v 1.3 2007/08/12 16:47:18 joerg Exp $       */
+/*     $NetBSD: opattern.c,v 1.4 2007/10/14 23:24:24 rillig Exp $      */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -11,7 +11,7 @@
 #if 0
 static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
 #else
-__RCSID("$NetBSD: opattern.c,v 1.3 2007/08/12 16:47:18 joerg Exp $");
+__RCSID("$NetBSD: opattern.c,v 1.4 2007/10/14 23:24:24 rillig Exp $");
 #endif
 #endif
 
@@ -139,11 +139,27 @@
        }
        if (strpbrk(pattern, "*?[]") != (char *) NULL) {
                /* glob match */
-               return glob_match(pattern, pkg);
+               if (glob_match(pattern, pkg))
+                       return 1;
        }
-       
+
        /* no alternate, dewey or glob match -> simple compare */
-       return simple_match(pattern, pkg);
+       if (simple_match(pattern, pkg))
+               return 1;
+
+       /* globbing patterns and simple matches may be specified with or
+        * without the version number, so check for both cases. */
+
+       {
+               char *pattern_ver;
+               int retval;
+
+               if (asprintf(&pattern_ver, "%s-[0-9]*", pattern) == -1)
+                       errx(EXIT_FAILURE, "Out of memory");
+               retval = glob_match(pattern_ver, pkg);
+               free(pattern_ver);
+               return retval;
+       }
 }
 
 int



Home | Main Index | Thread Index | Old Index