Gentoo Archives: gentoo-commits

From: "Roy Marples (uberlord)" <uberlord@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-freebsd/freebsd-bin/files: freebsd-bin-6.2-sh-cclass.patch
Date: Tue, 02 Oct 2007 13:42:24
Message-Id: E1IchsG-0008Py-S6@stork.gentoo.org
1 uberlord 07/10/02 13:33:20
2
3 Added: freebsd-bin-6.2-sh-cclass.patch
4 Log:
5 support POSIX character class RE match for sh
6 (Portage version: 2.1.3.11)
7
8 Revision Changes Path
9 1.1 sys-freebsd/freebsd-bin/files/freebsd-bin-6.2-sh-cclass.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-freebsd/freebsd-bin/files/freebsd-bin-6.2-sh-cclass.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-freebsd/freebsd-bin/files/freebsd-bin-6.2-sh-cclass.patch?rev=1.1&content-type=text/plain
13
14 Index: freebsd-bin-6.2-sh-cclass.patch
15 ===================================================================
16 Allow sh to use POSIX character classes, as specified in
17 sections 2.13.1 and 9.3.5
18
19 diff -u a/sh/expand.c b/sh/expand.c
20 --- a/sh/expand.c 2005-11-06 20:39:47 +0000
21 +++ b/sh/expand.c 2007-10-02 13:46:28 +0100
22 @@ -1320,6 +1320,42 @@
23 }
24
25
26 +STATIC int ccmatch(char *p, int chr, char **r)
27 +{
28 + static const struct class {
29 + char name[10];
30 + int (*fn)(int);
31 + } classes[] = {
32 + { .name = ":alnum:]", .fn = isalnum },
33 + { .name = ":cntrl:]", .fn = iscntrl },
34 + { .name = ":lower:]", .fn = islower },
35 + { .name = ":space:]", .fn = isspace },
36 + { .name = ":alpha:]", .fn = isalpha },
37 + { .name = ":digit:]", .fn = isdigit },
38 + { .name = ":print:]", .fn = isprint },
39 + { .name = ":upper:]", .fn = isupper },
40 + { .name = ":blank:]", .fn = isblank },
41 + { .name = ":graph:]", .fn = isgraph },
42 + { .name = ":punct:]", .fn = ispunct },
43 + { .name = ":xdigit:]", .fn = isxdigit },
44 + };
45 + const struct class *class, *end;
46 + char *q;
47 +
48 + end = classes + sizeof(classes) / sizeof(classes[0]);
49 + for (class = classes; class < end; class++) {
50 + q = prefix(class->name, p);
51 + if (!q)
52 + continue;
53 + *r = q;
54 + return class->fn(chr);
55 + }
56 +
57 + *r = 0;
58 + return 0;
59 +}
60 +
61 +
62 STATIC int
63 pmatch(char *pattern, char *string, int squoted)
64 {
65 @@ -1405,6 +1441,15 @@
66 continue;
67 if (c == CTLESC)
68 c = *p++;
69 + else if (c == '[') {
70 + char *r;
71 +
72 + found |= ccmatch(p, chr, &r);
73 + if (r) {
74 + p = r;
75 + continue;
76 + }
77 + }
78 if (*p == '-' && p[1] != ']') {
79 p++;
80 while (*p == CTLQUOTEMARK)
81 diff -u a/sh/mystring.c b/sh/mystring.c
82 --- a/sh/mystring.c 2004-04-06 21:06:51 +0100
83 +++ b/sh/mystring.c 2007-10-02 13:45:31 +0100
84 @@ -88,14 +88,14 @@
85 * prefix -- see if pfx is a prefix of string.
86 */
87
88 -int
89 +char *
90 prefix(const char *pfx, const char *string)
91 {
92 while (*pfx) {
93 if (*pfx++ != *string++)
94 return 0;
95 }
96 - return 1;
97 + return (char *)string;
98 }
99
100
101 diff -u a/sh/mystring.h b/sh/mystring.h
102 --- a/sh/mystring.h 2004-04-06 21:06:51 +0100
103 +++ b/sh/mystring.h 2007-10-02 13:45:35 +0100
104 @@ -36,7 +36,7 @@
105 #include <string.h>
106
107 void scopyn(const char *, char *, int);
108 -int prefix(const char *, const char *);
109 +char *prefix(const char *, const char *);
110 int number(const char *);
111 int is_number(const char *);
112
113
114
115 --
116 gentoo-commits@g.o mailing list