summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-03 09:48:00 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-03 09:48:00 +0000
commit06d4e3b42d836b762c29cdc9dc7181caf14dcdec (patch)
tree4c85b1a55d024c59143e193b17e2444cb6873c6e /regex.c
parent99839272a3cf1dfe69bd3bad26d96a915b905ef1 (diff)
990203
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/regex.c b/regex.c
index 426b49039e..d2a0fd95c2 100644
--- a/regex.c
+++ b/regex.c
@@ -400,9 +400,9 @@ re_set_syntax(syntax)
if (current_mbctype == MBCTYPE_UTF8) {\
int n = ismbchar(c);\
int c1;\
- c &= 1<<(BYTEWIDTH-2-n);\
+ c &= (1<<(BYTEWIDTH-2-n)) - 1;\
while (n--) {\
- c = c << 6 | *p++;\
+ c = c << 6 | *p++ & ((1<<6)-1);\
}\
}\
else {\
@@ -502,19 +502,17 @@ print_mbc(c)
/* Get the next unsigned number in the uncompiled pattern. */
#define GET_UNSIGNED_NUMBER(num) \
- do { if (p != pend) \
- { \
+ do { if (p != pend) { \
PATFETCH(c); \
- while (ISDIGIT(c)) \
- { \
- if (num < 0) \
- num = 0; \
- num = num * 10 + c - '0'; \
- if (p == pend) \
- break; \
- PATFETCH(c); \
- } \
- } \
+ while (ISDIGIT(c)) { \
+ if (num < 0) \
+ num = 0; \
+ num = num * 10 + c - '0'; \
+ if (p == pend) \
+ break; \
+ PATFETCH(c); \
+ } \
+ } \
} while (0)
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
@@ -1969,6 +1967,7 @@ re_compile_pattern(pattern, size, bufp)
p_save = p;
had_mbchar = 0;
+ c1 = 0;
GET_UNSIGNED_NUMBER(c1);
if (!ISDIGIT(c)) PATUNFETCH;
@@ -2844,10 +2843,11 @@ re_search(bufp, string, size, startpos, range, regs)
while (range > 0) {
c = *p++;
if (ismbchar(c)) {
+ int len = ismbchar(c);
if (fastmap[c])
break;
c = *p++;
- range--;
+ range -= len;
if (fastmap[c] == 2)
break;
}
@@ -3092,7 +3092,7 @@ typedef union
#define IS_A_LETTER(d) (SYNTAX(*(d)) == Sword || \
(current_mbctype ? \
- re_mbctab[*(d)] == 1 : \
+ re_mbctab[*(d)] : \
SYNTAX(*(d)) == Sword2))
#define PREV_IS_A_LETTER(d) ((current_mbctype == MBCTYPE_SJIS)? \
@@ -3537,7 +3537,7 @@ re_match(bufp, string_arg, size, pos, regs)
PREFETCH;
cc = c = (unsigned char)*d++;
if (ismbchar(c)) {
- if (d + ismbchar(c) < dend) {
+ if (d + ismbchar(c) <= dend) {
MBC2WC(c, d);
}
}