Date: 2005-08-17 Initial Package Version: 2.9.6 Origin: Miklos Vajna Description: Adds regexp search functionality to pacman -Qs and Ss. doc/pacman.8.in | 8 ++++---- src/db.c | 6 +++--- src/pacman.c | 4 ++-- src/util.c | 11 +++++++++++ src/util.h | 1 + 5 files changed, 21 insertions(+), 9 deletions(-) diff -Naur pacman-2.9.6.orig/doc/pacman.8.in pacman-2.9.6/doc/pacman.8.in --- pacman-2.9.6.orig/doc/pacman.8.in 2005-03-06 20:39:38.000000000 +0100 +++ pacman-2.9.6/doc/pacman.8.in 2005-08-15 00:07:57.000000000 +0200 @@ -110,9 +110,9 @@ can be piped to a file and downloaded at a later time, using a program like wget. .TP -.B "\-s, \-\-search " +.B "\-s, \-\-search " This will search each package in the package list for names or descriptions -that contains . +that matches . .TP .B "\-u, \-\-sysupgrade" Upgrades all packages that are out of date. pacman will examine every @@ -182,9 +182,9 @@ file, not an entry in the database. Pacman will decompress the file and query it. This is useful with \fB--info\fP and \fB--list\fP. .TP -.B "\-s, \-\-search " +.B "\-s, \-\-search " This will search each locally-installed package for names or descriptions -that contains . +that matches . .SH HANDLING CONFIG FILES pacman uses the same logic as rpm to determine action against files that are designated to be backed up. During an upgrade, it uses 3 diff -Naur pacman-2.9.6.orig/src/db.c pacman-2.9.6/src/db.c --- pacman-2.9.6.orig/src/db.c 2005-04-22 02:26:33.000000000 +0200 +++ pacman-2.9.6/src/db.c 2005-08-15 00:04:03.000000000 +0200 @@ -657,7 +657,7 @@ /* check name */ haystack = strdup(pkg->name); strtoupper(haystack); - if(strstr(haystack, targ)) { + if(reg_match(haystack, targ)) { match = 1; } FREE(haystack); @@ -666,7 +666,7 @@ if(!match) { haystack = strdup(pkg->desc); strtoupper(haystack); - if(strstr(haystack, targ)) { + if(reg_match(haystack, targ)) { match = 1; } FREE(haystack); @@ -680,7 +680,7 @@ for(m = info->provides; m; m = m->next) { haystack = strdup(m->data); strtoupper(haystack); - if(strstr(haystack, targ)) { + if(reg_match(haystack, targ)) { match = 1; } FREE(haystack); diff -Naur pacman-2.9.6.orig/src/pacman.c pacman-2.9.6/src/pacman.c --- pacman-2.9.6.orig/src/pacman.c 2005-04-25 20:19:24.000000000 +0200 +++ pacman-2.9.6/src/pacman.c 2005-08-15 00:06:42.000000000 +0200 @@ -3795,7 +3795,7 @@ printf(" -o, --owns query the package that owns \n"); printf(" -p, --file pacman will query the package file [package] instead of\n"); printf(" looking in the database\n"); - printf(" -s, --search search locally-installed packages for matching strings\n"); + printf(" -s, --search search locally-installed packages for matching regexps\n"); } else if(op == PM_SYNC) { printf("usage: %s {-S --sync} [options] [package]\n", myname); printf("options:\n"); @@ -3806,7 +3806,7 @@ printf(" -i, --info view package information\n"); printf(" -l, --list list all packages belonging to the specified repository\n"); printf(" -p, --print-uris print out download URIs for each package to be installed\n"); - printf(" -s, --search search remote repositories for matching strings\n"); + printf(" -s, --search search remote repositories for matching regexps\n"); printf(" -u, --sysupgrade upgrade all packages that are out of date\n"); printf(" -w, --downloadonly download packages but do not install/upgrade anything\n"); printf(" -y, --refresh download fresh package databases from the server\n"); diff -Naur pacman-2.9.6.orig/src/util.c pacman-2.9.6/src/util.c --- pacman-2.9.6.orig/src/util.c 2005-01-12 00:14:16.000000000 +0100 +++ pacman-2.9.6/src/util.c 2005-08-15 00:03:22.000000000 +0200 @@ -30,6 +30,7 @@ #include #include #include +#include #include "util.h" extern unsigned short pmo_verbose; @@ -330,5 +331,15 @@ return(0); } +int reg_match(char *string, char *pattern) +{ + int result; + regex_t reg; + + regcomp(®, pattern, REG_EXTENDED | REG_NOSUB); + result = regexec(®, string, 0, 0, 0); + regfree(®); + return(!(result)); +} /* vim: set ts=2 sw=2 noet: */ diff -Naur pacman-2.9.6.orig/src/util.h pacman-2.9.6/src/util.h --- pacman-2.9.6.orig/src/util.h 2005-01-12 00:14:16.000000000 +0100 +++ pacman-2.9.6/src/util.h 2005-08-14 23:58:41.000000000 +0200 @@ -38,6 +38,7 @@ char* trim(char *str); char* strtoupper(char *str); int grep(const char *fn, const char *needle); +int reg_match(char *string, char *pattern); #endif /* vim: set ts=2 sw=2 noet: */