1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

regex initialize bug

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-05-23 15:36:43 +00:00
parent bdd3b79fe1
commit 24b9bdca25

33
re.c
View file

@ -774,10 +774,10 @@ rb_reg_initialize(obj, s, len, options)
int options; /* CASEFOLD = 1 */ int options; /* CASEFOLD = 1 */
/* EXTENDED = 2 */ /* EXTENDED = 2 */
/* MULTILINE = 4 */ /* MULTILINE = 4 */
/* CODE_NONE = 8 */ /* CODE_NONE = 16 */
/* CODE_EUC = 16 */ /* CODE_EUC = 32 */
/* CODE_SJIS = 24 */ /* CODE_SJIS = 48 */
/* CODE_UTF8 = 32 */ /* CODE_UTF8 = 64 */
{ {
struct RRegexp *re = RREGEXP(obj); struct RRegexp *re = RREGEXP(obj);
@ -786,7 +786,7 @@ rb_reg_initialize(obj, s, len, options)
re->ptr = 0; re->ptr = 0;
re->str = 0; re->str = 0;
switch (options & ~0x7) { switch (options & ~0xf) {
case 0: case 0:
default: default:
FL_SET(re, reg_kcode); FL_SET(re, reg_kcode);
@ -950,16 +950,16 @@ rb_reg_initialize_m(argc, argv, self)
switch (kcode[0]) { switch (kcode[0]) {
case 'n': case 'N': case 'n': case 'N':
flag |= 8;
break;
case 'e': case 'E':
flag |= 16; flag |= 16;
break; break;
case 'e': case 'E':
flag |= 32;
break;
case 's': case 'S': case 's': case 'S':
flag |= 24; flag |= 48;
break; break;
case 'u': case 'U': case 'u': case 'U':
flag |= 32; flag |= 64;
break; break;
default: default:
break; break;
@ -988,6 +988,7 @@ rb_reg_s_new(argc, argv, klass)
{ {
NEWOBJ(re, struct RRegexp); NEWOBJ(re, struct RRegexp);
OBJSETUP(re, klass, T_REGEXP); OBJSETUP(re, klass, T_REGEXP);
re->ptr = 0; re->len = 0;
rb_obj_call_init((VALUE)re, argc, argv); rb_obj_call_init((VALUE)re, argc, argv);
return (VALUE)re; return (VALUE)re;
} }
@ -1063,13 +1064,13 @@ rb_reg_get_kcode(re)
switch (RBASIC(re)->flags & KCODE_MASK) { switch (RBASIC(re)->flags & KCODE_MASK) {
case KCODE_NONE: case KCODE_NONE:
kcode |= 4; break;
case KCODE_EUC:
kcode |= 8; break;
case KCODE_SJIS:
kcode |= 12; break;
case KCODE_UTF8:
kcode |= 16; break; kcode |= 16; break;
case KCODE_EUC:
kcode |= 32; break;
case KCODE_SJIS:
kcode |= 48; break;
case KCODE_UTF8:
kcode |= 64; break;
default: default:
break; break;
} }