> > -----Original Message----- > 手元にそのような環境がないので確認できませんが、 > もしそうなら、mbclen()とismbchar()には > charかunsigned charを渡すように書き換える必要が > あります。 > > 無駄になるかもしれませんが、これからパッチを > 作ってみようと思います。 出来ました。 -- 小迫@出向中 --- parse.y.orig 2004-05-25 11:54:21.000000000 +0900 +++ parse.y 2004-05-28 14:49:07.000000000 +0900 @@ -3084,8 +3084,10 @@ tokadd_string(func, term, paren, nest) int func, term, paren, *nest; { int c; + unsigned char uc; while ((c = nextc()) != -1) { + uc = (unsigned char )c; if (paren && c == paren) { ++*nest; } @@ -3136,8 +3138,8 @@ tokadd_string(func, term, paren, nest) } } } - else if (ismbchar(c)) { - int i, len = mbclen(c)-1; + else if (ismbchar(uc)) { + int i, len = mbclen(uc)-1; for (i = 0; i < len; i++) { tokadd(c); @@ -3217,6 +3219,7 @@ static int heredoc_identifier() { int c = nextc(), term, func = 0, len; + unsigned char uc; if (c == '-') { c = nextc(); @@ -3234,7 +3237,8 @@ heredoc_identifier() tokadd(func); term = c; while ((c = nextc()) != -1 && c != term) { - len = mbclen(c); + uc = (unsigned char )c; + len = mbclen(uc); do {tokadd(c);} while (--len > 0 && (c = nextc()) != -1); } if (c == -1) { @@ -3244,7 +3248,8 @@ heredoc_identifier() break; default: - if (!is_identchar(c)) { + uc = (unsigned char )c; + if (!is_identchar(uc)) { pushback(c); if (func & STR_FUNC_INDENT) { pushback('-'); @@ -3255,9 +3260,11 @@ heredoc_identifier() term = '"'; tokadd(func |= str_dquote); do { - len = mbclen(c); + uc = (unsigned char )c; + len = mbclen(uc); do {tokadd(c);} while (--len > 0 && (c = nextc()) != -1); - } while ((c = nextc()) != -1 && is_identchar(c)); + } while ((c = nextc()) != -1 && + (uc = (unsigned char )c, is_identchar(uc))); pushback(c); break; } @@ -3404,6 +3411,7 @@ yylex() register int c; int space_seen = 0; int cmd_state; + unsigned char uc; if (lex_strterm) { int token; @@ -3643,6 +3651,7 @@ yylex() rb_compile_error("incomplete character syntax"); return 0; } + uc = (unsigned char )c; if (ISSPACE(c)){ if (!IS_ARG()){ int c2 = 0; @@ -3675,7 +3684,7 @@ yylex() lex_state = EXPR_TERNARY; return '?'; } - else if (ismbchar(c)) { + else if (ismbchar(uc)) { rb_warn("multibyte character literal not supported yet; use ?\\%.3o", c); goto ternary; } @@ -4219,7 +4228,8 @@ yylex() } else { term = nextc(); - if (ISALNUM(term) || ismbchar(term)) { + uc = (unsigned char )c; + if (ISALNUM(term) || ismbchar(uc)) { yyerror("unknown type of %string"); return 0; } @@ -4298,7 +4308,8 @@ yylex() switch (c) { case '_': /* $_: last read line string */ c = nextc(); - if (is_identchar(c)) { + uc = (unsigned char )c; + if (is_identchar(uc)) { tokadd('$'); tokadd('_'); break; @@ -4364,7 +4375,8 @@ yylex() return tNTH_REF; default: - if (!is_identchar(c)) { + uc = (unsigned char )c; + if (!is_identchar(uc)) { pushback(c); return '$'; } @@ -4389,7 +4401,8 @@ yylex() rb_compile_error("`@@%c' is not allowed as a class variable name", c); } } - if (!is_identchar(c)) { + uc = (unsigned char )c; + if (!is_identchar(uc)) { pushback(c); return '@'; } @@ -4405,7 +4418,8 @@ yylex() break; default: - if (!is_identchar(c)) { + uc = (unsigned char )c; + if (!is_identchar(uc)) { rb_compile_error("Invalid char `\\%03o' in expression", c); goto retry; } @@ -4414,10 +4428,11 @@ yylex() break; } + uc = (unsigned char )c; do { tokadd(c); - if (ismbchar(c)) { - int i, len = mbclen(c)-1; + if (ismbchar(uc)) { + int i, len = mbclen(uc)-1; for (i = 0; i < len; i++) { c = nextc(); @@ -4425,7 +4440,8 @@ yylex() } } c = nextc(); - } while (is_identchar(c)); + uc = (unsigned char )c; + } while (is_identchar(uc)); if ((c == '!' || c == '?') && is_identchar(tok()[0]) && !peek('=')) { tokadd(c); } --- re.c.orig 2004-04-24 14:34:54.000000000 +0900 +++ re.c 2004-05-28 15:09:50.000000000 +0900 @@ -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; } @@ -1733,8 +1734,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++; @@ -1762,8 +1763,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++; @@ -2002,7 +2003,8 @@ 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; @@ -2011,12 +2013,12 @@ rb_reg_regsub(str, src, regs) 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); @@ -2026,12 +2028,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;