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

Bug#243885: Processed: t



On Thu, May 27, 2004 at 07:03:05PM -0700, Debian Bug Tracking System wrote:
> Processing commands for control@bugs.debian.org:
> 
> > retitle 250499 dash: doesn't understand [[:digit:]]
> Bug#250499: clamav-daemon: dpkg-reconfigure; limit stream length question won't accept any answer
> Changed Bug title.

Please cc the maintainer that you're reassinging to in future.

This bug will go away as soon as glibc fixes their fnmatch(3)
implementation re #243885.

To the glibc maintainers, have you made any progress on that issue?

Once that happens dash can switch back to using fnmatch(3) which
supports character classes.

Until then, we'll need something like the following patch.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Index: expand.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/dash/expand.c,v
retrieving revision 1.79
diff -u -r1.79 expand.c
--- a/expand.c	18 Mar 2004 09:56:55 -0000	1.79
+++ b/expand.c	28 May 2004 12:03:34 -0000
@@ -61,6 +61,8 @@
 #if !defined(GLOB_BROKEN)
 #include <glob.h>
 #endif
+#else
+#include <ctype.h>
 #endif
 #endif
 
@@ -1491,6 +1493,42 @@
 
 
 #if !defined(__GLIBC__) || defined(FNMATCH_BROKEN)
+STATIC int ccmatch(const char *p, int chr, const char **r)
+{
+	static const struct class {
+		char name[10];
+		int (*fn)(int);
+	} classes[] = {
+		{ .name = ":alnum:]", .fn = isalnum },
+		{ .name = ":cntrl:]", .fn = iscntrl },
+		{ .name = ":lower:]", .fn = islower },
+		{ .name = ":space:]", .fn = isspace },
+		{ .name = ":alpha:]", .fn = isalpha },
+		{ .name = ":digit:]", .fn = isdigit },
+		{ .name = ":print:]", .fn = isprint },
+		{ .name = ":upper:]", .fn = isupper },
+		{ .name = ":blank:]", .fn = isblank },
+		{ .name = ":graph:]", .fn = isgraph },
+		{ .name = ":punct:]", .fn = ispunct },
+		{ .name = ":xdigit:]", .fn = isxdigit },
+	};
+	const struct class *class, *end;
+
+	end = classes + sizeof(classes) / sizeof(classes[0]);
+	for (class = classes; class < end; class++) {
+		const char *q;
+
+		q = prefix(p, class->name);
+		if (!q)
+			continue;
+		*r = q;
+		return class->fn(chr);
+	}
+
+	*r = 0;
+	return 0;
+}
+
 STATIC int
 pmatch(const char *pattern, const char *string)
 {
@@ -1529,21 +1567,11 @@
 			} while (*q++ != '\0');
 			return 0;
 		case '[': {
-			const char *endp;
+			const char *startp;
 			int invert, found;
 			char chr;
 
-			endp = p;
-			if (*endp == '!')
-				endp++;
-			for (;;) {
-				if (*endp == '\0')
-					goto dft;		/* no matching ] */
-				if (*endp == '\\')
-					endp++;
-				if (*++endp == ']')
-					break;
-			}
+			startp = p;
 			invert = 0;
 			if (*p == '!') {
 				invert++;
@@ -1555,7 +1583,20 @@
 				return 0;
 			c = *p++;
 			do {
-				if (c == '\\')
+				if (!c) {
+					p = startp;
+					c = *p;
+					goto dft;
+				}
+				if (c == '[') {
+					const char *r;
+
+					found |= ccmatch(p, chr, &r);
+					if (r) {
+						p = r;
+						continue;
+					}
+				} else if (c == '\\')
 					c = *p++;
 				if (*p == '-' && p[1] != ']') {
 					p++;

Reply to: