/[packages]/cauldron/grep/current/SOURCES/67-w.patch
ViewVC logotype

Contents of /cauldron/grep/current/SOURCES/67-w.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download)
Tue Jan 4 21:05:36 2011 UTC (13 years, 2 months ago) by tmb
File size: 2876 byte(s)
imported package grep
1 reverted:
2 --- src/search.c 2007-10-01 14:47:55.000000000 +0200
3 +++ src/search.c 2007-09-30 23:38:45.000000000 +0200
4 @@ -282,6 +284,7 @@
5 static int use_dfa_checked = 0;
6 size_t i, ret_val;
7 #ifdef MBS_SUPPORT
8 + const char *last_char = NULL;
9 int mb_cur_max = MB_CUR_MAX;
10 mbstate_t mbs;
11 memset (&mbs, '\0', sizeof (mbstate_t));
12 @@ -338,6 +341,8 @@
13 while (bytes_left)
14 {
15 size_t mlen = mbrlen (beg, bytes_left, &mbs);
16 +
17 + last_char = beg;
18 if (mlen == (size_t) -1 || mlen == 0)
19 {
20 /* Incomplete character: treat as single-byte. */
21 @@ -398,6 +403,8 @@
22 while (bytes_left)
23 {
24 size_t mlen = mbrlen (beg, bytes_left, &mbs);
25 +
26 + last_char = beg;
27 if (mlen == (size_t) -1 || mlen == 0)
28 {
29 /* Incomplete character: treat as single-byte. */
30 @@ -475,10 +483,84 @@
31 if (match_words)
32 while (match <= best_match)
33 {
34 + int lword_match = 0;
35 + if (match == buf)
36 + lword_match = 1;
37 + else
38 + {
39 + assert (start > 0);
40 +#ifdef MBS_SUPPORT
41 + if (mb_cur_max > 1)
42 + {
43 + const char *s;
44 + int mr;
45 + wchar_t pwc;
46 + if (using_utf8)
47 + {
48 + s = match - 1;
49 + while (s > buf
50 + && (unsigned char) *s >= 0x80
51 + && (unsigned char) *s <= 0xbf)
52 + --s;
53 + }
54 + else
55 + s = last_char;
56 + mr = mbtowc (&pwc, s, match - s);
57 + if (mr <= 0)
58 + {
59 + memset (&mbs, '\0', sizeof (mbstate_t));
60 + lword_match = 1;
61 + }
62 + else if (!(iswalnum (pwc) || pwc == L'_')
63 + && mr == (int) (match - s))
64 + lword_match = 1;
65 + }
66 + else
67 +#endif /* MBS_SUPPORT */
68 + if (!WCHAR ((unsigned char) match[-1]))
69 + lword_match = 1;
70 + }
71 +
72 + if (lword_match)
73 + {
74 + int rword_match = 0;
75 + if (start + len == end - beg - 1)
76 + rword_match = 1;
77 + else
78 + {
79 +#ifdef MBS_SUPPORT
80 + if (mb_cur_max > 1)
81 + {
82 + wchar_t nwc;
83 + int mr;
84 +
85 + mr = mbtowc (&nwc, buf + start + len,
86 + end - buf - start - len - 1);
87 + if (mr <= 0)
88 + {
89 + memset (&mbs, '\0', sizeof (mbstate_t));
90 + rword_match = 1;
91 + }
92 + else if (!iswalnum (nwc) && nwc != L'_')
93 + rword_match = 1;
94 + }
95 + else
96 +#endif /* MBS_SUPPORT */
97 + if (!WCHAR ((unsigned char) match[len]))
98 + rword_match = 1;
99 + }
100 +
101 + if (rword_match)
102 + {
103 + if (!start_ptr)
104 + /* Returns the whole line. */
105 + goto success;
106 + else
107 + {
108 + goto assess_pattern_match;
109 + }
110 + }
111 + }
112 - if ((match == buf || !WCHAR ((unsigned char) match[-1]))
113 - && (len == end - beg - 1
114 - || !WCHAR ((unsigned char) match[len])))
115 - goto assess_pattern_match;
116 if (len > 0)
117 {
118 /* Try a shorter length anchored at the same place. */

  ViewVC Help
Powered by ViewVC 1.1.30