From 1d1b8102bcb38b982855395e97067139190de1d8 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 1 Nov 2004 23:49:16 +0000 Subject: [PATCH] * eval.c (proc_invoke): nail down dyna_var node when Proc object or continuation is created. [ruby-dev:24671] * io.c (rb_io_s_popen): do not expand argv array. [ruby-dev:24670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 ++++++++++++++ eval.c | 59 ++++++++++++++++-------------------------------------- io.c | 28 +++++++++++--------------- lib/cgi.rb | 2 +- regcomp.c | 1 - regexec.c | 3 ++- 6 files changed, 47 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3e445e9ab..3204e9153f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Nov 2 01:20:09 2004 Yukihiro Matsumoto + + * eval.c (proc_invoke): nail down dyna_var node when Proc object + or continuation is created. [ruby-dev:24671] + + * io.c (rb_io_s_popen): do not expand argv array. [ruby-dev:24670] + Mon Nov 1 22:25:56 2004 Kouhei Sutou * lib/rss/maker/base.rb: changed xml-stylesheet's API of RSS Maker @@ -32,6 +39,14 @@ Mon Nov 1 09:37:19 2004 Kouhei Sutou * lib/rss/maker.rb: added entry point of RSS Maker. +Mon Nov 1 03:14:14 2004 Yukihiro Matsumoto + + * eval.c (rb_get_method_body): store ICLASS in the cache. + [ruby-core:03672] + + * eval.c (rb_provided): should return true for loading library + too for autoloading. [ruby-core:03655] + Mon Nov 1 01:14:52 2004 Yukihiro Matsumoto * io.c (rb_f_open): create copy of popen specifier. [ruby-dev:24656] diff --git a/eval.c b/eval.c index e26e1652cc..40b79fe99a 100644 --- a/eval.c +++ b/eval.c @@ -412,7 +412,6 @@ rb_get_method_body(klassp, idp, noexp) if (ruby_running) { /* store in cache */ - if (BUILTIN_TYPE(origin) == T_ICLASS) origin = RBASIC(origin)->klass; ent = cache + EXPR1(klass, id); ent->klass = klass; ent->noex = body->nd_noex; @@ -2177,18 +2176,6 @@ arg_defined(self, node, buf, type) return type; } -static VALUE -search_iclass(self, klass) - VALUE self, klass; -{ - VALUE k = CLASS_OF(self); - - while (k && !(BUILTIN_TYPE(k) == T_ICLASS && RBASIC(k)->klass == klass)) { - k = RCLASS(k)->super; - } - return k; -} - static const char* is_defined(self, node, buf, noeval) VALUE self; @@ -2207,10 +2194,6 @@ is_defined(self, node, buf, noeval) if (ruby_frame->orig_func == 0) return 0; else if (ruby_frame->last_class == 0) return 0; val = ruby_frame->last_class; - if (BUILTIN_TYPE(val) == T_MODULE) { - val = search_iclass(self, val); - if (!val) return 0; - } if (rb_method_boundp(RCLASS(val)->super, ruby_frame->orig_func, 0)) { if (nd_type(node) == NODE_SUPER) { return arg_defined(self, node->nd_args, buf, "super"); @@ -5861,20 +5844,6 @@ rb_call_super(argc, argv) self = ruby_frame->self; klass = ruby_frame->last_class; - if (BUILTIN_TYPE(klass) == T_MODULE) { - k = search_iclass(self, klass); - if (!k) { - rb_raise(rb_eTypeError, "%s is not included in %s", - rb_class2name(klass), - rb_class2name(CLASS_OF(self))); - } - if (RCLASS(k)->super == 0) { - rb_name_error(ruby_frame->last_func, - "super: no superclass method `%s'", - rb_id2name(ruby_frame->last_func)); - } - klass = k; - } PUSH_ITER(ruby_iter->iter ? ITER_PRE : ITER_NOT); result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3); @@ -6623,7 +6592,21 @@ int rb_provided(feature) const char *feature; { - return rb_feature_p(feature, 0, Qfalse) ? Qtrue : Qfalse; + int i; + char *buf; + + if (rb_feature_p(feature, 0, Qfalse)) + return Qtrue; + if (!loading_tbl) return Qfalse; + if (st_lookup(loading_tbl, (st_data_t)feature, 0)) return Qtrue; + buf = ALLOCA_N(char, strlen(feature)+8); + strcpy(buf, feature); + for (i=0; ; i++) { + if (!loadable_ext[i]) break; + strcpy(buf+strlen(feature), loadable_ext[i]); + if (st_lookup(loading_tbl, (st_data_t)buf, 0)) return Qtrue; + } + return Qfalse; } static void @@ -8112,7 +8095,6 @@ proc_invoke(proc, args, self, klass) int state; volatile int safe = ruby_safe_level; volatile VALUE old_wrapper = ruby_wrapper; - struct RVarmap * volatile old_dvars = ruby_dyna_vars; volatile int pcall, avalue = Qtrue; VALUE bvar = Qnil; @@ -8129,6 +8111,7 @@ proc_invoke(proc, args, self, klass) args = RARRAY(args)->ptr[0]; } + PUSH_VARS(); ruby_wrapper = data->wrapper; ruby_dyna_vars = data->dyna_vars; /* PUSH BLOCK from data */ @@ -8155,15 +8138,7 @@ proc_invoke(proc, args, self, klass) POP_ITER(); ruby_block = old_block; ruby_wrapper = old_wrapper; - if (FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE)) { - struct RVarmap *vars; - - for (vars = old_dvars; vars; vars = vars->next) { - if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break; - FL_SET(vars, DVAR_DONT_RECYCLE); - } - } - ruby_dyna_vars = old_dvars; + POP_VARS(); if (proc_safe_level_p(proc)) ruby_safe_level = safe; switch (state) { diff --git a/io.c b/io.c index a71214121b..65605d2d03 100644 --- a/io.c +++ b/io.c @@ -2793,7 +2793,7 @@ pipe_open(argc, argv, pname, mode) argc = 0; prog = argv[0]; } - pname = StringValuePtr(prog); + pname = StringValueCStr(prog); } cmd = pname; @@ -2971,25 +2971,21 @@ rb_io_s_popen(argc, argv, klass) } tmp = rb_check_array_type(pname); if (!NIL_P(tmp)) { - long argc = RARRAY(tmp)->len; - VALUE *argv = ALLOCA_N(VALUE, argc); - - MEMCPY(argv, RARRAY(tmp)->ptr, VALUE, argc); - port = pipe_open(argc, argv, 0, mode); + pname = tmp; } else { SafeStringValue(pname); - port = pipe_open(1, &pname, 0, mode); - if (NIL_P(port)) { - /* child */ - if (rb_block_given_p()) { - rb_yield(Qnil); - fflush(stdout); - fflush(stderr); - _exit(0); - } - return Qnil; + } + port = pipe_open(1, &pname, 0, mode); + if (NIL_P(port)) { + /* child */ + if (rb_block_given_p()) { + rb_yield(Qnil); + fflush(stdout); + fflush(stderr); + _exit(0); } + return Qnil; } RBASIC(port)->klass = klass; if (rb_block_given_p()) { diff --git a/lib/cgi.rb b/lib/cgi.rb index 9f3f7c0e04..22544d9059 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -1023,7 +1023,7 @@ class CGI content_length -= c.size end - buf = buf.sub(/\A((?:.|\n)*?)(?:#{EOL})?#{boundary}(#{EOL}|#{LF}|--)/n) do + buf = buf.sub(/\A((?:.|\n)*?)(?:[\r\n]{1,2})?#{boundary}([\r\n]{1,2}|--)/n) do body.print $1 if "--" == $2 content_length = -1 diff --git a/regcomp.c b/regcomp.c index b1a7b0ad14..3b62e18b43 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4922,7 +4922,6 @@ onig_end() return 0; } - #ifdef ONIG_DEBUG OnigOpInfoType OnigOpInfo[] = { diff --git a/regexec.c b/regexec.c index 7c8ffa47a9..a0625fdf7e 100644 --- a/regexec.c +++ b/regexec.c @@ -2206,7 +2206,8 @@ match_at(regex_t* reg, UChar* str, UChar* end, UChar* sstart, repeat_inc_ng: stkp->u.repeat.count++; - if (stkp->u.repeat.count < reg->repeat_range[mem].upper) { + if (stkp->u.repeat.count < reg->repeat_range[mem].upper + || reg->repeat_range[mem].upper < 0 /* IS_REPEAT_INFINITE(upper) */) { if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) { UChar* pcode = stkp->u.repeat.pcode;