summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog25
-rw-r--r--array.c22
-rw-r--r--ext/enumerator/enumerator.c13
-rw-r--r--ext/socket/socket.c2
-rw-r--r--gc.c6
-rw-r--r--lib/irb/ruby-lex.rb3
-rw-r--r--string.c9
7 files changed, 56 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index bdc7632..588a997 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Thu Nov 4 09:11:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (gc_mark): enable GC stack checking.
+
+Thu Nov 4 03:11:33 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (str_gsub): lock strings temporarily. [ruby-dev:24687]
+
+ * ext/socket/socket.c (s_recvfrom): tmplock input buffer.
+ [ruby-dev:24705]
+
Wed Nov 3 22:32:12 2004 NARUSE, Yui <naruse@ruby-lang.org>
* process.c: On NetBSD don't use setruid() and setrgid().
@@ -7,6 +18,15 @@ Wed Nov 3 22:24:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpauth/digestauth.rb: use Base64.encode64 to
avoid warnings.
+Wed Nov 3 17:19:59 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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.
+
Wed Nov 3 17:13:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* io.c (pipe_open): fix compile error
@@ -39,6 +59,11 @@ Wed Nov 3 15:53:34 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/maker/*.rb: ditto.
+Tue Nov 2 16:35:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/enumerator/enumerator.c (each_cons_i): pass copy of an
+ internal consequent array. [ruby-talk:118691]
+
Tue Nov 2 16:05:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (rb_f_fork): need to flush stdout and stderr before
diff --git a/array.c b/array.c
index 860cd64..03647f8 100644
--- a/array.c
+++ b/array.c
@@ -2677,7 +2677,7 @@ static VALUE
rb_ary_and(ary1, ary2)
VALUE ary1, ary2;
{
- VALUE hash, ary3;
+ VALUE hash, ary3, v, vv;
long i;
ary2 = to_ary(ary2);
@@ -2686,8 +2686,8 @@ rb_ary_and(ary1, ary2)
hash = ary_make_hash(ary2, 0);
for (i=0; i<RARRAY(ary1)->len; i++) {
- VALUE v = rb_ary_elt(ary1, i);
- if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
+ v = vv = rb_ary_elt(ary1, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -2711,7 +2711,7 @@ rb_ary_or(ary1, ary2)
VALUE ary1, ary2;
{
VALUE hash, ary3;
- VALUE v;
+ VALUE v, vv;
long i;
ary2 = to_ary(ary2);
@@ -2719,14 +2719,14 @@ rb_ary_or(ary1, ary2)
hash = ary_make_hash(ary1, ary2);
for (i=0; i<RARRAY(ary1)->len; i++) {
- v = rb_ary_elt(ary1, i);
- if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
+ v = vv = rb_ary_elt(ary1, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
for (i=0; i<RARRAY(ary2)->len; i++) {
- v = rb_ary_elt(ary2, i);
- if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
+ v = vv = rb_ary_elt(ary2, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -2751,7 +2751,7 @@ static VALUE
rb_ary_uniq_bang(ary)
VALUE ary;
{
- VALUE hash;
+ VALUE hash, v, vv;
long i, j;
rb_ary_modify(ary);
@@ -2762,8 +2762,8 @@ rb_ary_uniq_bang(ary)
return Qnil;
}
for (i=j=0; i<RARRAY(ary)->len; i++) {
- VALUE v = rb_ary_elt(ary, i);
- if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
+ v = vv = rb_ary_elt(ary, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_store(ary, j++, v);
}
}
diff --git a/ext/enumerator/enumerator.c b/ext/enumerator/enumerator.c
index 6e47330..7478556 100644
--- a/ext/enumerator/enumerator.c
+++ b/ext/enumerator/enumerator.c
@@ -87,15 +87,13 @@ each_cons_i(val, memo)
{
VALUE ary = memo->u1.value;
long size = memo->u3.cnt;
- long len = RARRAY(ary)->len;
- if (len == size) {
+ if (RARRAY(ary)->len == size) {
rb_ary_shift(ary);
- rb_ary_push(ary, val);
- rb_yield(ary);
- } else {
- rb_ary_push(ary, val);
- if (len + 1 == size) rb_yield(ary);
+ }
+ rb_ary_push(ary, val);
+ if (RARRAY(ary)->len == size) {
+ rb_yield(rb_ary_dup(ary));
}
return Qnil;
}
@@ -106,7 +104,6 @@ enum_each_cons(obj, n)
{
long size = NUM2LONG(n);
NODE *memo;
- VALUE ary;
if (size <= 0) rb_raise(rb_eArgError, "invalid size");
memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 624ea9f..1df7cb9 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -436,10 +436,12 @@ s_recvfrom(sock, argc, argv, from)
str = rb_tainted_str_new(0, buflen);
retry:
+ rb_str_locktmp(str);
rb_thread_wait_fd(fd);
TRAP_BEG;
slen = recvfrom(fd, RSTRING(str)->ptr, buflen, flags, (struct sockaddr*)buf, &alen);
TRAP_END;
+ rb_str_unlocktmp(str);
if (slen < 0) {
if (rb_io_wait_readable(fd)) {
diff --git a/gc.c b/gc.c
index f507872..912d2ca 100644
--- a/gc.c
+++ b/gc.c
@@ -645,7 +645,7 @@ mark_tbl(tbl, lev)
int lev;
{
if (!tbl) return;
- st_foreach(tbl, mark_entry, lev+1);
+ st_foreach(tbl, mark_entry, lev);
}
void
@@ -672,7 +672,7 @@ mark_hash(tbl, lev)
int lev;
{
if (!tbl) return;
- st_foreach(tbl, mark_keyvalue, lev+1);
+ st_foreach(tbl, mark_keyvalue, lev);
}
void
@@ -718,7 +718,7 @@ gc_mark(ptr, lev)
}
return;
}
- gc_mark_children(ptr, lev);
+ gc_mark_children(ptr, lev+1);
}
void
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 5a1ede7..e25af30 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -55,6 +55,9 @@ class RubyLex
@skip_space = false
@readed_auto_clean_up = false
@exception_on_syntax_error = true
+ @prompt = nil
+ @here_header = nil
+ @lex_state = nil
end
attr_accessor :skip_space
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);
}