Skip to content

Commit

Permalink
* eval.c (proc_call): should not modify ruby_block->frame.iter
Browse files Browse the repository at this point in the history
  based on ruby_frame->iter altered by PUSH_ITER().

* eval.c (rb_thread_fd_close): should save current context before
  raising exception.

* io.c (set_stdin): preserve original stdin.

* io.c (set_outfile): preserve original stdout/stderr.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Feb 26, 2001
1 parent 69739b1 commit df2d69b
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 78 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon Feb 26 00:04:52 2001 Yukihiro Matsumoto <[email protected]>

* eval.c (proc_call): should not modify ruby_block->frame.iter
based on ruby_frame->iter altered by PUSH_ITER().

Mon Feb 26 05:27:52 2001 Wakou Aoyama <[email protected]>

* lib/net/telnet.rb: #telnetmode(), #binmode(): bug fix.
Expand All @@ -18,6 +23,11 @@ Sun Feb 25 02:45:30 2001 WATANABE Hirofumi <[email protected]>

* file.c (rb_file_s_rename): avoid Cygwin's bug.

Sat Feb 24 23:32:55 2001 Yukihiro Matsumoto <[email protected]>

* eval.c (rb_thread_fd_close): should save current context before
raising exception.

Sat Feb 24 22:14:00 2001 WATANABE Hirofumi <[email protected]>

* win32/win32.c (myrename): fix error handling.
Expand All @@ -29,6 +39,12 @@ Sat Feb 24 13:58:48 2001 Minero Aoki <[email protected]>

* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: change copyright.

Sat Feb 24 03:15:49 2001 Yukihiro Matsumoto <[email protected]>

* io.c (set_stdin): preserve original stdin.

* io.c (set_outfile): preserve original stdout/stderr.

Fri Feb 23 08:28:58 2001 Minero Aoki <[email protected]>

* lib/net/protocol.rb: clear read buffer after reopen.
Expand Down
1 change: 1 addition & 0 deletions ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Standard Libraries
* Hash::new{default} or recommend Hash#fetch?
* new user-defined marshal scheme. _dump(dumper), _load(restorer)
* warn, warning for Ruby level
* hash etc. should handle self referenceing array/hash

Extension Libraries

Expand Down
10 changes: 2 additions & 8 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,8 @@ rb_ary_push_m(argc, argv, ary)
rb_raise(rb_eArgError, "wrong # of arguments(at least 1)");
}
if (argc > 0) {
long len = RARRAY(ary)->len;

--argc;
/* make rooms by copying the last item */
rb_ary_store(ary, len + argc, argv[argc]);

if (argc) { /* if any rest */
MEMCPY(RARRAY(ary)->ptr + len, argv, VALUE, argc);
while (argc--) {
rb_ary_push(ary, *argv++);
}
}
return ary;
Expand Down
3 changes: 2 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ check(tm, y, m, d, h, s)
struct tm *tm;
int y, m, d, h, s;
{
if (tm->tm_year != y ||
if (!tm ||
tm->tm_year != y ||
tm->tm_mon != m-1 ||
tm->tm_mday != d ||
tm->tm_hour != h ||
Expand Down
2 changes: 1 addition & 1 deletion dln.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ aix_loaderror(const char *pathname)
if (nerr == load_errtab[i].errno && load_errtab[i].errstr)
ERRBUF_APPEND(load_errtab[i].errstr);
}
while (ISDIGIT(*message[i])) message[i]++;
while (isdigit(*message[i])) message[i]++;
ERRBUF_APPEND(message[i]);
ERRBUF_APPEND("\n");
}
Expand Down
61 changes: 19 additions & 42 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3608,24 +3608,6 @@ rb_yield_0(val, self, klass, acheck)
pop_state:
POP_ITER();
POP_CLASS();
#if 0
if (ruby_dyna_vars && (block->flags & BLOCK_D_SCOPE) &&
(!(ruby_scope->flags & SCOPE_DONT_RECYCLE) ||
!(block->tag->flags & BLOCK_DYNAMIC) ||
!FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE))) {
struct RVarmap *vars, *tmp;

if (ruby_dyna_vars->id == 0) {
vars = ruby_dyna_vars->next;
rb_gc_force_recycle((VALUE)ruby_dyna_vars);
while (vars && vars->id != 0) {
tmp = vars->next;
rb_gc_force_recycle((VALUE)vars);
vars = tmp;
}
}
}
#else
if (ruby_dyna_vars && (block->flags & BLOCK_D_SCOPE) &&
!FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE)) {
struct RVarmap *vars = ruby_dyna_vars;
Expand All @@ -3640,7 +3622,6 @@ rb_yield_0(val, self, klass, acheck)
}
}
}
#endif
POP_VARS();
ruby_block = block;
ruby_frame = ruby_frame->prev;
Expand Down Expand Up @@ -6182,7 +6163,7 @@ proc_new(klass)
struct RVarmap *vars;

if (!rb_block_given_p() && !rb_f_block_given_p()) {
rb_raise(rb_eArgError, "tried to create Procedure-Object without a block");
rb_raise(rb_eArgError, "tried to create Proc object without a block");
}

proc = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
Expand Down Expand Up @@ -6280,26 +6261,27 @@ proc_call(proc, args)
Data_Get_Struct(proc, struct BLOCK, data);
orphan = blk_orphan(data);

if (orphan) {/* orphan procedure */
if (rb_block_given_p()) {
ruby_block->frame.iter = ITER_CUR;
}
else {
ruby_block->frame.iter = ITER_NOT;
}
}

/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
ruby_block = &_block;

PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR;

if (args != Qundef && TYPE(args) == T_ARRAY) {
args = callargs(args);
}

if (orphan) {/* orphan procedure */
if (rb_block_given_p()) {
ruby_block->frame.iter = ITER_CUR;
}
else {
ruby_block->frame.iter = ITER_NOT;
}
}

PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
if (state == 0) {
Expand Down Expand Up @@ -6993,6 +6975,8 @@ rb_thread_check(data)
return (rb_thread_t)RDATA(data)->data;
}

static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t));

static int th_raise_argc;
static VALUE th_raise_argv[2];
static char *th_raise_file;
Expand Down Expand Up @@ -7176,20 +7160,15 @@ void
rb_thread_fd_close(fd)
int fd;
{
rb_thread_t th;
rb_thread_t th, curr = curr_thread;

FOREACH_THREAD(th) {
FOREACH_THREAD_FROM(curr, th) {
if ((th->wait_for & WAIT_FD) && fd == th->fd) {
th_raise_argc = 1;
th_raise_argv[0] = rb_exc_new2(rb_eIOError, "stream closed");
th_raise_file = ruby_sourcefile;
th_raise_line = ruby_sourceline;
curr_thread = th;
rb_thread_ready(th);
rb_thread_restore_context(curr_thread, RESTORE_RAISE);
VALUE exc = rb_exc_new2(rb_eIOError, "stream closed");
rb_thread_raise(1, &exc, th);
}
}
END_FOREACH(th);
END_FOREACH_FROM(curr, th);
}

static void
Expand Down Expand Up @@ -7976,8 +7955,6 @@ catch_timer(sig)
int rb_thread_tick = THREAD_TICK;
#endif

static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t));

#define SCOPE_SHARED FL_USER1

#if defined(HAVE_SETITIMER)
Expand Down Expand Up @@ -8460,7 +8437,7 @@ rb_thread_inspect(thread)
void
rb_thread_atfork()
{
#if 0 /* enable on 1.7 */
#if 1 /* enable on 1.7 */
rb_thread_t th;

if (rb_thread_alone()) return;
Expand Down
3 changes: 3 additions & 0 deletions ext/extmk.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ EOS
mfile.print "
.c.@OBJEXT@:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
.cc.@OBJEXT@ .cpp.@OBJEXT@ .cxx.@OBJEXT@ .C.@OBJEXT@:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
"
end

Expand Down
28 changes: 26 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ VALUE rb_eIOError;

VALUE rb_stdin, rb_stdout, rb_stderr, rb_defout;
static VALUE orig_stdin, orig_stdout, orig_stderr;
static int saved_fd[3] = {0, 1, 2};

VALUE rb_output_fs;
VALUE rb_rs;
Expand Down Expand Up @@ -1187,7 +1188,12 @@ rb_io_sysread(io, len)
}
str = rb_str_new(0, ilen);

n = fileno(fptr->f);
rb_thread_wait_fd(fileno(fptr->f));
if (fptr->f == 0) {
fprintf(stderr, "bingo\n");
exit(1);
}
TRAP_BEG;
n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
TRAP_END;
Expand Down Expand Up @@ -2212,7 +2218,15 @@ set_stdin(val, id, var)

GetOpenFile(val, fptr);
rb_io_check_readable(fptr);
dup2(fileno(fptr->f), 0);
if (fileno(fptr->f) == 0 && saved_fd[0] != 0) {
dup2(saved_fd[0], 0);
close(saved_fd[0]);
saved_fd[0] = 0;
}
else {
saved_fd[0] = dup(0);
dup2(fileno(fptr->f), 0);
}

*var = val;
}
Expand All @@ -2226,6 +2240,7 @@ set_outfile(val, var, orig, stdf)
{
OpenFile *fptr;
FILE *f;
int fd;

if (val == *var) return;

Expand All @@ -2243,7 +2258,16 @@ set_outfile(val, var, orig, stdf)
GetOpenFile(val, fptr);
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
dup2(fileno(f), fileno(stdf));
fd = fileno(stdf);
if (fileno(fptr->f) == fd && saved_fd[fd] != fd) {
dup2(saved_fd[fd], fd);
close(saved_fd[fd]);
saved_fd[fd] = fd;
}
else {
saved_fd[fd] = dup(fd);
dup2(fileno(fptr->f), fd);
}

*var = val;
}
Expand Down
14 changes: 1 addition & 13 deletions lib/Env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@
# $USER = "matz"
# p ENV["USER"]

for k,v in ENV
next unless /^[a-zA-Z][_a-zA-Z0-9]*/ =~ k
eval <<EOS
$#{k} = %q!#{v}!
trace_var "$#{k}", proc{|v|
ENV[%q!#{k}!] = v;
$#{k} = %q!#{v}!
if v == nil
untrace_var "$#{k}"
end
}
EOS
end
require 'importenv'

if __FILE__ == $0
p $TERM
Expand Down
1 change: 0 additions & 1 deletion lib/README
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ profile.rb ruby profiler
pstore.rb persistent object strage using marshal
rational.rb rational number support
readbytes.rb define IO#readbytes
shell.rb shell like operation under Ruby (imcomplete)
shellwords.rb split into words like shell
singleton.rb singleton design pattern library
sync.rb 2 phase lock
Expand Down
1 change: 0 additions & 1 deletion lib/importenv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@
$TERM = "foo"
p ENV["TERM"]
end

3 changes: 3 additions & 0 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ def create_makefile(target, srcdir = File.dirname($0))
.c.#{$OBJEXT}:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
.cc.#{$OBJEXT} .cpp.#{$OBJEXT} .cxx.#{$OBJEXT} .C.#{$OBJEXT}:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
"
end

Expand Down
4 changes: 4 additions & 0 deletions missing/flock.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ flock(fd, operation)

/* LOCK_SH - get a shared lock */
case LOCK_SH:
rb_notimplement();
return -1;
/* LOCK_EX - get an exclusive lock */
case LOCK_EX:
i = lockf (fd, F_LOCK, 0);
break;

/* LOCK_SH|LOCK_NB - get a non-blocking shared lock */
case LOCK_SH|LOCK_NB:
rb_notimplement();
return -1;
/* LOCK_EX|LOCK_NB - get a non-blocking exclusive lock */
case LOCK_EX|LOCK_NB:
i = lockf (fd, F_TLOCK, 0);
Expand Down
15 changes: 8 additions & 7 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -1271,18 +1271,19 @@ primary : literal
cref_pop();
class_nest--;
}
| kCLASS tLSHFT expr term
| kCLASS tLSHFT expr
{
$<num>$ = in_def;
in_def = 0;
}
term
{
$<num>$ = in_single;
in_single = 0;
class_nest++;
cref_push();
local_push();
}
{
$<num>$ = in_def;
in_def = 0;
}
compstmt
kEND
{
Expand All @@ -1291,8 +1292,8 @@ primary : literal
local_pop();
cref_pop();
class_nest--;
in_single = $<num>5;
in_def = $<num>6;
in_def = $<num>4;
in_single = $<num>6;
}
| kMODULE cname
{
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.0"
#define RUBY_RELEASE_DATE "2001-02-24"
#define RUBY_RELEASE_DATE "2001-02-26"
#define RUBY_VERSION_CODE 170
#define RUBY_RELEASE_CODE 20010224
#define RUBY_RELEASE_CODE 20010226

0 comments on commit df2d69b

Please sign in to comment.