summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/string.c b/string.c
index f7366cf99a..3214c20adb 100644
--- a/string.c
+++ b/string.c
@@ -112,9 +112,10 @@ rb_str_new4(orig)
str->ptr = RSTRING(orig)->ptr;
RSTRING(orig)->orig = (VALUE)str;
str->orig = 0;
- if (FL_TEST(str, FL_TAINT)) {
+ if (FL_TEST(orig, FL_TAINT)) {
FL_SET(str, FL_TAINT);
}
+ FL_SET(str, STR_FREEZE);
return (VALUE)str;
}
}
@@ -756,6 +757,7 @@ rb_str_upto(beg, end, excl)
int excl;
{
VALUE current;
+ ID succ = rb_intern("succ");
if (TYPE(end) != T_STRING) end = rb_str_to_str(end);
@@ -763,7 +765,7 @@ rb_str_upto(beg, end, excl)
while (rb_str_cmp(current, end) <= 0) {
rb_yield(current);
if (!excl && rb_str_equal(current, end)) break;
- current = rb_str_succ(current);
+ current = rb_funcall(current, succ, 0, 0);
if (excl && rb_str_equal(current, end)) break;
if (RSTRING(current)->len > RSTRING(end)->len)
break;
@@ -1110,7 +1112,7 @@ rb_str_gsub_bang(argc, argv, str)
* Always consume at least one character of the input string
* in order to prevent infinite loops.
*/
- len = mbclen(RSTRING(str)->ptr[END(0)]);
+ len = mbclen2(RSTRING(str)->ptr[END(0)], pat);
if (RSTRING(str)->len > END(0)) {
memcpy(bp, RSTRING(str)->ptr+END(0), len);
bp += len;
@@ -1343,12 +1345,6 @@ rb_str_inspect(str)
*b++ = *p++;
}
}
-#if 0
- else if ((c & 0x80) && rb_kcode() != MBCTYPE_EUC) {
- CHECK(1);
- *b++ = c;
- }
-#endif
else if (c == '"'|| c == '\\') {
CHECK(2);
*b++ = '\\';
@@ -2069,6 +2065,7 @@ rb_str_split_method(argc, argv, str)
if (!NIL_P(limit) && lim <= ++i) break;
}
end++;
+ if (ismbchar(*ptr)) ptr++;
}
}
}
@@ -2082,11 +2079,11 @@ rb_str_split_method(argc, argv, str)
regs = RMATCH(rb_backref_get())->regs;
if (start == end && BEG(0) == END(0)) {
if (last_null == 1) {
- rb_ary_push(result, rb_str_substr(str, beg, mbclen(RSTRING(str)->ptr[beg])));
+ rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat)));
beg = start;
}
else {
- start += mbclen(RSTRING(str)->ptr[start]);
+ start += mbclen2(RSTRING(str)->ptr[start],spat);
last_null = 1;
continue;
}
@@ -2396,7 +2393,7 @@ scan_once(str, pat, start)
/*
* Always consume at least one character of the input string
*/
- *start = END(0)+mbclen(RSTRING(str)->ptr[END(0)]);
+ *start = END(0)+mbclen2(RSTRING(str)->ptr[END(0)],pat);
}
else {
*start = END(0);