]> git.pld-linux.org Git - packages/grep.git/blame - grep-i18n.patch
- patch from RH.
[packages/grep.git] / grep-i18n.patch
CommitLineData
6912647e 1The following patch works around the bug in grep which makes
2
3 grep '[a-c]'
4
5match "B". Note, this is a bug in grep caused by a bug in the
6standards which do not provide interfaces to get the necessary
7information. This patch as correct as grep was before (multibyte char
8handling is not 100% correct but that cannot be solved now), future
9changes might increase the speed a bit.
10
11~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12--- grep-2.4.2/src/dfa.c-old Sat Aug 19 17:55:05 2000
13+++ grep-2.4.2/src/dfa.c Sat Aug 19 17:55:11 2000
14@@ -743,6 +743,7 @@ lex (void)
15 else
16 c2 = c;
17
18+#if 0
19 lo[0] = c; lo[1] = '\0';
20 hi[0] = c2; hi[1] = '\0';
21 for (c = 0; c < NOTCHAR; c++)
22@@ -761,6 +762,37 @@ lex (void)
23 }
24 }
25 }
26+#else
27+ {
28+ char expr[6] = { '[', c, '-', c2, ']', '\0' };
29+ regex_t re;
30+
31+ if (regcomp (&re, expr, case_fold ? REG_ICASE : 0)
32+ == REG_NOERROR)
33+ {
34+ for (c = 0; c < NOTCHAR; ++c)
35+ {
36+ char buf[2] = { c, '\0' };
37+ regmatch_t mat;
38+
39+ if (regexec (&re, buf, 1, &mat, 0) == REG_NOERROR
40+ && mat.rm_so == 0 && mat.rm_eo == 1)
41+ {
42+ setbit (c, ccl);
43+ if (case_fold)
44+ {
45+ if (ISUPPER (c))
46+ setbit (tolower (c), ccl);
47+ else if (ISLOWER (c))
48+ setbit (toupper (c), ccl);
49+ }
50+ }
51+ }
52+
53+ regfree (&re);
54+ }
55+ }
56+#endif
57
58 skip:
59 ;
60~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This page took 0.047827 seconds and 4 git commands to generate.