summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-05-23 15:36:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-05-23 15:36:43 +0000
commit24b9bdca25dc431aff935df7739b9c5ea0ee4077 (patch)
tree6eac9299555b2423f38ee3c5d167b3143e66516f
parentbdd3b79fe1ea00530c1a0d69ef1d8c5ec404b2da (diff)
regex initialize bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--re.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/re.c b/re.c
index ef1614d..4b14001 100644
--- a/re.c
+++ b/re.c
@@ -774,10 +774,10 @@ rb_reg_initialize(obj, s, len, options)
int options; /* CASEFOLD = 1 */
/* EXTENDED = 2 */
/* MULTILINE = 4 */
- /* CODE_NONE = 8 */
- /* CODE_EUC = 16 */
- /* CODE_SJIS = 24 */
- /* CODE_UTF8 = 32 */
+ /* CODE_NONE = 16 */
+ /* CODE_EUC = 32 */
+ /* CODE_SJIS = 48 */
+ /* CODE_UTF8 = 64 */
{
struct RRegexp *re = RREGEXP(obj);
@@ -786,7 +786,7 @@ rb_reg_initialize(obj, s, len, options)
re->ptr = 0;
re->str = 0;
- switch (options & ~0x7) {
+ switch (options & ~0xf) {
case 0:
default:
FL_SET(re, reg_kcode);
@@ -950,16 +950,16 @@ rb_reg_initialize_m(argc, argv, self)
switch (kcode[0]) {
case 'n': case 'N':
- flag |= 8;
+ flag |= 16;
break;
case 'e': case 'E':
- flag |= 16;
+ flag |= 32;
break;
case 's': case 'S':
- flag |= 24;
+ flag |= 48;
break;
case 'u': case 'U':
- flag |= 32;
+ flag |= 64;
break;
default:
break;
@@ -988,6 +988,7 @@ rb_reg_s_new(argc, argv, klass)
{
NEWOBJ(re, struct RRegexp);
OBJSETUP(re, klass, T_REGEXP);
+ re->ptr = 0; re->len = 0;
rb_obj_call_init((VALUE)re, argc, argv);
return (VALUE)re;
}
@@ -1063,13 +1064,13 @@ rb_reg_get_kcode(re)
switch (RBASIC(re)->flags & KCODE_MASK) {
case KCODE_NONE:
- kcode |= 4; break;
+ kcode |= 16; break;
case KCODE_EUC:
- kcode |= 8; break;
+ kcode |= 32; break;
case KCODE_SJIS:
- kcode |= 12; break;
+ kcode |= 48; break;
case KCODE_UTF8:
- kcode |= 16; break;
+ kcode |= 64; break;
default:
break;
}