summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorksaito <ksaito@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-04 14:43:08 +0000
committerksaito <ksaito@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-04 14:43:08 +0000
commit82cb9eaa3bb49a77df4452cfdff18f817ecf63a6 (patch)
tree62fb3445ee466b5710d977707c048a0f26c5781d /re.c
parent5e853c811ce1d6d6edc187e580a14133667e1058 (diff)
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0. * parse.y, re.c: Now mbclen() takes unsigned char as its argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/re.c b/re.c
index daa179d819..59b80a9b04 100644
--- a/re.c
+++ b/re.c
@@ -248,11 +248,12 @@ rb_reg_mbclen2(c, re)
VALUE re;
{
int len;
+ unsigned char uc = (unsigned char)c;
if (!FL_TEST(re, KCODE_FIXED))
- return mbclen(c);
+ return mbclen(uc);
kcode_set_option(re);
- len = mbclen(c);
+ len = mbclen(uc);
kcode_reset_option();
return len;
}
@@ -1775,8 +1776,8 @@ rb_reg_quote(str)
send = s + RSTRING(str)->len;
for (; s < send; s++) {
c = *s;
- if (ismbchar(c)) {
- int n = mbclen(c);
+ if (ismbchar(*s)) {
+ int n = mbclen(*s);
while (n-- && s < send)
s++;
@@ -1804,8 +1805,8 @@ rb_reg_quote(str)
for (; s < send; s++) {
c = *s;
- if (ismbchar(c)) {
- int n = mbclen(c);
+ if (ismbchar(*s)) {
+ int n = mbclen(*s);
while (n-- && s < send)
*t++ = *s++;
@@ -2044,21 +2045,23 @@ rb_reg_regsub(str, src, regs)
struct re_registers *regs;
{
VALUE val = 0;
- char *p, *s, *e, c;
+ char *p, *s, *e;
+ unsigned char uc;
int no;
+
p = s = RSTRING(str)->ptr;
e = s + RSTRING(str)->len;
while (s < e) {
char *ss = s;
- c = *s++;
- if (ismbchar(c)) {
- s += mbclen(c) - 1;
+ uc = (unsigned char)*s++;
+ if (ismbchar(uc)) {
+ s += mbclen(uc) - 1;
continue;
}
- if (c != '\\' || s == e) continue;
+ if (uc != '\\' || s == e) continue;
if (!val) {
val = rb_str_buf_new(ss-p);
@@ -2068,12 +2071,12 @@ rb_reg_regsub(str, src, regs)
rb_str_buf_cat(val, p, ss-p);
}
- c = *s++;
+ uc = (unsigned char)*s++;
p = s;
- switch (c) {
+ switch (uc) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- no = c - '0';
+ no = uc - '0';
break;
case '&':
no = 0;