* eval.c (proc_call): should not modify ruby_block->frame.iter

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
This commit is contained in:
matz 2001-02-26 05:29:06 +00:00
Родитель 69739b14a5
Коммит df2d69b49a
15 изменённых файлов: 90 добавлений и 80 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Mon Feb 26 00:04:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <wakou@fsinet.or.jp>
* lib/net/telnet.rb: #telnetmode(), #binmode(): bug fix.
@ -18,6 +23,11 @@ Sun Feb 25 02:45:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* file.c (rb_file_s_rename): avoid Cygwin's bug.
Sat Feb 24 23:32:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_fd_close): should save current context before
raising exception.
Sat Feb 24 22:14:00 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* win32/win32.c (myrename): fix error handling.
@ -29,6 +39,12 @@ Sat Feb 24 13:58:48 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: change copyright.
Sat Feb 24 03:15:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (set_stdin): preserve original stdin.
* io.c (set_outfile): preserve original stdout/stderr.
Fri Feb 23 08:28:58 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* lib/net/protocol.rb: clear read buffer after reopen.

1
ToDo
Просмотреть файл

@ -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

10
array.c
Просмотреть файл

@ -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;

Просмотреть файл

@ -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 ||

2
dln.c
Просмотреть файл

@ -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");
}

65
eval.c
Просмотреть файл

@ -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;
@ -3640,7 +3622,6 @@ rb_yield_0(val, self, klass, acheck)
}
}
}
#endif
POP_VARS();
ruby_block = block;
ruby_frame = ruby_frame->prev;
@ -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);
@ -6280,17 +6261,6 @@ proc_call(proc, args)
Data_Get_Struct(proc, struct BLOCK, data);
orphan = blk_orphan(data);
/* 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;
@ -6300,6 +6270,18 @@ proc_call(proc, args)
}
}
/* 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);
}
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
if (state == 0) {
@ -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;
@ -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
@ -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)
@ -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;

Просмотреть файл

@ -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

28
io.c
Просмотреть файл

@ -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;
@ -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;
@ -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;
}
@ -2226,6 +2240,7 @@ set_outfile(val, var, orig, stdf)
{
OpenFile *fptr;
FILE *f;
int fd;
if (val == *var) return;
@ -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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -29,4 +29,3 @@ if __FILE__ == $0
$TERM = "foo"
p ENV["TERM"]
end

Просмотреть файл

@ -503,6 +503,9 @@ EOMF
.c.#{$OBJEXT}:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
.cc.#{$OBJEXT} .cpp.#{$OBJEXT} .cxx.#{$OBJEXT} .C.#{$OBJEXT}:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
"
end

Просмотреть файл

@ -99,6 +99,8 @@ 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);
@ -106,6 +108,8 @@ flock(fd, operation)
/* 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);

15
parse.y
Просмотреть файл

@ -1271,7 +1271,12 @@ 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;
@ -1279,10 +1284,6 @@ primary : literal
cref_push();
local_push();
}
{
$<num>$ = in_def;
in_def = 0;
}
compstmt
kEND
{
@ -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
{

Просмотреть файл

@ -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