diff options
-rw-r--r-- | ChangeLog | 36 | ||||
-rw-r--r-- | eval.c | 44 | ||||
-rw-r--r-- | ext/readline/extconf.rb | 3 | ||||
-rw-r--r-- | ext/readline/readline.c | 9 | ||||
-rw-r--r-- | file.c | 39 | ||||
-rw-r--r-- | io.c | 13 | ||||
-rw-r--r-- | missing/flock.c | 17 | ||||
-rw-r--r-- | parse.y | 1 | ||||
-rw-r--r-- | regex.c | 2 |
9 files changed, 127 insertions, 37 deletions
@@ -1,9 +1,38 @@ +Sat Apr 14 22:46:43 2001 Guy Decoux <decoux@moulon.inra.fr> + + * regex.c (calculate_must_string): wrong length calculation. + Sat Apr 14 13:33:32 2001 Usaku Nakamura <usa@osb.att.ne.jp> * win32/config.status.in: no longer use missing/alloca.c. * win32/Makefile.sub: ditto. +Fri Apr 13 12:40:48 2001 K.Kosako <kosako@sofnec.co.jp> + + * eval.c (rb_thread_start_0): fixed memory leak. + +Fri Apr 13 16:41:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * parse.y (none): should clear cmdarg_stack too. + +Fri Apr 13 06:19:29 2001 GOTOU YUUZOU <gotoyuzo@notwork.org> + + * io.c (rb_fopen): use setvbuf() to avoid recursive malloc() on + some platforms. + +Wed Apr 11 23:36:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * file.c (rb_stat_dev): device functions should honor stat field + types (except long long such as dev_t). + +Wed Apr 11 18:07:53 2001 K.Kosako <kosako@sofnec.co.jp> + + * eval.c (rb_mod_nesting): should not push nil for nesting array. + + * eval.c (rb_mod_s_constants): should not search array by + rb_mod_const_at() for nil (happens for singleton class). + Wed Apr 11 13:29:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org> * class.c (rb_singleton_class_attached): should modify iv_tbl by @@ -3629,6 +3658,13 @@ Sat Mar 25 23:21:10 2000 Yukihiro Matsumoto <matz@netlab.co.jp> * marshal.c (w_object): symbols should be converted to ID before dumping out. +Sun Mar 25 16:52:48 2001 Koji Arai <JCA02266@nifty.ne.jp> + + * file.c (rb_file_flock): do not trap EINTR. + + * missing/flock.c (flock): returns the value from lockf(2) + directly. + Fri Mar 24 18:26:51 2000 Yukihiro Matsumoto <matz@netlab.co.jp> * file.c (test_check): should have checked exact number of arguments. @@ -1449,7 +1449,7 @@ rb_mod_nesting() VALUE ary = rb_ary_new(); while (cbase && cbase->nd_next) { - rb_ary_push(ary, cbase->nd_clss); + if (!NIL_P(cbase->nd_clss)) rb_ary_push(ary, cbase->nd_clss); cbase = cbase->nd_next; } return ary; @@ -1462,11 +1462,11 @@ rb_mod_s_constants() VALUE ary = rb_ary_new(); while (cbase) { - rb_mod_const_at(cbase->nd_clss, ary); + if (!NIL_P(cbase->nd_clss)) rb_mod_const_at(cbase->nd_clss, ary); cbase = cbase->nd_next; } - rb_mod_const_of(ruby_cbase, ary); + if (!NIL_P(ruby_cbase)) rb_mod_const_of(ruby_cbase, ary); return ary; } @@ -6015,6 +6015,7 @@ blk_copy_prev(block) struct BLOCK *block; { struct BLOCK *tmp; + struct RVarmap* vars; while (block->prev) { tmp = ALLOC_N(struct BLOCK, 1); @@ -6025,6 +6026,12 @@ blk_copy_prev(block) } scope_dup(tmp->scope); tmp->tag->flags |= BLOCK_DYNAMIC; + + for (vars = tmp->dyna_vars; vars; vars = vars->next) { + if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break; + FL_SET(vars, DVAR_DONT_RECYCLE); + } + block->prev = tmp; block = tmp; } @@ -6869,6 +6876,7 @@ struct thread { VALUE klass; VALUE wrapper; NODE *cref; + NODE *cref; int flags; /* misc. states (vmode/rb_trap_immediate/raised) */ @@ -6936,6 +6944,7 @@ safe_setter(val) int level = NUM2INT(val); if (level < ruby_safe_level) { + rb_gc_mark((VALUE)th->cref); rb_raise(rb_eSecurityError, "tried to downgrade safe level from %d to %d", ruby_safe_level, level); } @@ -7053,6 +7062,7 @@ static VALUE th_raise_argv[2]; static char *th_raise_file; static int th_raise_line; static VALUE th_cmd; + th->cref = ruby_cref; static int th_sig; static char *th_signm; @@ -7143,6 +7153,7 @@ thread_switch(n) static void rb_thread_restore_context _((rb_thread_t,int)); static void + ruby_cref = th->cref; stack_extend(th, exit) rb_thread_t th; int exit; @@ -7547,7 +7558,14 @@ rb_thread_fd_writable(fd) if (rb_thread_critical) return Qtrue; if (curr_thread == curr_thread->next) return Qtrue; if (curr_thread->status == THREAD_TO_KILL) return Qtrue; - + if (n < 0) { + switch (errno) { + case EINTR: + return; + default: + rb_sys_fail("sleep"); + } + } curr_thread->status = THREAD_STOPPED; FD_ZERO(&curr_thread->readfds); FD_ZERO(&curr_thread->writefds); @@ -7951,6 +7969,7 @@ rb_thread_s_abort_exc_set(self, val) static VALUE rb_thread_abort_exc(thread) + th->cref = ruby_cref;\ VALUE thread; { return rb_thread_check(thread)->abort?Qtrue:Qfalse; @@ -8079,6 +8098,7 @@ rb_thread_start_0(fn, arg, th_arg) { volatile rb_thread_t th = th_arg; volatile VALUE thread = th->thread; + struct BLOCK* saved_block = 0; enum thread_status status; int state; @@ -8096,7 +8116,11 @@ rb_thread_start_0(fn, arg, th_arg) #endif if (ruby_block) { /* should nail down higher scopes */ - blk_copy_prev(ruby_block); + struct BLOCK dummy; + + dummy.prev = ruby_block; + blk_copy_prev(&dummy); + saved_block = ruby_block = dummy.prev; } scope_dup(ruby_scope); FL_SET(ruby_scope, SCOPE_SHARED); @@ -8123,6 +8147,16 @@ rb_thread_start_0(fn, arg, th_arg) } POP_TAG(); status = th->status; + + while (saved_block) { + struct BLOCK *tmp = saved_block; + + if (tmp->frame.argc > 0) + free(tmp->frame.argv); + saved_block = tmp->prev; + free(tmp); + } + if (th == main_thread) ruby_stop(state); rb_thread_remove(th); if (state && status != THREAD_TO_KILL && !NIL_P(ruby_errinfo)) { diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb index 7db62745f3..431ed213bb 100644 --- a/ext/readline/extconf.rb +++ b/ext/readline/extconf.rb @@ -9,5 +9,8 @@ have_library("ncurses", "tgetnum") or if have_header("readline/readline.h") and have_header("readline/history.h") and have_library("readline", "readline") + if have_func("rl_filename_completion_function") + $CFLAGS += "-DREADLINE_42_OR_LATER" + end create_makefile("readline") end diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 02b29796af..b96f818194 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -15,6 +15,11 @@ static VALUE mReadline; #define COMPLETION_PROC "completion_proc" #define COMPLETION_CASE_FOLD "completion_case_fold" +#ifndef READLINE_42_OR_LATER +# define rl_filename_completion_function filename_completion_function +# define rl_username_completion_function username_completion_function +#endif + static int readline_event() { @@ -322,7 +327,7 @@ filename_completion_proc_call(self, str) int i; matches = completion_matches(STR2CSTR(str), - filename_completion_function); + rl_filename_completion_function); if (matches) { result = rb_ary_new(); for (i = 0; matches[i]; i++) { @@ -349,7 +354,7 @@ username_completion_proc_call(self, str) int i; matches = completion_matches(STR2CSTR(str), - username_completion_function); + rl_username_completion_function); if (matches) { result = rb_ary_new(); for (i = 0; matches[i]; i++) { @@ -160,42 +160,42 @@ static VALUE rb_stat_dev(self) VALUE self; { - return INT2FIX((int)get_stat(self)->st_dev); + return INT2NUM(get_stat(self)->st_dev); } static VALUE rb_stat_ino(self) VALUE self; { - return INT2FIX((int)get_stat(self)->st_ino); + return UINT2NUM(get_stat(self)->st_ino); } static VALUE rb_stat_mode(self) VALUE self; { - return INT2FIX((int)get_stat(self)->st_mode); + return UINT2NUM(get_stat(self)->st_mode); } static VALUE rb_stat_nlink(self) VALUE self; { - return INT2FIX((int)get_stat(self)->st_nlink); + return UINT2NUM(get_stat(self)->st_nlink); } static VALUE rb_stat_uid(self) VALUE self; { - return INT2FIX((int)get_stat(self)->st_uid); + return UINT2NUM(get_stat(self)->st_uid); } static VALUE rb_stat_gid(self) VALUE self; { - return INT2FIX((int)get_stat(self)->st_gid); + return UINT2NUM(get_stat(self)->st_gid); } static VALUE @@ -203,7 +203,7 @@ rb_stat_rdev(self) VALUE self; { #ifdef HAVE_ST_RDEV - return INT2FIX((int)get_stat(self)->st_rdev); + return INT2NUM(get_stat(self)->st_rdev); #else return INT2FIX(0); #endif @@ -213,7 +213,7 @@ static VALUE rb_stat_size(self) VALUE self; { - return INT2FIX((int)get_stat(self)->st_size); + return INT2NUM(get_stat(self)->st_size); } static VALUE @@ -221,7 +221,7 @@ rb_stat_blksize(self) VALUE self; { #ifdef HAVE_ST_BLKSIZE - return INT2FIX((int)get_stat(self)->st_blksize); + return UINT2NUM(get_stat(self)->st_blksize); #else return INT2FIX(0); #endif @@ -232,7 +232,7 @@ rb_stat_blocks(self) VALUE self; { #ifdef HAVE_ST_BLOCKS - return INT2FIX((int)get_stat(self)->st_blocks); + return UINT2NUM(get_stat(self)->st_blocks); #else return INT2FIX(0); #endif @@ -1523,11 +1523,14 @@ rb_thread_flock(fd, op, fptr) op |= LOCK_NB; while (flock(fd, op) < 0) { switch (errno) { - case EINTR: /* can be happen? */ + case EAGAIN: + case EACCES: +#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN case EWOULDBLOCK: +#endif rb_thread_polling(); /* busy wait */ rb_io_check_closed(fptr); - break; + continue; default: return -1; } @@ -1556,11 +1559,14 @@ rb_file_flock(obj, operation) ret = flock(fileno(fptr->f), NUM2INT(operation)); TRAP_END; if (ret < 0) { -#ifdef EWOULDBLOCK - if (errno == EWOULDBLOCK) { - return Qfalse; - } + switch (errno) { + case EAGAIN: + case EACCES: +#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN + case EWOULDBLOCK: #endif + return Qfalse; + } rb_sys_fail(fptr->path); } #endif @@ -2201,6 +2207,7 @@ define_filetest_function(name, func, argc) rb_define_singleton_method(rb_cFile, name, func, argc); } +void Init_File() { rb_mFileTest = rb_define_module("FileTest"); @@ -27,6 +27,10 @@ # define NO_LONG_FNAME #endif +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(sun) +# define USE_SETVBUF +#endif + #include <sys/types.h> #if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) #include <sys/ioctl.h> @@ -1362,6 +1366,9 @@ rb_fopen(fname, mode) rb_sys_fail(fname); } } +#ifdef USE_SETVBUF + setvbuf(file, NULL, _IOFBF, 0); +#endif #ifdef __human68k__ fmode(file, _IOTEXT); #endif @@ -1385,6 +1392,10 @@ rb_fdopen(fd, mode) rb_sys_fail(0); } } +#ifdef USE_SETVBUF + setvbuf(file, NULL, _IOFBF, 0); +#endif + return file; } @@ -1902,12 +1913,14 @@ rb_io_reopen(argc, argv, file) fclose(fptr->f2); fptr->f2 = 0; } + return file; } if (freopen(RSTRING(fname)->ptr, mode, fptr->f) == 0) { rb_sys_fail(fptr->path); } + if (fptr->f2) { if (freopen(RSTRING(fname)->ptr, "w", fptr->f2) == 0) { rb_sys_fail(fptr->path); diff --git a/missing/flock.c b/missing/flock.c index e293ca0d72..c828fcc7ad 100644 --- a/missing/flock.c +++ b/missing/flock.c @@ -94,7 +94,6 @@ flock(fd, operation) int fd; int operation; { - int i; switch (operation) { /* LOCK_SH - get a shared lock */ @@ -103,8 +102,7 @@ flock(fd, operation) return -1; /* LOCK_EX - get an exclusive lock */ case LOCK_EX: - i = lockf (fd, F_LOCK, 0); - break; + return lockf (fd, F_LOCK, 0); /* LOCK_SH|LOCK_NB - get a non-blocking shared lock */ case LOCK_SH|LOCK_NB: @@ -112,24 +110,17 @@ flock(fd, operation) return -1; /* LOCK_EX|LOCK_NB - get a non-blocking exclusive lock */ case LOCK_EX|LOCK_NB: - i = lockf (fd, F_TLOCK, 0); - if (i == -1) - if ((errno == EAGAIN) || (errno == EACCES)) - errno = EWOULDBLOCK; - break; + return lockf (fd, F_TLOCK, 0); /* LOCK_UN - unlock */ case LOCK_UN: - i = lockf (fd, F_ULOCK, 0); - break; + return lockf (fd, F_ULOCK, 0); /* Default - can't decipher operation */ default: - i = -1; errno = EINVAL; - break; + return -1; } - return i; } #elif !defined NT int @@ -1973,6 +1973,7 @@ yycompile(f, line) ruby_in_compile = 0; cond_nest = 0; cond_stack = 0; + cmdarg_stack = 0; class_nest = 0; in_single = 0; in_def = 0; @@ -1049,7 +1049,7 @@ calculate_must_string(start, end) EXTRACT_NUMBER_AND_INCR(mcnt, p); if (mcnt > 0) p += mcnt; if ((enum regexpcode)p[-3] == jump) { - p -= 3; + p -= 2; EXTRACT_NUMBER_AND_INCR(mcnt, p); if (mcnt > 0) p += mcnt; } |