зеркало из https://github.com/github/ruby.git
* parse.y (parse_regx): should raise error on untermitated
expression interpolation. * pack.c (pack_unpack): should give length to utf8_to_uv(). * pack.c (utf8_to_uv): add length check. * massages: replace "wrong #" by "wrong number". * marshal.c (w_float): output Infinity and NaN explicitly. * marshal.c (r_object): support new explicit float format. * eval.c (rb_thread_wait_for): select may cause ERESTART on Solaris. * eval.c (rb_thread_select): ditto. * array.c (rb_ary_join): dumped core if sep is not T_STRING nor T_NIL. * array.c (rb_ary_join): buffer size calculattion was wrong. * array.c (rb_ary_to_s): if rb_output_fs is nil, insert newlines between array elements (use rb_default_rs as newline litral) [experimental]. * gc.c (init_mark_stack): no need to clear mark_stack. * gc.c (gc_mark_all): need to handle finalizer mark. * gc.c (gc_mark_rest): use MEMCPY instead of memcpy. * gc.c (rb_gc_mark): earlier const check to avoid pusing special constants into mark stack. * numeric.c (fix_to_s): 'to_s' now takes optional argument to specify radix. [new] * bignum.c (rb_big_to_s): ditto. [new] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d550569264
Коммит
df96f994f1
47
ChangeLog
47
ChangeLog
|
@ -10,6 +10,25 @@ Sun Nov 18 19:37:55 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
|||
* parse.y (parse_regx): parse error at unterminated regex /#{.
|
||||
(ruby-bugs-ja:PR#142)
|
||||
|
||||
Sat Nov 17 12:37:39 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* pack.c (pack_unpack): should give length to utf8_to_uv().
|
||||
|
||||
* pack.c (utf8_to_uv): add length check.
|
||||
|
||||
Sat Nov 17 01:41:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* massages: replace "wrong #" by "wrong number".
|
||||
|
||||
* marshal.c (w_float): output Infinity and NaN explicitly.
|
||||
|
||||
* marshal.c (r_object): support new explicit float format.
|
||||
|
||||
* eval.c (rb_thread_wait_for): select may cause ERESTART on
|
||||
Solaris.
|
||||
|
||||
* eval.c (rb_thread_select): ditto.
|
||||
|
||||
Thu Nov 15 15:29:39 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* array.c (rb_ary_join): non-nil separator must be converted to
|
||||
|
@ -22,12 +41,36 @@ Thu Nov 15 03:37:17 2001 Usaku Nakamura <usa@ruby-lang.org>
|
|||
|
||||
* win32/win32.c, win32/win32.h: sort out #if 0 - #endif or others.
|
||||
|
||||
Thu Nov 15 00:07:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_to_s): if rb_output_fs is nil, insert newlines
|
||||
between array elements (use rb_default_rs as newline litral)
|
||||
[experimental].
|
||||
|
||||
Wed Nov 14 15:16:23 2001 K.Kosako <kosako@sofnec.co.jp>
|
||||
|
||||
* gc.c (init_mark_stack): no need to clear mark_stack.
|
||||
|
||||
* gc.c (gc_mark_all): need to handle finalizer mark.
|
||||
|
||||
* gc.c (gc_mark_rest): use MEMCPY instead of memcpy.
|
||||
|
||||
* gc.c (rb_gc_mark): earlier const check to avoid pusing special
|
||||
constants into mark stack.
|
||||
|
||||
Wed Nov 14 01:12:07 2001 Usaku Nakamura <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (waitpid): fix wait count.
|
||||
|
||||
* win32/win32.c (poll_child_status): rename from wait_child().
|
||||
|
||||
Wed Nov 14 01:33:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* numeric.c (fix_to_s): 'to_s' now takes optional argument to
|
||||
specify radix. [new]
|
||||
|
||||
* bignum.c (rb_big_to_s): ditto. [new]
|
||||
|
||||
Tue Nov 13 19:50:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* configure.in: do not override CC if set.
|
||||
|
@ -263,7 +306,7 @@ Tue Oct 30 18:21:51 2001 Usaku Nakamura <usa@ruby-lang.org>
|
|||
|
||||
Tue Oct 30 14:04:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_chomp_bang): do smart chomp if $/ == '\n'.
|
||||
* string.c (rb_str_chomp_bang): do smart chomp if $/ == '\n'. [new]
|
||||
|
||||
* io.c (rb_io_puts): don't treat Array specially.
|
||||
|
||||
|
@ -273,7 +316,7 @@ Tue Oct 30 14:04:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
Mon Oct 29 16:08:30 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* regex.c (re_compile_pattern): should preverve p0 value.
|
||||
* regex.c (re_compile_pattern): should preserve p0 value.
|
||||
|
||||
Mon Oct 29 14:56:44 2001 Usaku Nakamura <usa@ruby-lang.org>
|
||||
|
||||
|
|
6
ToDo
6
ToDo
|
@ -31,7 +31,7 @@ Language Spec.
|
|||
* method combination, e.g. before, after, around, etc.
|
||||
* .. or something like defadvice in Emacs.
|
||||
* property - for methods, or for objects in general.
|
||||
* in modifier, to annotate, or to encourage assertion.
|
||||
* "in" modifier, to annotate, or to encourage assertion.
|
||||
* selector namespace - something like generic-flet in CLOS, to help RubyBehevior
|
||||
|
||||
Hacking Interpreter
|
||||
|
@ -70,6 +70,7 @@ Standard Libraries
|
|||
- Enumerable#sort_by for Schwartzian transformation
|
||||
- fork_and_kill_other_threads.
|
||||
- signal list (Signal::trap, Signal::list).
|
||||
- move NameError under StandardError.
|
||||
* String#scanf(?)
|
||||
* Object#fmt(?)
|
||||
* Integer#{bin,oct,hex,heX}
|
||||
|
@ -88,12 +89,13 @@ Standard Libraries
|
|||
* Hash::new{default} or recommend Hash#fetch?
|
||||
* new user-defined marshal scheme. _dump(dumper), _load(restorer)
|
||||
* hash etc. should handle self referenceing array/hash
|
||||
* move NameError under StandardError.
|
||||
* library to load per-user profile seeking .ruby_profile or ruby.ini file.
|
||||
* warning framework (warn, warning for Ruby level)
|
||||
* marshal should not depend on sprintf/strtod (works bad for locale).
|
||||
* ternary arg pow: a.pow(b,c) == a**b%c
|
||||
* new caller(), e.g. call_stack; needs better name.
|
||||
* remove dependency on MAXPATHLEN.
|
||||
* pointer share mechanism similar to one in String for Array.
|
||||
|
||||
Extension Libraries
|
||||
|
||||
|
|
16
array.c
16
array.c
|
@ -305,7 +305,7 @@ rb_ary_push_m(argc, argv, ary)
|
|||
VALUE ary;
|
||||
{
|
||||
if (argc == 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(at least 1)");
|
||||
rb_raise(rb_eArgError, "wrong number arguments(at least 1)");
|
||||
}
|
||||
if (argc > 0) {
|
||||
while (argc--) {
|
||||
|
@ -380,7 +380,7 @@ rb_ary_unshift_m(argc, argv, ary)
|
|||
VALUE ary;
|
||||
{
|
||||
if (argc == 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(at least 1)");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(at least 1)");
|
||||
}
|
||||
if (argc > 0) {
|
||||
long len = RARRAY(ary)->len;
|
||||
|
@ -652,7 +652,7 @@ rb_ary_aset(argc, argv, ary)
|
|||
return argv[2];
|
||||
}
|
||||
if (argc != 2) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 2)", argc);
|
||||
}
|
||||
if (FIXNUM_P(argv[0])) {
|
||||
offset = FIX2LONG(argv[0]);
|
||||
|
@ -682,7 +682,7 @@ rb_ary_insert(argc, argv, ary)
|
|||
long pos;
|
||||
|
||||
if (argc < 2) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(at least 2)");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(at least 2)");
|
||||
}
|
||||
pos = NUM2LONG(argv[0]);
|
||||
if (pos == -1) {
|
||||
|
@ -774,6 +774,7 @@ rb_ary_dup(ary)
|
|||
}
|
||||
|
||||
extern VALUE rb_output_fs;
|
||||
extern VALUE rb_default_rs;
|
||||
|
||||
static VALUE
|
||||
inspect_join(ary, arg)
|
||||
|
@ -856,11 +857,12 @@ VALUE
|
|||
rb_ary_to_s(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
VALUE str;
|
||||
VALUE str, sep;
|
||||
|
||||
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
|
||||
str = rb_ary_join(ary, rb_output_fs);
|
||||
if (NIL_P(str)) return rb_str_new(0, 0);
|
||||
if (!NIL_P(rb_output_fs)) sep = rb_output_fs;
|
||||
else sep = rb_default_rs;
|
||||
str = rb_ary_join(ary, sep);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
20
bignum.c
20
bignum.c
|
@ -10,9 +10,9 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include "ruby.h"
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include "ruby.h"
|
||||
|
||||
VALUE rb_cBignum;
|
||||
|
||||
|
@ -397,9 +397,7 @@ rb_big2str(x, base)
|
|||
hbase = 020;
|
||||
}
|
||||
else {
|
||||
j = 0;
|
||||
hbase = 0;
|
||||
rb_raise(rb_eArgError, "Bignum cannot treat base %d", base);
|
||||
rb_raise(rb_eArgError, "illegal radix %d", base);
|
||||
}
|
||||
|
||||
t = rb_big_clone(x);
|
||||
|
@ -435,10 +433,18 @@ rb_big2str(x, base)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_big_to_s(x)
|
||||
rb_big_to_s(argc, argv, x)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE x;
|
||||
{
|
||||
return rb_big2str(x, 10);
|
||||
VALUE b;
|
||||
int base;
|
||||
|
||||
rb_scan_args(argc, argv, "01", &b);
|
||||
if (argc == 0) base = 10;
|
||||
else base = NUM2INT(b);
|
||||
return rb_big2str(x, base);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
|
@ -1442,7 +1448,7 @@ Init_Bignum()
|
|||
{
|
||||
rb_cBignum = rb_define_class("Bignum", rb_cInteger);
|
||||
|
||||
rb_define_method(rb_cBignum, "to_s", rb_big_to_s, 0);
|
||||
rb_define_method(rb_cBignum, "to_s", rb_big_to_s, -1);
|
||||
rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
|
||||
rb_define_method(rb_cBignum, "-@", rb_big_uminus, 0);
|
||||
rb_define_method(rb_cBignum, "+", rb_big_plus, 1);
|
||||
|
|
4
class.c
4
class.c
|
@ -734,7 +734,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
|
|||
if (ISDIGIT(*p)) {
|
||||
n = *p - '0';
|
||||
if (n > argc)
|
||||
rb_raise(rb_eArgError, "wrong # of arguments (%d for %d)", argc, n);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, n);
|
||||
for (i=0; i<n; i++) {
|
||||
var = va_arg(vargs, VALUE*);
|
||||
if (var) *var = argv[i];
|
||||
|
@ -789,7 +789,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
|
|||
}
|
||||
|
||||
if (argc > i) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, i);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", argc, i);
|
||||
}
|
||||
|
||||
return argc;
|
||||
|
|
137
eval.c
137
eval.c
|
@ -91,10 +91,6 @@ struct timeval {
|
|||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
VALUE rb_cProc;
|
||||
|
@ -500,7 +496,6 @@ extern NODE *ruby_eval_tree;
|
|||
extern int ruby_nerrs;
|
||||
|
||||
static VALUE rb_eLocalJumpError;
|
||||
static VALUE rb_eSysStackError;
|
||||
|
||||
extern VALUE ruby_top_self;
|
||||
|
||||
|
@ -3055,7 +3050,7 @@ rb_eval(self, n)
|
|||
|
||||
case NODE_ATTRSET:
|
||||
if (ruby_frame->argc != 1)
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)",
|
||||
ruby_frame->argc);
|
||||
result = rb_ivar_set(self, node->nd_vid, ruby_frame->argv[0]);
|
||||
break;
|
||||
|
@ -3587,7 +3582,7 @@ rb_f_raise(argc, argv)
|
|||
mesg = rb_funcall(argv[0], exception, n, argv[1]);
|
||||
break;
|
||||
default:
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
break;
|
||||
}
|
||||
if (argc > 0) {
|
||||
|
@ -3685,13 +3680,13 @@ rb_yield_0(val, self, klass, pcall)
|
|||
if ((state = EXEC_TAG()) == 0) {
|
||||
if (block->var == (NODE*)1) {
|
||||
if (pcall && RARRAY(val)->len != 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)",
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)",
|
||||
RARRAY(val)->len);
|
||||
}
|
||||
}
|
||||
else if (block->var == (NODE*)2) {
|
||||
if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)",
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)",
|
||||
RARRAY(val)->len);
|
||||
}
|
||||
}
|
||||
|
@ -3850,7 +3845,7 @@ massign(self, node, val, pcall)
|
|||
i++;
|
||||
list = list->nd_next;
|
||||
}
|
||||
rb_raise(rb_eArgError, "wrong # of arguments (%d for %d)", len, i);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", len, i);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4164,7 +4159,7 @@ rb_f_missing(argc, argv, obj)
|
|||
rb_raise(rb_eArgError, "no id given");
|
||||
}
|
||||
|
||||
rb_stack_check();
|
||||
ruby_stack_check();
|
||||
|
||||
id = SYM2ID(argv[0]);
|
||||
|
||||
|
@ -4255,57 +4250,6 @@ rb_undefined(obj, id, argc, argv, call_status)
|
|||
return rb_funcall2(obj, missing, argc+1, nargv);
|
||||
}
|
||||
|
||||
#ifdef DJGPP
|
||||
static unsigned int STACK_LEVEL_MAX = 65535;
|
||||
#else
|
||||
#ifdef __human68k__
|
||||
extern unsigned int _stacksize;
|
||||
# define STACK_LEVEL_MAX (_stacksize - 4096)
|
||||
# undef HAVE_GETRLIMIT
|
||||
#else
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
static unsigned int STACK_LEVEL_MAX = 655300;
|
||||
#else
|
||||
# define STACK_LEVEL_MAX 655300
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern VALUE *rb_gc_stack_start;
|
||||
static int
|
||||
stack_length(p)
|
||||
VALUE **p;
|
||||
{
|
||||
#ifdef C_ALLOCA
|
||||
VALUE stack_end;
|
||||
alloca(0);
|
||||
# define STACK_END (&stack_end)
|
||||
#else
|
||||
# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS)
|
||||
VALUE *stack_end = __builtin_frame_address(0);
|
||||
# else
|
||||
VALUE *stack_end = alloca(1);
|
||||
# endif
|
||||
# define STACK_END (stack_end)
|
||||
#endif
|
||||
if (p) *p = STACK_END;
|
||||
|
||||
#ifdef __sparc__
|
||||
return rb_gc_stack_start - STACK_END + 0x80;
|
||||
#else
|
||||
return (STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END
|
||||
: STACK_END - rb_gc_stack_start;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
rb_stack_check()
|
||||
{
|
||||
if (stack_length(0) > STACK_LEVEL_MAX) {
|
||||
rb_raise(rb_eSysStackError, "stack level too deep");
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
call_cfunc(func, recv, len, argc, argv)
|
||||
VALUE (*func)();
|
||||
|
@ -4314,7 +4258,7 @@ call_cfunc(func, recv, len, argc, argv)
|
|||
VALUE *argv;
|
||||
{
|
||||
if (len >= 0 && argc != len) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)",
|
||||
argc, len);
|
||||
}
|
||||
|
||||
|
@ -4421,7 +4365,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
|||
|
||||
if ((++tick & 0xff) == 0) {
|
||||
CHECK_INTS; /* better than nothing */
|
||||
rb_stack_check();
|
||||
ruby_stack_check();
|
||||
}
|
||||
PUSH_ITER(itr);
|
||||
PUSH_FRAME();
|
||||
|
@ -4468,7 +4412,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
|||
/* for attr get/set */
|
||||
case NODE_IVAR:
|
||||
if (argc != 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 0)", argc);
|
||||
}
|
||||
case NODE_ATTRSET:
|
||||
/* for re-scoped/renamed method */
|
||||
|
@ -4532,7 +4476,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
|||
|
||||
i = node->nd_cnt;
|
||||
if (i > argc) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)",
|
||||
argc, i);
|
||||
}
|
||||
if (node->nd_rest == -1) {
|
||||
|
@ -4544,7 +4488,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
|||
optnode = optnode->nd_next;
|
||||
}
|
||||
if (opt < argc) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)",
|
||||
argc, opt);
|
||||
}
|
||||
ruby_frame->argc = opt;
|
||||
|
@ -5212,7 +5156,7 @@ specific_eval(argc, argv, klass, self)
|
|||
{
|
||||
if (rb_block_given_p()) {
|
||||
if (argc > 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
|
||||
}
|
||||
return yield_under(klass, self);
|
||||
}
|
||||
|
@ -5231,7 +5175,7 @@ specific_eval(argc, argv, klass, self)
|
|||
SafeStringValue(argv[0]);
|
||||
}
|
||||
if (argc > 3) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
|
||||
rb_raise(rb_eArgError, "wrong number of arguments: %s(src) or %s{..}",
|
||||
rb_id2name(ruby_frame->last_func),
|
||||
rb_id2name(ruby_frame->last_func));
|
||||
}
|
||||
|
@ -5824,7 +5768,7 @@ rb_obj_extend(argc, argv, obj)
|
|||
int i;
|
||||
|
||||
if (argc == 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(0 for 1)");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(0 for 1)");
|
||||
}
|
||||
for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
|
||||
for (i=0; i<argc; i++) {
|
||||
|
@ -6102,19 +6046,6 @@ Init_eval()
|
|||
rb_global_variable(&trace_func);
|
||||
|
||||
rb_define_virtual_variable("$SAFE", safe_getter, safe_setter);
|
||||
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
{
|
||||
struct rlimit rlim;
|
||||
|
||||
if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
|
||||
double space = (double)rlim.rlim_cur*0.2;
|
||||
|
||||
if (space > 1024*1024) space = 1024*1024;
|
||||
STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
VALUE rb_f_autoload();
|
||||
|
@ -6992,7 +6923,7 @@ rb_mod_define_method(argc, argv, mod)
|
|||
body = argv[1];
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc);
|
||||
}
|
||||
if (TYPE(body) != T_DATA) {
|
||||
/* type error */
|
||||
|
@ -7017,7 +6948,6 @@ void
|
|||
Init_Proc()
|
||||
{
|
||||
rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
|
||||
rb_eSysStackError = rb_define_class("SystemStackError", rb_eStandardError);
|
||||
|
||||
rb_cProc = rb_define_class("Proc", rb_cObject);
|
||||
rb_undef_method(CLASS_OF(rb_cProc), "allocate");
|
||||
|
@ -7321,6 +7251,8 @@ static char *th_signm;
|
|||
#define RESTORE_RAISE 5
|
||||
#define RESTORE_SIGNAL 6
|
||||
|
||||
extern VALUE *rb_gc_stack_start;
|
||||
|
||||
static void
|
||||
rb_thread_save_context(th)
|
||||
rb_thread_t th;
|
||||
|
@ -7329,7 +7261,7 @@ rb_thread_save_context(th)
|
|||
int len;
|
||||
static VALUE tval;
|
||||
|
||||
len = stack_length(&pos);
|
||||
len = ruby_stack_length(&pos);
|
||||
th->stk_len = 0;
|
||||
th->stk_pos = (rb_gc_stack_start<pos)?rb_gc_stack_start
|
||||
:rb_gc_stack_start - len;
|
||||
|
@ -7856,6 +7788,9 @@ rb_thread_wait_for(time)
|
|||
if (n < 0) {
|
||||
switch (errno) {
|
||||
case EINTR:
|
||||
#ifdef ERESTART
|
||||
case ERESTART:
|
||||
#endif
|
||||
return;
|
||||
default:
|
||||
rb_sys_fail("sleep");
|
||||
|
@ -7927,14 +7862,22 @@ rb_thread_select(max, read, write, except, timeout)
|
|||
TRAP_BEG;
|
||||
n = select(max, read, write, except, tvp);
|
||||
TRAP_END;
|
||||
if (n < 0 && errno == EINTR) {
|
||||
if (timeout) {
|
||||
double d = timeofday() - limit;
|
||||
if (n < 0) {
|
||||
switch (errno) {
|
||||
case EINTR:
|
||||
#ifdef ERESTART
|
||||
case ERESTART:
|
||||
#endif
|
||||
if (timeout) {
|
||||
double d = timeofday() - limit;
|
||||
|
||||
tv.tv_sec = (unsigned int)d;
|
||||
tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6);
|
||||
tv.tv_sec = (unsigned int)d;
|
||||
tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6);
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
@ -7943,8 +7886,14 @@ rb_thread_select(max, read, write, except, timeout)
|
|||
TRAP_BEG;
|
||||
n = select(max, read, write, except, timeout);
|
||||
TRAP_END;
|
||||
if (n < 0 && errno == EINTR) {
|
||||
continue;
|
||||
if (n < 0) {
|
||||
switch (errno) {
|
||||
case EINTR:
|
||||
#ifdef ERESTART
|
||||
case ERESTART:
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -638,7 +638,7 @@ def extmake(target)
|
|||
if $static_ext.size > 0 ||
|
||||
!File.exist?("./Makefile") ||
|
||||
older("./Makefile", "#{$top_srcdir}/ext/@setup@") ||
|
||||
older("./Makefile", "../extmk.rb") ||
|
||||
older("./Makefile", "#{$topdir}/ext/extmk.rb") ||
|
||||
older("./Makefile", "#{$top_srcdir}/ext/#{target}/makefile.rb") ||
|
||||
older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
|
||||
then
|
||||
|
|
103
ext/pty/pty.c
103
ext/pty/pty.c
|
@ -1,6 +1,7 @@
|
|||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/file.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
@ -31,6 +32,7 @@
|
|||
|
||||
#if !defined(HAVE_OPENPTY)
|
||||
#ifdef __hpux
|
||||
static
|
||||
char *MasterDevice = "/dev/ptym/pty%s",
|
||||
*SlaveDevice = "/dev/pty/tty%s",
|
||||
*deviceNo[] = {
|
||||
|
@ -54,6 +56,7 @@ char *MasterDevice = "/dev/ptym/pty%s",
|
|||
};
|
||||
#else /* NOT HPUX */
|
||||
#ifdef _IBMESA /* AIX/ESA */
|
||||
static
|
||||
char *MasterDevice = "/dev/ptyp%s",
|
||||
*SlaveDevice = "/dev/ttyp%s",
|
||||
*deviceNo[] = {
|
||||
|
@ -75,6 +78,7 @@ char *MasterDevice = "/dev/ptyp%s",
|
|||
"f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff",
|
||||
};
|
||||
#else
|
||||
static
|
||||
char *MasterDevice = "/dev/pty%s",
|
||||
*SlaveDevice = "/dev/tty%s",
|
||||
*deviceNo[] = {
|
||||
|
@ -90,7 +94,7 @@ char *MasterDevice = "/dev/pty%s",
|
|||
#endif /* HPUX */
|
||||
#endif /* !defined(HAVE_OPENPTY) */
|
||||
|
||||
char SlaveName[DEVICELEN];
|
||||
static char SlaveName[DEVICELEN];
|
||||
|
||||
extern int errno;
|
||||
|
||||
|
@ -107,64 +111,69 @@ extern int errno;
|
|||
#endif /* NO_SETEUID */
|
||||
|
||||
struct pty_info {
|
||||
int fd;
|
||||
pid_t child_pid;
|
||||
int fd;
|
||||
pid_t child_pid;
|
||||
VALUE thread;
|
||||
};
|
||||
|
||||
static void
|
||||
pty_raise(cpid)
|
||||
pty_raise(thread, cpid, stop)
|
||||
VALUE thread;
|
||||
int cpid;
|
||||
int stop;
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
"eval %%Q{Thread.main.raise 'pty - stopped: %d'}, nil, \"%s\", %d",
|
||||
cpid, ruby_sourcefile, ruby_sourceline);
|
||||
rb_eval_string(buf);
|
||||
snprintf(buf, sizeof(buf), "pty - %s: %d", stop ? "stopped" : "changed", cpid);
|
||||
rb_funcall(thread, rb_intern("raise"), 1, rb_str_new2(buf));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
pty_syswait(pid)
|
||||
int pid;
|
||||
pty_syswait(info)
|
||||
struct pty_info *info;
|
||||
{
|
||||
int cpid, status;
|
||||
|
||||
cpid = rb_waitpid(pid, &status, WUNTRACED);
|
||||
|
||||
printf("PTY command (%d) finished (%d:%d)\n", pid, cpid, status);
|
||||
cpid = rb_waitpid(info->child_pid, &status, WUNTRACED);
|
||||
printf("cpid: %d (%d)\n", cpid, status);
|
||||
|
||||
if (cpid == 0 || cpid == -1)
|
||||
return Qnil;
|
||||
|
||||
#ifdef IF_STOPPED
|
||||
if (IF_STOPPED(status)) { /* suspend */
|
||||
pty_raise(cpid);
|
||||
pty_raise(info->thread, cpid, Qtrue);
|
||||
}
|
||||
#else
|
||||
#ifdef WIFSTOPPED
|
||||
if (WIFSTOPPED(status)) { /* suspend */
|
||||
pty_raise(cpid);
|
||||
pty_raise(info->thread, cpid, Qtrue);
|
||||
}
|
||||
#else
|
||||
---->> Either IF_STOPPED or WIFSTOPPED is needed <<----
|
||||
#endif /* WIFSTOPPED */
|
||||
#endif /* IF_STOPPED */
|
||||
|
||||
pty_raise(info->thread, cpid, Qfalse);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static void getDevice _((int*, int*));
|
||||
|
||||
static void
|
||||
establishShell(shellname, info)
|
||||
char *shellname;
|
||||
establishShell(argc, argv, info)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
struct pty_info *info;
|
||||
{
|
||||
static int i,j,master,slave,currentPid;
|
||||
static int i,master,slave,currentPid;
|
||||
char *p,*getenv();
|
||||
struct passwd *pwent;
|
||||
RETSIGTYPE chld_changed();
|
||||
|
||||
if (shellname[0] == '\0') {
|
||||
VALUE v;
|
||||
|
||||
if (argc == 0) {
|
||||
char *shellname;
|
||||
|
||||
if ((p = getenv("SHELL")) != NULL) {
|
||||
shellname = p;
|
||||
}
|
||||
|
@ -175,17 +184,20 @@ establishShell(shellname, info)
|
|||
else
|
||||
shellname = "/bin/sh";
|
||||
}
|
||||
v = rb_str_new2(shellname);
|
||||
argc = 1;
|
||||
argv = &v;
|
||||
}
|
||||
getDevice(&master,&slave);
|
||||
|
||||
currentPid = getpid();
|
||||
if((i = vfork()) < 0) {
|
||||
if((i = fork()) < 0) {
|
||||
rb_sys_fail("fork failed");
|
||||
}
|
||||
|
||||
if(i == 0) { /* child */
|
||||
int argc;
|
||||
char *argv[1024];
|
||||
/* int argc;
|
||||
char *argv[1024]; */
|
||||
currentPid = getpid();
|
||||
|
||||
/*
|
||||
|
@ -232,23 +244,11 @@ establishShell(shellname, info)
|
|||
dup2(slave,1);
|
||||
dup2(slave,2);
|
||||
close(slave);
|
||||
|
||||
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRESUID)
|
||||
seteuid(getuid());
|
||||
#endif
|
||||
|
||||
argc = 0;
|
||||
for (i = 0; shellname[i];) {
|
||||
while (isspace(shellname[i])) i++;
|
||||
for (j = i; shellname[j] && !isspace(shellname[j]); j++);
|
||||
argv[argc] = (char*)xmalloc(j-i+1);
|
||||
strncpy(argv[argc],&shellname[i],j-i);
|
||||
argv[argc][j-i] = 0;
|
||||
i = j;
|
||||
argc++;
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
execvp(argv[0],argv);
|
||||
rb_f_exec(argc, argv);
|
||||
sleep(1);
|
||||
_exit(1);
|
||||
}
|
||||
|
@ -361,8 +361,10 @@ freeDevice()
|
|||
|
||||
/* ruby function: getpty */
|
||||
static VALUE
|
||||
pty_getpty(self, command)
|
||||
VALUE self, command;
|
||||
pty_getpty(argc, argv, self)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE self;
|
||||
{
|
||||
VALUE res, th;
|
||||
struct pty_info info;
|
||||
|
@ -373,35 +375,28 @@ pty_getpty(self, command)
|
|||
MakeOpenFile(rport, rfptr);
|
||||
MakeOpenFile(wport, wfptr);
|
||||
|
||||
if (TYPE(command) == T_ARRAY)
|
||||
command = rb_ary_join(command,rb_str_new2(" "));
|
||||
Check_SafeStr(command);
|
||||
|
||||
establishShell(RSTRING(command)->ptr,&info);
|
||||
establishShell(argc, argv, &info);
|
||||
|
||||
rfptr->mode = rb_io_mode_flags("r");
|
||||
rfptr->f = fdopen(info.fd, "r");
|
||||
rfptr->path = strdup(RSTRING(command)->ptr);
|
||||
rfptr->path = 0; /*strdup(RSTRING(command)->ptr); */
|
||||
|
||||
wfptr->mode = rb_io_mode_flags("w");
|
||||
wfptr->f = fdopen(dup(info.fd), "w");
|
||||
wfptr->path = strdup(RSTRING(command)->ptr);
|
||||
wfptr->path = 0; /* strdup(RSTRING(command)->ptr); */
|
||||
|
||||
res = rb_ary_new2(3);
|
||||
rb_ary_store(res,0,(VALUE)rport);
|
||||
rb_ary_store(res,1,(VALUE)wport);
|
||||
rb_ary_store(res,2,INT2FIX(info.child_pid));
|
||||
|
||||
printf("start watching PTY command (%d)\n", info.child_pid);
|
||||
th = rb_thread_create(pty_syswait, (void*)info.child_pid);
|
||||
info.thread = rb_thread_current();
|
||||
th = rb_thread_create(pty_syswait, (void*)&info);
|
||||
if (rb_block_given_p()) {
|
||||
res = rb_yield((VALUE)res);
|
||||
rb_funcall(th, rb_intern("kill"), 0, 0);
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* ruby function: protect_signal - obsolete */
|
||||
|
@ -429,8 +424,8 @@ void
|
|||
Init_pty()
|
||||
{
|
||||
cPTY = rb_define_module("PTY");
|
||||
rb_define_module_function(cPTY,"getpty",pty_getpty,1);
|
||||
rb_define_module_function(cPTY,"spawn",pty_getpty,1);
|
||||
rb_define_module_function(cPTY,"getpty",pty_getpty,-1);
|
||||
rb_define_module_function(cPTY,"spawn",pty_getpty,-1);
|
||||
rb_define_module_function(cPTY,"protect_signal",pty_protect,0);
|
||||
rb_define_module_function(cPTY,"reset_signal",pty_reset_signal,0);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,7 @@ $r_pty = nil
|
|||
$w_pty = nil
|
||||
|
||||
def writer
|
||||
PTY.protect_signal do
|
||||
system "stty -echo raw"
|
||||
end
|
||||
system "stty -echo raw"
|
||||
begin
|
||||
while true
|
||||
c = STDIN.getc
|
||||
|
@ -35,9 +33,7 @@ def writer
|
|||
$reader.raise(nil)
|
||||
return 'Exit'
|
||||
ensure
|
||||
PTY.protect_signal do
|
||||
system "stty echo -raw"
|
||||
end
|
||||
system "stty echo -raw"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1564,31 +1564,6 @@ module TkXIM
|
|||
end
|
||||
end
|
||||
|
||||
module TkXIM
|
||||
include Tk
|
||||
extend Tk
|
||||
|
||||
def TkXIM.useinputmethods(window=nil,value=nil)
|
||||
if window
|
||||
if value
|
||||
tk_call 'tk', 'useinputmethods', '-displayof', window.path, value
|
||||
else
|
||||
tk_call 'tk', 'useinputmethods', '-displayof', window.path
|
||||
end
|
||||
else
|
||||
if value
|
||||
tk_call 'tk', 'useinputmethods', value
|
||||
else
|
||||
tk_call 'tk', 'useinputmethods'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def useinputmethods(value=nil)
|
||||
TkXIM.useinputmethods(self,value)
|
||||
end
|
||||
end
|
||||
|
||||
module TkWinfo
|
||||
include Tk
|
||||
extend Tk
|
||||
|
|
|
@ -691,10 +691,10 @@ class TkFont
|
|||
def metrics_core_tk8x(font, window, option=nil)
|
||||
if option
|
||||
if window
|
||||
number(tk_call('font', 'metrics', font, "-#{option}"))
|
||||
else
|
||||
number(tk_call('font', 'metrics', font,
|
||||
"-displayof", window, "-#{option}"))
|
||||
else
|
||||
number(tk_call('font', 'metrics', font, "-#{option}"))
|
||||
end
|
||||
else
|
||||
l = tk_split_list(if window
|
||||
|
|
6
file.c
6
file.c
|
@ -1301,7 +1301,7 @@ rb_file_s_umask(argc, argv)
|
|||
omask = umask(NUM2INT(argv[0]));
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "wrong # of argument");
|
||||
rb_raise(rb_eArgError, "wrong number of argument");
|
||||
}
|
||||
return INT2FIX(omask);
|
||||
}
|
||||
|
@ -1742,7 +1742,7 @@ test_check(n, argc, argv)
|
|||
int i;
|
||||
|
||||
n+=1;
|
||||
if (n != argc) rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, n);
|
||||
if (n != argc) rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", argc, n);
|
||||
for (i=1; i<n; i++) {
|
||||
switch (TYPE(argv[i])) {
|
||||
case T_STRING:
|
||||
|
@ -1766,7 +1766,7 @@ rb_f_test(argc, argv)
|
|||
{
|
||||
int cmd;
|
||||
|
||||
if (argc == 0) rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
if (argc == 0) rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
#if 0 /* 1.7 behavior? */
|
||||
if (argc == 1) {
|
||||
return RTEST(argv[0]) ? Qtrue : Qfalse;
|
||||
|
|
177
gc.c
177
gc.c
|
@ -21,6 +21,10 @@
|
|||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
void re_free_registers _((struct re_registers*));
|
||||
void rb_io_fptr_finalize _((struct OpenFile*));
|
||||
|
||||
|
@ -345,71 +349,21 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
|
|||
extern st_table *rb_class_tbl;
|
||||
VALUE *rb_gc_stack_start = 0;
|
||||
|
||||
|
||||
#define MARK_STACK_MAX 1024
|
||||
static VALUE mark_stack[MARK_STACK_MAX];
|
||||
static VALUE *mark_stack_ptr;
|
||||
static int mark_stack_overflow;
|
||||
|
||||
static void
|
||||
init_mark_stack()
|
||||
{
|
||||
mark_stack_overflow = 0;
|
||||
mark_stack_ptr = mark_stack;
|
||||
memset(mark_stack, 0, MARK_STACK_MAX);
|
||||
}
|
||||
|
||||
#define MARK_STACK_EMPTY (mark_stack_ptr == mark_stack)
|
||||
|
||||
static int mark_all;
|
||||
|
||||
static void rb_gc_mark_children(VALUE ptr);
|
||||
static void
|
||||
gc_mark_all()
|
||||
{
|
||||
RVALUE *p, *pend;
|
||||
int i;
|
||||
mark_all = 0;
|
||||
while(!mark_all){
|
||||
mark_all = 1;
|
||||
for (i = 0; i < heaps_used; i++) {
|
||||
p = heaps[i]; pend = p + heaps_limits[i];
|
||||
while (p < pend) {
|
||||
if (!(rb_special_const_p((VALUE)p))
|
||||
&& p->as.basic.flags&FL_MARK) {
|
||||
rb_gc_mark_children((VALUE)p);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gc_mark_rest()
|
||||
{
|
||||
VALUE tmp_arry[MARK_STACK_MAX];
|
||||
VALUE *p;
|
||||
|
||||
p = (mark_stack_ptr - mark_stack) + tmp_arry;
|
||||
memcpy(tmp_arry, mark_stack, MARK_STACK_MAX);
|
||||
|
||||
init_mark_stack();
|
||||
|
||||
while(p != tmp_arry){
|
||||
p--;
|
||||
rb_gc_mark(*p);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(DJGPP)
|
||||
# define STACK_LEVEL_MAX 65535;
|
||||
#elif defined(__human68k__)
|
||||
#ifdef DJGPP
|
||||
static unsigned int STACK_LEVEL_MAX = 65535;
|
||||
#else
|
||||
#ifdef __human68k__
|
||||
extern unsigned int _stacksize;
|
||||
# define STACK_LEVEL_MAX (_stacksize - 4096)
|
||||
# undef HAVE_GETRLIMIT
|
||||
#else
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
static unsigned int STACK_LEVEL_MAX = 655300;
|
||||
#else
|
||||
# define STACK_LEVEL_MAX 655300
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef C_ALLOCA
|
||||
# define SET_STACK_END VALUE stack_end; alloca(0);
|
||||
|
@ -431,9 +385,87 @@ extern unsigned int _stacksize;
|
|||
|
||||
#define CHECK_STACK(ret) do {\
|
||||
SET_STACK_END;\
|
||||
ret = (STACK_LENGTH > STACK_LEVEL_MAX);\
|
||||
(ret) = (STACK_LENGTH > STACK_LEVEL_MAX);\
|
||||
} while (0)\
|
||||
|
||||
int
|
||||
ruby_stack_length(p)
|
||||
VALUE **p;
|
||||
{
|
||||
int ret;
|
||||
|
||||
SET_STACK_END;
|
||||
if (p) *p = STACK_END;
|
||||
return STACK_LENGTH;
|
||||
}
|
||||
|
||||
static VALUE rb_eSysStackError;
|
||||
|
||||
void
|
||||
ruby_stack_check()
|
||||
{
|
||||
int ret;
|
||||
|
||||
CHECK_STACK(ret);
|
||||
if (ret) {
|
||||
rb_raise(rb_eSysStackError, "stack level too deep");
|
||||
}
|
||||
}
|
||||
|
||||
#define MARK_STACK_MAX 1024
|
||||
static VALUE mark_stack[MARK_STACK_MAX];
|
||||
static VALUE *mark_stack_ptr;
|
||||
static int mark_stack_overflow;
|
||||
|
||||
static void
|
||||
init_mark_stack()
|
||||
{
|
||||
mark_stack_overflow = 0;
|
||||
mark_stack_ptr = mark_stack;
|
||||
}
|
||||
|
||||
#define MARK_STACK_EMPTY (mark_stack_ptr == mark_stack)
|
||||
|
||||
static int mark_all;
|
||||
|
||||
static void rb_gc_mark_children(VALUE ptr);
|
||||
static void
|
||||
gc_mark_all()
|
||||
{
|
||||
RVALUE *p, *pend;
|
||||
int i;
|
||||
mark_all = 0;
|
||||
while(!mark_all){
|
||||
mark_all = 1;
|
||||
for (i = 0; i < heaps_used; i++) {
|
||||
p = heaps[i]; pend = p + heaps_limits[i];
|
||||
while (p < pend) {
|
||||
if ((p->as.basic.flags & FL_MARK) &&
|
||||
(p->as.basic.flags != FL_MARK)) {
|
||||
rb_gc_mark_children((VALUE)p);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gc_mark_rest()
|
||||
{
|
||||
VALUE tmp_arry[MARK_STACK_MAX];
|
||||
VALUE *p;
|
||||
|
||||
p = (mark_stack_ptr - mark_stack) + tmp_arry;
|
||||
MEMCPY(tmp_arry, mark_stack, VALUE, MARK_STACK_MAX);
|
||||
|
||||
init_mark_stack();
|
||||
|
||||
while(p != tmp_arry){
|
||||
p--;
|
||||
rb_gc_mark(*p);
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
is_pointer_to_heap(ptr)
|
||||
|
@ -534,6 +566,10 @@ rb_gc_mark(ptr)
|
|||
{
|
||||
register RVALUE *obj = RANY(ptr);
|
||||
|
||||
if (rb_special_const_p(ptr)) return; /* special const not marked */
|
||||
if (obj->as.basic.flags == 0) return; /* free cell */
|
||||
if (obj->as.basic.flags & FL_MARK) return; /* already marked */
|
||||
|
||||
if (!mark_stack_overflow){
|
||||
int ret;
|
||||
CHECK_STACK(ret);
|
||||
|
@ -544,15 +580,10 @@ rb_gc_mark(ptr)
|
|||
return;
|
||||
}else{
|
||||
mark_stack_overflow = 1;
|
||||
printf("mark_stack_overflow\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rb_special_const_p((VALUE)obj)) return; /* special const not marked */
|
||||
if (obj->as.basic.flags == 0) return; /* free cell */
|
||||
if (obj->as.basic.flags & FL_MARK) return; /* already marked */
|
||||
|
||||
obj->as.basic.flags |= FL_MARK;
|
||||
|
||||
if (mark_stack_overflow){
|
||||
|
@ -1171,6 +1202,18 @@ Init_stack(addr)
|
|||
if (!addr) addr = &start;
|
||||
rb_gc_stack_start = addr;
|
||||
#endif
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
{
|
||||
struct rlimit rlim;
|
||||
|
||||
if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
|
||||
double space = (double)rlim.rlim_cur*0.2;
|
||||
|
||||
if (space > 1024*1024) space = 1024*1024;
|
||||
STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1474,4 +1517,6 @@ Init_GC()
|
|||
rb_global_variable(&finalizers);
|
||||
rb_gc_unregister_address(&rb_mObSpace);
|
||||
finalizers = rb_ary_new();
|
||||
|
||||
rb_eSysStackError = rb_define_class("SystemStackError", rb_eStandardError);
|
||||
}
|
||||
|
|
4
hash.c
4
hash.c
|
@ -303,7 +303,7 @@ rb_hash_fetch(argc, argv, hash)
|
|||
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
|
||||
if (rb_block_given_p()) {
|
||||
if (argc > 1) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments", argc);
|
||||
}
|
||||
return rb_yield(key);
|
||||
}
|
||||
|
@ -928,7 +928,7 @@ env_fetch(argc, argv)
|
|||
if (!env) {
|
||||
if (rb_block_given_p()) {
|
||||
if (argc > 1) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments", argc);
|
||||
}
|
||||
return rb_yield(key);
|
||||
}
|
||||
|
|
17
intern.h
17
intern.h
|
@ -107,13 +107,11 @@ void rb_define_singleton_method _((VALUE, const char*, VALUE(*)(ANYARGS), int));
|
|||
void rb_define_private_method _((VALUE, const char*, VALUE(*)(ANYARGS), int));
|
||||
VALUE rb_singleton_class _((VALUE));
|
||||
/* enum.c */
|
||||
VALUE rb_enum_length _((VALUE));
|
||||
/* error.c */
|
||||
EXTERN int ruby_nerrs;
|
||||
VALUE rb_exc_new _((VALUE, const char*, long));
|
||||
VALUE rb_exc_new2 _((VALUE, const char*));
|
||||
VALUE rb_exc_new3 _((VALUE, VALUE));
|
||||
void rb_stack_check _((void));
|
||||
NORETURN(void rb_loaderror __((const char*, ...)));
|
||||
NORETURN(void rb_name_error __((VALUE id, const char*, ...)));
|
||||
void rb_compile_error __((const char*, ...));
|
||||
|
@ -191,6 +189,8 @@ void rb_file_const _((const char*, VALUE));
|
|||
int rb_find_file_ext _((VALUE*, const char* const*));
|
||||
VALUE rb_find_file _((VALUE));
|
||||
/* gc.c */
|
||||
void ruby_stack_check _((void));
|
||||
int ruby_stack_length _((VALUE**));
|
||||
void rb_gc_mark_locations _((VALUE*, VALUE*));
|
||||
void rb_mark_tbl _((struct st_table*));
|
||||
void rb_mark_hash _((struct st_table*));
|
||||
|
@ -259,12 +259,12 @@ VALUE rb_Array _((VALUE));
|
|||
/* parse.y */
|
||||
EXTERN int ruby_sourceline;
|
||||
EXTERN char *ruby_sourcefile;
|
||||
#define yyparse rb_yyparse
|
||||
#define yylex rb_yylex
|
||||
#define yyerror rb_yyerror
|
||||
#define yylval rb_yylval
|
||||
#define yychar rb_yychar
|
||||
#define yydebug rb_yydebug
|
||||
#define yyparse ruby_yyparse
|
||||
#define yylex ruby_yylex
|
||||
#define yyerror ruby_yyerror
|
||||
#define yylval ruby_yylval
|
||||
#define yychar ruby_yychar
|
||||
#define yydebug ruby_yydebug
|
||||
int yyparse _((void));
|
||||
ID rb_id_attrset _((ID));
|
||||
void rb_parser_append_print _((void));
|
||||
|
@ -280,6 +280,7 @@ void rb_lastline_set _((VALUE));
|
|||
VALUE rb_sym_all_symbols _((void));
|
||||
/* process.c */
|
||||
int rb_proc_exec _((const char*));
|
||||
VALUE rb_f_exec _((int,VALUE*));
|
||||
int rb_waitpid _((int,int*,int));
|
||||
void rb_syswait _((int));
|
||||
VALUE rb_proc_times _((VALUE));
|
||||
|
|
5
io.c
5
io.c
|
@ -2206,6 +2206,11 @@ rb_io_puts(argc, argv, out)
|
|||
line = rb_str_new2("nil");
|
||||
}
|
||||
else {
|
||||
#if 0
|
||||
if (TYPE(argv[i]) == T_ARRAY) {
|
||||
rb_warn("puts behavior changed for Array");
|
||||
}
|
||||
#endif
|
||||
line = rb_obj_as_string(argv[i]);
|
||||
}
|
||||
rb_io_write(out, line);
|
||||
|
|
|
@ -132,7 +132,7 @@ class PStore
|
|||
ensure
|
||||
@table = nil
|
||||
@transaction = false
|
||||
file.close
|
||||
file.close if file
|
||||
end
|
||||
value
|
||||
end
|
||||
|
|
32
marshal.c
32
marshal.c
|
@ -10,6 +10,8 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "ruby.h"
|
||||
#include "rubyio.h"
|
||||
#include "st.h"
|
||||
|
@ -52,7 +54,7 @@ shortlen(len, ds)
|
|||
#endif
|
||||
|
||||
#define MARSHAL_MAJOR 4
|
||||
#define MARSHAL_MINOR 6
|
||||
#define MARSHAL_MINOR 7
|
||||
|
||||
#define TYPE_NIL '0'
|
||||
#define TYPE_TRUE 'T'
|
||||
|
@ -185,7 +187,17 @@ w_float(d, arg)
|
|||
{
|
||||
char buf[100];
|
||||
|
||||
sprintf(buf, "%.16g", d);
|
||||
if (isinf(d)) {
|
||||
if (d < 0) strcpy(buf, "-inf");
|
||||
else strcpy(buf, "inf");
|
||||
}
|
||||
else if (isnan(d)) {
|
||||
strcpy(buf, "nan");
|
||||
}
|
||||
else {
|
||||
/* xxx: should not use system's sprintf(3) */
|
||||
sprintf(buf, "%.16g", d);
|
||||
}
|
||||
w_bytes(buf, strlen(buf), arg);
|
||||
}
|
||||
|
||||
|
@ -832,9 +844,23 @@ r_object(arg)
|
|||
case TYPE_FLOAT:
|
||||
{
|
||||
char *buf;
|
||||
double d, t = 0.0;
|
||||
|
||||
r_bytes(buf, arg);
|
||||
v = rb_float_new(strtod(buf, 0));
|
||||
if (strcmp(buf, "nan") == 0) {
|
||||
d = t / t;
|
||||
}
|
||||
else if (strcmp(buf, "inf") == 0) {
|
||||
d = 1.0 / t;
|
||||
}
|
||||
else if (strcmp(buf, "-inf") == 0) {
|
||||
d = -1.0 / t;
|
||||
}
|
||||
else {
|
||||
/* xxx: should not use system's strtod(3) */
|
||||
d = strtod(buf, 0);
|
||||
}
|
||||
v = rb_float_new(d);
|
||||
return r_regist(v, arg);
|
||||
}
|
||||
|
||||
|
|
31
numeric.c
31
numeric.c
|
@ -960,17 +960,30 @@ rb_fix2str(x, base)
|
|||
if (base == 10) fmt[2] = 'd';
|
||||
else if (base == 16) fmt[2] = 'x';
|
||||
else if (base == 8) fmt[2] = 'o';
|
||||
else rb_fatal("fixnum cannot treat base %d", base);
|
||||
else rb_raise(rb_eArgError, "illegal radix %d", base);
|
||||
|
||||
sprintf(buf, fmt, FIX2LONG(x));
|
||||
return rb_str_new2(buf);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
fix_to_s(in)
|
||||
VALUE in;
|
||||
fix_to_s(argc, argv, x)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE x;
|
||||
{
|
||||
return rb_fix2str(in, 10);
|
||||
VALUE b;
|
||||
int base;
|
||||
|
||||
rb_scan_args(argc, argv, "01", &b);
|
||||
if (argc == 0) base = 10;
|
||||
else base = NUM2INT(b);
|
||||
|
||||
if (base == 2) {
|
||||
/* rb_fix2str() does not handle binary */
|
||||
return rb_big2str(rb_int2big(FIX2INT(x)), 2);
|
||||
}
|
||||
return rb_fix2str(x, base);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -1342,13 +1355,6 @@ fix_to_f(num)
|
|||
return rb_float_new(val);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
fix_type(fix)
|
||||
VALUE fix;
|
||||
{
|
||||
return rb_cFixnum;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
fix_abs(fix)
|
||||
VALUE fix;
|
||||
|
@ -1606,8 +1612,7 @@ Init_Numeric()
|
|||
rb_define_singleton_method(rb_cFixnum, "induced_from", rb_fix_induced_from, 1);
|
||||
rb_define_singleton_method(rb_cInteger, "induced_from", rb_int_induced_from, 1);
|
||||
|
||||
rb_define_method(rb_cFixnum, "to_s", fix_to_s, 0);
|
||||
rb_define_method(rb_cFixnum, "type", fix_type, 0);
|
||||
rb_define_method(rb_cFixnum, "to_s", fix_to_s, -1);
|
||||
|
||||
rb_define_method(rb_cFixnum, "id2name", fix_id2name, 0);
|
||||
|
||||
|
|
7
pack.c
7
pack.c
|
@ -1420,12 +1420,12 @@ pack_unpack(str, fmt)
|
|||
|
||||
case 'U':
|
||||
if (len > send - s) len = send - s;
|
||||
while (len-- > 0 && s < send) {
|
||||
int alen;
|
||||
while (len > 0 && s < send) {
|
||||
int alen = len;
|
||||
unsigned long l;
|
||||
|
||||
l = utf8_to_uv(s, &alen);
|
||||
s += alen;
|
||||
s += alen; len -= alen;
|
||||
rb_ary_push(ary, rb_uint2inum(l));
|
||||
}
|
||||
break;
|
||||
|
@ -1767,6 +1767,7 @@ utf8_to_uv(p, lenp)
|
|||
else if (c < 0xfc) n = 5;
|
||||
else if (c < 0xfe) n = 6;
|
||||
else if (c == 0xfe) n = 7;
|
||||
if (n > *lenp) return 0;
|
||||
*lenp = n--;
|
||||
|
||||
uv = c;
|
||||
|
|
14
process.c
14
process.c
|
@ -673,7 +673,7 @@ proc_spawn(sv)
|
|||
}
|
||||
#endif /* __human68k__ */
|
||||
|
||||
static VALUE
|
||||
VALUE
|
||||
rb_f_exec(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
|
@ -681,7 +681,7 @@ rb_f_exec(argc, argv)
|
|||
VALUE prog = 0;
|
||||
|
||||
if (argc == 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
||||
if (TYPE(argv[0]) == T_ARRAY) {
|
||||
|
@ -804,7 +804,7 @@ rb_f_system(argc, argv)
|
|||
fflush(stderr);
|
||||
if (argc == 0) {
|
||||
rb_last_status = Qnil;
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
||||
if (TYPE(argv[0]) == T_ARRAY) {
|
||||
|
@ -828,7 +828,7 @@ rb_f_system(argc, argv)
|
|||
|
||||
if (argc == 0) {
|
||||
rb_last_status = Qnil;
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
||||
if (TYPE(argv[0]) == T_ARRAY) {
|
||||
|
@ -856,7 +856,7 @@ rb_f_system(argc, argv)
|
|||
fflush(stderr);
|
||||
if (argc == 0) {
|
||||
rb_last_status = Qnil;
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
||||
if (TYPE(argv[0]) == T_ARRAY) {
|
||||
|
@ -884,7 +884,7 @@ rb_f_system(argc, argv)
|
|||
fflush(stderr);
|
||||
if (argc == 0) {
|
||||
rb_last_status = Qnil;
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
||||
if (TYPE(argv[0]) == T_ARRAY) {
|
||||
|
@ -948,7 +948,7 @@ rb_f_sleep(argc, argv)
|
|||
rb_thread_wait_for(rb_time_interval(argv[0]));
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
||||
end = time(0) - beg;
|
||||
|
|
2
re.c
2
re.c
|
@ -1013,7 +1013,7 @@ rb_reg_initialize_m(argc, argv, self)
|
|||
int flags = 0;
|
||||
|
||||
if (argc == 0 || argc > 3) {
|
||||
rb_raise(rb_eArgError, "wrong # of argument");
|
||||
rb_raise(rb_eArgError, "wrong number of argument");
|
||||
}
|
||||
if (argc >= 2) {
|
||||
if (FIXNUM_P(argv[1])) flags = FIX2INT(argv[1]);
|
||||
|
|
4
signal.c
4
signal.c
|
@ -205,7 +205,7 @@ rb_f_kill(argc, argv)
|
|||
|
||||
rb_secure(2);
|
||||
if (argc < 2)
|
||||
rb_raise(rb_eArgError, "wrong # of arguments -- kill(sig, pid...)");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments -- kill(sig, pid...)");
|
||||
switch (TYPE(argv[0])) {
|
||||
case T_FIXNUM:
|
||||
sig = FIX2INT(argv[0]);
|
||||
|
@ -617,7 +617,7 @@ sig_trap(argc, argv)
|
|||
|
||||
rb_secure(2);
|
||||
if (argc == 0 || argc > 2) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments -- trap(sig, cmd)/trap(sig){...}");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments -- trap(sig, cmd)/trap(sig){...}");
|
||||
}
|
||||
|
||||
arg.sig = argv[0];
|
||||
|
|
14
string.c
14
string.c
|
@ -1139,7 +1139,7 @@ rb_str_aref_m(argc, argv, str)
|
|||
return rb_str_substr(str, NUM2INT(argv[0]), NUM2INT(argv[1]));
|
||||
}
|
||||
if (argc != 1) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc);
|
||||
}
|
||||
return rb_str_aref(str, argv[0]);
|
||||
}
|
||||
|
@ -1295,7 +1295,7 @@ rb_str_aset_m(argc, argv, str)
|
|||
return argv[2];
|
||||
}
|
||||
if (argc != 2) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 2)", argc);
|
||||
}
|
||||
return rb_str_aset(str, argv[0], argv[1]);
|
||||
}
|
||||
|
@ -1328,7 +1328,7 @@ rb_str_slice_bang(argc, argv, str)
|
|||
int i;
|
||||
|
||||
if (argc < 1 || 2 < argc) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc);
|
||||
}
|
||||
for (i=0; i<argc; i++) {
|
||||
buf[i] = argv[i];
|
||||
|
@ -1379,7 +1379,7 @@ rb_str_sub_bang(argc, argv, str)
|
|||
if (OBJ_TAINTED(repl)) tainted = 1;
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 2)", argc);
|
||||
}
|
||||
|
||||
pat = get_pat(argv[0]);
|
||||
|
@ -1453,7 +1453,7 @@ str_gsub(argc, argv, str, bang)
|
|||
if (OBJ_TAINTED(repl)) tainted = 1;
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
|
||||
rb_raise(rb_eArgError, "wrong number of arguments(%d for 2)", argc);
|
||||
}
|
||||
|
||||
pat = get_pat(argv[0]);
|
||||
|
@ -2225,7 +2225,7 @@ rb_str_delete_bang(argc, argv, str)
|
|||
int i;
|
||||
|
||||
if (argc < 1) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
for (i=0; i<argc; i++) {
|
||||
VALUE s = argv[i];
|
||||
|
@ -2350,7 +2350,7 @@ rb_str_count(argc, argv, str)
|
|||
int i;
|
||||
|
||||
if (argc < 1) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
for (i=0; i<argc; i++) {
|
||||
VALUE s = argv[i];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define RUBY_VERSION "1.7.2"
|
||||
#define RUBY_RELEASE_DATE "2001-11-18"
|
||||
#define RUBY_RELEASE_DATE "2001-11-19"
|
||||
#define RUBY_VERSION_CODE 172
|
||||
#define RUBY_RELEASE_CODE 20011118
|
||||
#define RUBY_RELEASE_CODE 20011119
|
||||
|
|
Загрузка…
Ссылка в новой задаче