Date: 2005-09-20
Initial Package Version: 2.9.7
Upstream Status: Not yet submitted
Origin: Miklos Vajna <vmiklos@frugalware.org>
Description: Replaces pacman -Ss foo['s segfault with an error message.
diff -Naur pacman-2.9.7.orig/src/db.c pacman-2.9.7/src/db.c
--- pacman-2.9.7.orig/src/db.c	2005-09-20 23:34:53.000000000 +0200
+++ pacman-2.9.7/src/db.c	2005-09-20 23:53:49.000000000 +0200
@@ -661,14 +661,12 @@
 
 	for(i = needles; i; i = i->next) {
 		char *targ = strdup(i->data);
-		strtoupper(targ);
 		for(j = cache; j; j = j->next) {
 			pkginfo_t *pkg = (pkginfo_t*)j->data;
 			char *haystack;
 			int match = 0;
 			/* check name */
 			haystack = strdup(pkg->name);
-			strtoupper(haystack);
 			if(reg_match(haystack, targ)) {
 				match = 1;
 			}
@@ -677,7 +675,6 @@
 			/* check description */
 			if(!match) {
 				haystack = strdup(pkg->desc);
-				strtoupper(haystack);
 				if(reg_match(haystack, targ)) {
 					match = 1;
 				}
@@ -691,7 +688,6 @@
 				if(info != NULL) {
 					for(m = info->provides; m; m = m->next) {
 						haystack = strdup(m->data);
-						strtoupper(haystack);
 						if(reg_match(haystack, targ)) {
 							match = 1;
 						}
diff -Naur pacman-2.9.7.orig/src/util.c pacman-2.9.7/src/util.c
--- pacman-2.9.7.orig/src/util.c	2005-09-20 23:34:53.000000000 +0200
+++ pacman-2.9.7/src/util.c	2005-09-20 23:54:01.000000000 +0200
@@ -403,7 +403,11 @@
 	int result;
 	regex_t reg;
 
-	regcomp(&reg, pattern, REG_EXTENDED | REG_NOSUB);
+	if (regcomp(&reg, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0)
+	{
+		fprintf(stderr, "error: %s is not a valid regular expression.\n", pattern);
+		exit(1);
+	}
 	result = regexec(&reg, string, 0, 0, 0);
 	regfree(&reg);
 	return(!(result));
