Skip to content

Commit

Permalink
* string.c (rb_str_update): call rb_str_modify().
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Dec 25, 2003
1 parent 33e05ba commit f7d46c8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Thu Dec 25 15:30:17 2003 Yukihiro Matsumoto <[email protected]>

* string.c (rb_str_update): call rb_str_modify().

Thu Dec 25 05:08:09 2003 Nobuyoshi Nakada <[email protected]>

* eval.c (search_required): search actual file name once when no
Expand Down
7 changes: 1 addition & 6 deletions dln.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,12 +1115,7 @@ dln_sym(name)
#endif /* USE_DLN_A_OUT */

#ifdef USE_DLN_DLOPEN
# ifdef __NetBSD__
# include <nlist.h>
# include <link.h>
# else
# include <dlfcn.h>
# endif
# include <dlfcn.h>
#endif

#ifdef __hpux
Expand Down
2 changes: 1 addition & 1 deletion ext/tcltklib/tcltklib.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ ip_ruby(clientData, interp, argc, argv)

/* status check */
if (arg.failed) {
VALUE eclass = CLASS_OF(arg.failed);
VALUE eclass = rb_obj_class(arg.failed);
DUMP1("(rb_eval_string result) failed");
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, StringValuePtr(arg.failed), (char*)NULL);
Expand Down
26 changes: 18 additions & 8 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -1579,8 +1579,8 @@ rb_str_aref_m(argc, argv, str)
return rb_str_aref(str, argv[0]);
}

void
rb_str_update(str, beg, len, val)
static void
rb_str_splice(str, beg, len, val)
VALUE str;
long beg, len;
VALUE val;
Expand Down Expand Up @@ -1624,6 +1624,16 @@ rb_str_update(str, beg, len, val)
OBJ_INFECT(str, val);
}

void
rb_str_update(str, beg, len, val)
VALUE str;
long beg, len;
VALUE val;
{
rb_str_modify(str);
return rb_str_splice(str, beg, len, val);
}

static void
rb_str_subpat_set(str, re, nth, val)
VALUE str, re;
Expand Down Expand Up @@ -1655,7 +1665,7 @@ rb_str_subpat_set(str, re, nth, val)
end = RMATCH(match)->END(nth);
len = end - start;
rb_str_modify(str);
rb_str_update(str, start, len, val);
rb_str_splice(str, start, len, val);
}

static VALUE
Expand Down Expand Up @@ -1686,7 +1696,7 @@ rb_str_aset(str, indx, val)
RSTRING(str)->ptr[idx] = NUM2INT(val) & 0xff;
}
else {
rb_str_update(str, idx, 1, val);
rb_str_splice(str, idx, 1, val);
}
return val;

Expand All @@ -1699,15 +1709,15 @@ rb_str_aset(str, indx, val)
if (beg < 0) {
rb_raise(rb_eIndexError, "string not matched");
}
rb_str_update(str, beg, RSTRING(indx)->len, val);
rb_str_splice(str, beg, RSTRING(indx)->len, val);
return val;

default:
/* check if indx is Range */
{
long beg, len;
if (rb_range_beg_len(indx, &beg, &len, RSTRING(str)->len, 2)) {
rb_str_update(str, beg, len, val);
rb_str_splice(str, beg, len, val);
return val;
}
}
Expand Down Expand Up @@ -1753,7 +1763,7 @@ rb_str_aset_m(argc, argv, str)
rb_str_subpat_set(str, argv[0], NUM2INT(argv[1]), argv[2]);
}
else {
rb_str_update(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
rb_str_splice(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
}
return argv[2];
}
Expand Down Expand Up @@ -1793,7 +1803,7 @@ rb_str_insert(str, idx, str2)
else if (pos < 0) {
pos++;
}
rb_str_update(str, pos, 0, str2);
rb_str_splice(str, pos, 0, str2);
return str;
}

Expand Down

0 comments on commit f7d46c8

Please sign in to comment.