summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-04 01:20:51 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-04 01:20:51 +0000
commitd55db6b999396639b660c25a8680bcb984db878f (patch)
tree58af38aca9f76e68ee11d008cf95bedf9bf3bac9 /string.c
parent5a571ee064e26b73121359e4b52590a5c21be331 (diff)
* gc.c (gc_mark): enable GC stack checking.
* string.c (str_gsub): lock strings temporarily. [ruby-dev:24687] * ext/socket/socket.c (s_recvfrom): tmplock input buffer. [ruby-dev:24705] * array.c (rb_ary_uniq_bang): do not push frozen string from hash table. [ruby-dev:24695] * array.c (rb_ary_and): ditto. * array.c (rb_ary_or): ditto. * ext/enumerator/enumerator.c (each_cons_i): pass copy of an internal consequent array. [ruby-talk:118691] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/string.c b/string.c
index 8a8a0d4..48cd779 100644
--- a/string.c
+++ b/string.c
@@ -464,6 +464,7 @@ str_independent(str)
VALUE str;
{
if (FL_TEST(str, STR_TMPLOCK)) {
+ FL_UNSET(str, STR_TMPLOCK);
rb_raise(rb_eRuntimeError, "can't modify string; temporarily locked");
}
if (OBJ_FROZEN(str)) rb_error_frozen("string");
@@ -2064,6 +2065,8 @@ str_gsub(argc, argv, str, bang)
bp = buf;
cp = RSTRING(str)->ptr;
+ rb_str_locktmp(str);
+ rb_str_locktmp(dest);
while (beg >= 0) {
n++;
match = rb_backref_get();
@@ -2121,6 +2124,8 @@ str_gsub(argc, argv, str, bang)
}
rb_backref_set(match);
*bp = '\0';
+ rb_str_unlocktmp(str);
+ rb_str_unlocktmp(dest);
if (bang) {
if (str_independent(str)) {
free(RSTRING(str)->ptr);
@@ -4417,7 +4422,7 @@ rb_str_sum(argc, argv, str)
return sum;
}
else {
- unsigned int sum = 0;
+ unsigned long sum = 0;
while (p < pend) {
str_mod_check(str, ptr, len);
@@ -4425,7 +4430,7 @@ rb_str_sum(argc, argv, str)
p++;
}
if (bits != 0) {
- sum &= (1<<bits)-1;
+ sum &= (((unsigned long)1)<<bits)-1;
}
return rb_int2inum(sum);
}