summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-26 09:45:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-26 09:45:09 +0000
commit05da25f297c4d26b6bb454a9649b1dd63a102910 (patch)
tree568d1118ca9c2c7bfbcaf2d2132a7e870367d407 /re.c
parent839f4c5f3fdb4ea6b270fce17f1c3881060087d4 (diff)
980626
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/re.c b/re.c
index 8e2f6ec7a0..d9962cb1f1 100644
--- a/re.c
+++ b/re.c
@@ -629,7 +629,7 @@ reg_new_1(klass, s, len, options)
re->ptr = 0;
re->str = 0;
- if (options & 0x1) {
+ if (options & RE_OPTION_IGNORECASE) {
FL_SET(re, REG_IGNORECASE);
}
switch (options & ~0x3) {
@@ -763,19 +763,21 @@ reg_s_new(argc, argv, self)
ArgError("wrong # of argument");
}
if (argc >= 2 && RTEST(argv[1])) {
- flag = 1;
+ flag = RE_OPTION_IGNORECASE;
}
if (argc == 3) {
- Check_Type(argv[2], T_STRING);
- switch (RSTRING(argv[2])->ptr[0]) {
+ char *kcode = STR2CSTR(argv[2]);
+
+ if (!kcode) TypeError("wrong char-code");
+ switch (kcode[0]) {
case 'n': case 'N':
- flag |= 2;
+ flag |= 4;
break;
case 'e': case 'E':
- flag |= 4;
+ flag |= 8;
break;
case 's': case 'S':
- flag |= 6;
+ flag |= 12;
break;
default:
break;
@@ -801,12 +803,11 @@ reg_s_quote(re, str)
{
char *s, *send, *t;
char *tmp;
+ int len;
- Check_Type(str, T_STRING);
-
- tmp = ALLOCA_N(char, RSTRING(str)->len*2);
-
- s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
+ s = str2cstr(str, &len);
+ send = s + len;
+ tmp = ALLOCA_N(char, len*2);
t = tmp;
for (; s != send; s++) {