Skip to content

Commit c492b9b

Browse files
author
matz
committed
* eval.c (mark_frame_adj): need to adjust argv pointer if using
system's alloca. [ruby-core:01503] * io.c (rb_f_gets): should call next_argv() before type check current_file. [ruby-list:38336] * eval.c (proc_invoke): should retrieve retval when pcall is true. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 4198feb commit c492b9b

File tree

5 files changed

+60
-28
lines changed

5 files changed

+60
-28
lines changed

ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ Thu Sep 4 12:54:50 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
101101
* ext/syck/token.c: headerless documents with root-level spacing now
102102
honored.
103103

104+
Thu Sep 4 00:06:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
105+
106+
* eval.c (mark_frame_adj): need to adjust argv pointer if using
107+
system's alloca. [ruby-core:01503]
108+
104109
Wed Sep 3 21:33:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
105110

106111
* test: add test directory. Test::Unit aware testcases and needed
@@ -112,11 +117,20 @@ Wed Sep 3 21:33:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
112117

113118
* test/csv/*: add testcase for lib/csv.rb.
114119

120+
Wed Sep 3 01:37:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
121+
122+
* io.c (rb_f_gets): should call next_argv() before type check
123+
current_file. [ruby-list:38336]
124+
115125
Tue Sep 2 20:37:15 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
116126

117127
* ext/openssl/lib/net/protocols.rb (SSLIO#ssl_connect): warning
118128
for skipping server verification.
119129

130+
Tue Sep 2 23:36:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
131+
132+
* eval.c (proc_invoke): should retrieve retval when pcall is true.
133+
120134
Tue Sep 2 14:09:20 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
121135

122136
* ext/socket/extconf.rb: check s6_addr8 in in6_addr (Tru64 UNIX).

array.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,17 +1095,16 @@ rb_ary_reverse(ary)
10951095
VALUE tmp;
10961096

10971097
rb_ary_modify(ary);
1098-
if (RARRAY(ary)->len <= 1) return ary;
1099-
1100-
p1 = RARRAY(ary)->ptr;
1101-
p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
1102-
1103-
while (p1 < p2) {
1104-
tmp = *p1;
1105-
*p1++ = *p2;
1106-
*p2-- = tmp;
1098+
if (RARRAY(ary)->len > 1) {
1099+
p1 = RARRAY(ary)->ptr;
1100+
p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
1101+
1102+
while (p1 < p2) {
1103+
tmp = *p1;
1104+
*p1++ = *p2;
1105+
*p2-- = tmp;
1106+
}
11071107
}
1108-
11091108
return ary;
11101109
}
11111110

@@ -1173,10 +1172,10 @@ rb_ary_sort_bang(ary)
11731172
VALUE ary;
11741173
{
11751174
rb_ary_modify(ary);
1176-
if (RARRAY(ary)->len <= 1) return ary;
1177-
1178-
FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
1179-
rb_ensure(sort_internal, ary, sort_unlock, ary);
1175+
if (RARRAY(ary)->len > 1) {
1176+
FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
1177+
rb_ensure(sort_internal, ary, sort_unlock, ary);
1178+
}
11801179
return ary;
11811180
}
11821181

eval.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7023,7 +7023,7 @@ proc_invoke(proc, args, self, klass)
70237023
proc_set_safe_level(proc);
70247024
result = rb_yield_0(args, self, self!=Qundef?CLASS_OF(self):0, pcall, Qtrue);
70257025
}
7026-
else if (TAG_DST()) {
7026+
else if (pcall || TAG_DST()) {
70277027
result = prot_tag->retval;
70287028
}
70297029
POP_TAG();
@@ -8043,6 +8043,25 @@ timeofday()
80438043

80448044
#define STACK(addr) (th->stk_pos<(VALUE*)(addr) && (VALUE*)(addr)<th->stk_pos+th->stk_len)
80458045
#define ADJ(addr) (void*)(STACK(addr)?(((VALUE*)(addr)-th->stk_pos)+th->stk_ptr):(VALUE*)(addr))
8046+
#ifdef C_ALLOCA
8047+
# define MARK_FRAME_ADJ(f) rb_gc_mark_frame(f)
8048+
#else
8049+
# define MARK_FRAME_ADJ(f) mark_frame_adj(f, th)
8050+
static void
8051+
mark_frame_adj(frame, th)
8052+
struct FRAME *frame;
8053+
rb_thread_t th;
8054+
{
8055+
if (frame->flags & FRAME_MALLOC) {
8056+
rb_gc_mark_locations(frame->argv, frame->argv+frame->argc);
8057+
}
8058+
else {
8059+
VALUE *start = ADJ(frame->argv);
8060+
rb_gc_mark_locations(start, start+frame->argc);
8061+
}
8062+
rb_gc_mark((VALUE)frame->node);
8063+
}
8064+
#endif
80468065

80478066
static void
80488067
thread_mark(th)
@@ -8084,13 +8103,13 @@ thread_mark(th)
80848103
frame = th->frame;
80858104
while (frame && frame != top_frame) {
80868105
frame = ADJ(frame);
8087-
rb_gc_mark_frame(frame);
8106+
MARK_FRAME_ADJ(frame);
80888107
if (frame->tmp) {
80898108
struct FRAME *tmp = frame->tmp;
80908109

80918110
while (tmp && tmp != top_frame) {
80928111
tmp = ADJ(tmp);
8093-
rb_gc_mark_frame(tmp);
8112+
MARK_FRAME_ADJ(tmp);
80948113
tmp = tmp->prev;
80958114
}
80968115
}
@@ -8099,7 +8118,7 @@ thread_mark(th)
80998118
block = th->block;
81008119
while (block) {
81018120
block = ADJ(block);
8102-
rb_gc_mark_frame(&block->frame);
8121+
MARK_FRAME_ADJ(&block->frame);
81038122
block = block->prev;
81048123
}
81058124
}

io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3115,8 +3115,8 @@ rb_f_gets(argc, argv)
31153115
{
31163116
VALUE line;
31173117

3118+
if (!next_argv()) return Qnil;
31183119
if (TYPE(current_file) != T_FILE) {
3119-
if (!next_argv()) return Qnil;
31203120
line = rb_funcall3(current_file, rb_intern("gets"), argc, argv);
31213121
}
31223122
else {

string.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,16 +1807,16 @@ rb_str_reverse_bang(str)
18071807
char *s, *e;
18081808
char c;
18091809

1810-
if (RSTRING(str)->len <= 1) return Qnil;
1811-
rb_str_modify(str);
1812-
s = RSTRING(str)->ptr;
1813-
e = s + RSTRING(str)->len - 1;
1814-
while (s < e) {
1815-
c = *s;
1816-
*s++ = *e;
1817-
*e-- = c;
1810+
if (RSTRING(str)->len > 1) {
1811+
rb_str_modify(str);
1812+
s = RSTRING(str)->ptr;
1813+
e = s + RSTRING(str)->len - 1;
1814+
while (s < e) {
1815+
c = *s;
1816+
*s++ = *e;
1817+
*e-- = c;
1818+
}
18181819
}
1819-
18201820
return str;
18211821
}
18221822

0 commit comments

Comments
 (0)