summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-06 03:09:03 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-06 03:09:03 +0000
commit6b7b84edc7168786408b0757e2eb53728d1b71a6 (patch)
tree299c41408ef82854a829327d1f8d5c4cc8cf6a8c /string.c
parent53118356b53259b456aabc11fb1212d965251fc4 (diff)
new exception model
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/string.c b/string.c
index f94e457cefe..f355f8e5975 100644
--- a/string.c
+++ b/string.c
@@ -106,8 +106,8 @@ str_new4(orig)
}
}
-static VALUE
-to_str(str)
+VALUE
+str_to_str(str)
VALUE str;
{
return rb_convert_type(str, T_STRING, "String", "to_str");
@@ -173,7 +173,7 @@ str_dup(str)
{
VALUE s;
- str = to_str(str);
+ str = str_to_str(str);
s = str_new(RSTRING(str)->ptr, RSTRING(str)->len);
if (str_tainted(str)) s = str_taint(s);
if (RSTRING(str)->orig && FL_TEST(str, STR_NO_ORIG))
@@ -228,7 +228,7 @@ str_plus(str1, str2)
{
VALUE str3;
- str2 = to_str(str2);
+ str2 = str_to_str(str2);
str3 = str_new(0, RSTRING(str1)->len+RSTRING(str2)->len);
memcpy(RSTRING(str3)->ptr, RSTRING(str1)->ptr, RSTRING(str1)->len);
memcpy(RSTRING(str3)->ptr+RSTRING(str1)->len, RSTRING(str2)->ptr, RSTRING(str2)->len);
@@ -449,7 +449,7 @@ VALUE
str_concat(str1, str2)
VALUE str1, str2;
{
- str2 = to_str(str2);
+ str2 = str_to_str(str2);
str_cat(str1, RSTRING(str2)->ptr, RSTRING(str2)->len);
return str1;
}
@@ -530,7 +530,7 @@ str_cmp_method(str1, str2)
{
int result;
- str2 = to_str(str2);
+ str2 = str_to_str(str2);
result = str_cmp(str1, str2);
return INT2FIX(result);
}
@@ -607,7 +607,7 @@ str_index_method(argc, argv, str)
switch (TYPE(sub)) {
case T_REGEXP:
- pos = reg_search(sub, str, pos, (struct re_registers *)-1);
+ pos = reg_search(sub, str, pos, 0);
break;
case T_STRING:
@@ -655,11 +655,7 @@ str_rindex(argc, argv, str)
switch (TYPE(sub)) {
case T_REGEXP:
- reg_prepare_re(sub);
- pos = re_search(RREGEXP(sub)->ptr,
- RSTRING(str)->ptr, RSTRING(str)->len,
- pos, -pos, 0);
- kcode_reset_option();
+ pos = reg_search(sub, str, pos, 1);
if (pos >= 0) return INT2FIX(pos);
break;
@@ -770,7 +766,7 @@ str_upto(beg, end)
{
VALUE current;
- end = to_str(end);
+ end = str_to_str(end);
if (RTEST(rb_funcall(beg, '>', 1, end)))
return Qnil;
@@ -1120,7 +1116,7 @@ str_aset_method(argc, argv, str)
if (rb_scan_args(argc, argv, "21", &arg1, &arg2, &arg3) == 3) {
int beg, len;
- arg3 = to_str(arg3);
+ arg3 = str_to_str(arg3);
beg = NUM2INT(arg1);
if (beg < 0) {
beg = RSTRING(str)->len + beg;
@@ -1205,7 +1201,7 @@ static VALUE
str_replace_method(str, str2)
VALUE str, str2;
{
- str2 = to_str(str2);
+ str2 = str_to_str(str2);
str_modify(str);
str_resize(str, RSTRING(str2)->len);
memcpy(RSTRING(str)->ptr, RSTRING(str2)->ptr, RSTRING(str2)->len);
@@ -1353,7 +1349,7 @@ str_include(str, arg)
return FALSE;
}
- i = str_index(str, to_str(arg), 0);
+ i = str_index(str, str_to_str(arg), 0);
if (i == -1) return FALSE;
return INT2FIX(i);
@@ -1755,13 +1751,13 @@ tr_trans(str, src, repl, sflag)
UCHAR *s, *send;
str_modify(str);
- src = to_str(src);
+ src = str_to_str(src);
trsrc.p = RSTRING(src)->ptr; trsrc.pend = trsrc.p + RSTRING(src)->len;
if (RSTRING(src)->len > 2 && RSTRING(src)->ptr[0] == '^') {
cflag++;
trsrc.p++;
}
- repl = to_str(repl);
+ repl = str_to_str(repl);
if (RSTRING(repl)->len == 0) return str_delete_bang(str, src);
trrepl.p = RSTRING(repl)->ptr;
trrepl.pend = trrepl.p + RSTRING(repl)->len;
@@ -1890,7 +1886,7 @@ str_delete_bang(str1, str2)
UCHAR squeez[256];
int modify = 0;
- str2 = to_str(str2);
+ str2 = str_to_str(str2);
tr_setup_table(str2, squeez);
str_modify(str1);
@@ -1968,7 +1964,7 @@ str_squeeze_bang(argc, argv, str1)
VALUE str2;
if (rb_scan_args(argc, argv, "01", &str2) == 1) {
- str2 = to_str(str2);
+ str2 = str_to_str(str2);
}
return tr_squeeze(str1, str2);
}
@@ -2145,7 +2141,7 @@ str_split(str, sep0)
{
VALUE sep;
- str = to_str(str);
+ str = str_to_str(str);
sep = str_new2(sep0);
return str_split_method(1, &sep, str);
}
@@ -2180,7 +2176,7 @@ str_each_line(argc, argv, str)
rb_yield(str);
return Qnil;
}
- rs = to_str(rs);
+ rs = str_to_str(rs);
rslen = RSTRING(rs)->len;
if (rslen == 0) {
@@ -2293,7 +2289,7 @@ str_chomp_bang(argc, argv, str)
}
if (NIL_P(rs)) return Qnil;
- rs = to_str(rs);
+ rs = str_to_str(rs);
rslen = RSTRING(rs)->len;
if (rslen == 0) {
while (len>0 && p[len-1] == '\n') {
@@ -2490,7 +2486,7 @@ str_crypt(str, salt)
{
extern char *crypt();
- salt = to_str(salt);
+ salt = str_to_str(salt);
if (RSTRING(salt)->len < 2)
ArgError("salt too short(need >2 bytes)");
return str_new2(crypt(RSTRING(str)->ptr, RSTRING(salt)->ptr));