From 552fb72159d3bb27ff40ecc121bbc52a3fff89a1 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 23 Jun 2000 07:05:59 +0000 Subject: 2000-06-23 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ bignum.c | 9 ++------- eval.c | 2 +- lib/cgi.rb | 20 ++++++++++---------- marshal.c | 2 +- parse.y | 16 ++++++++++++++-- sample/test.rb | 11 +++++++++++ string.c | 9 +++++++-- version.h | 4 ++-- 9 files changed, 59 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7c504f65d..b65b9b2f7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Fri Jun 23 01:11:27 2000 Yukihiro Matsumoto + + * string.c (rb_str_substr): should return empty string (""), + if beg == str.size and len == zero, mostly for convenience and + backward compatibility. + + * parse.y (new_super): should tweak block_pass node for super too. + + * string.c (rb_str_split_m): last split element should not be nil, + but "" when limit is specified. + Thu Jun 22 17:27:46 2000 Yukihiro Matsumoto * string.c (rb_str_substr): str[n,m] now returns nil when n equals diff --git a/bignum.c b/bignum.c index ec36a0946c..385ec7b4e3 100644 --- a/bignum.c +++ b/bignum.c @@ -899,13 +899,8 @@ bigdivmod(x, y, div, mod, modulo) RBIGNUM(*mod)->len = ny; RBIGNUM(*mod)->sign = RBIGNUM(x)->sign; if (modulo && RBIGNUM(x)->sign != RBIGNUM(y)->sign) { - long len = ny; - zds = BDIGITS(*mod); - while (len && !zds[len]) len--; - if (len > 0) { - *mod = bigadd(*mod, y, 1); - return; - } + *mod = bigadd(*mod, y, 1); + return; } *mod = bignorm(*mod); } diff --git a/eval.c b/eval.c index c92384fd7c..05a1b06ca1 100644 --- a/eval.c +++ b/eval.c @@ -4850,7 +4850,7 @@ rb_load(fname, wrap) PUSH_FRAME(); ruby_frame->last_func = 0; ruby_frame->last_class = 0; - ruby_frame->self = ruby_top_self; + ruby_frame->self = self; ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,ruby_class,0,0); PUSH_SCOPE(); if (ruby_class == rb_cObject && top_scope->local_tbl) { diff --git a/lib/cgi.rb b/lib/cgi.rb index 4fc2ca71ea..7f40c3a0f6 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -975,7 +975,7 @@ convert string charset, and set language to "ja". '="' + CGI::escapeHTML(value) + '"' end }.to_s + ">" + - if iterator? + if block_given? yield.to_s else "" @@ -1011,7 +1011,7 @@ convert string charset, and set language to "ja". '="' + CGI::escapeHTML(value) + '"' end }.to_s + ">" + - if iterator? + if block_given? yield.to_s + "" else "" @@ -1036,7 +1036,7 @@ convert string charset, and set language to "ja". else href end - if iterator? + if block_given? super(attributes){ yield } else super(attributes) @@ -1055,7 +1055,7 @@ convert string charset, and set language to "ja". else href end - if iterator? + if block_given? super(attributes){ yield } else super(attributes) @@ -1074,7 +1074,7 @@ convert string charset, and set language to "ja". else cite or "" end - if iterator? + if block_given? super(attributes){ yield } else super(attributes) @@ -1093,7 +1093,7 @@ convert string charset, and set language to "ja". else align or "" end - if iterator? + if block_given? super(attributes){ yield } else super(attributes) @@ -1225,7 +1225,7 @@ convert string charset, and set language to "ja". end method end - if iterator? + if block_given? body = yield else body = "" @@ -1315,7 +1315,7 @@ convert string charset, and set language to "ja". buf.concat( doctype ) end - if iterator? + if block_given? buf.concat( super(attributes){ yield } ) else buf.concat( super(attributes) ) @@ -1397,7 +1397,7 @@ convert string charset, and set language to "ja". end action end - if iterator? + if block_given? form(attributes){ yield } else form(attributes) @@ -1672,7 +1672,7 @@ convert string charset, and set language to "ja". else name end - if iterator? + if block_given? super(attributes){ yield } else super(attributes) diff --git a/marshal.c b/marshal.c index 19a06a99f4..af4a9fa6e3 100644 --- a/marshal.c +++ b/marshal.c @@ -985,7 +985,7 @@ Init_marshal() s_load = rb_intern("_load"); rb_define_module_function(rb_mMarshal, "dump", marshal_dump, -1); rb_define_module_function(rb_mMarshal, "load", marshal_load, -1); - rb_define_module_function(rb_mMarshal, "restore", marshal_load, 1); + rb_define_module_function(rb_mMarshal, "restore", marshal_load, -1); rb_provide("marshal.so"); /* for backward compatibility */ } diff --git a/parse.y b/parse.y index 75c0ad8acd..7b47c7f6ed 100644 --- a/parse.y +++ b/parse.y @@ -83,6 +83,7 @@ static int in_defined = 0; static NODE *arg_blk_pass(); static NODE *new_call(); static NODE *new_fcall(); +static NODE *new_super(); static NODE *gettable(); static NODE *assignable(); @@ -451,7 +452,7 @@ command_call : operation call_args { if (!compile_for_eval && !cur_mid && !in_single) yyerror("super called outside of method"); - $$ = NEW_SUPER($2); + $$ = new_super($2); fixpos($$, $2); } @@ -1390,7 +1391,7 @@ method_call : operation '(' opt_call_args close_paren if (!compile_for_eval && !cur_mid && !in_single && !in_defined) yyerror("super called outside of method"); - $$ = NEW_SUPER($3); + $$ = new_super($3); } | kSUPER { @@ -4387,6 +4388,17 @@ new_fcall(m,a) return NEW_FCALL(m,a); } +static NODE* +new_super(a) + NODE *a; +{ + if (a && nd_type(a) == NODE_BLOCK_PASS) { + a->nd_iter = NEW_SUPER(a->nd_head); + return a; + } + return NEW_SUPER(a); +} + static struct local_vars { ID *tbl; int nofree; diff --git a/sample/test.rb b/sample/test.rb index 8f789fdd88..9da67f5722 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -607,6 +607,17 @@ for i in 4000..4096 end ok($good) +b = 10**80 +a = b * 9 + 7 +ok(7 == a % b) +ok(7-b == a % (-b)) +ok(b-7 == (-a) % b) +ok(-7 ==(-a) % (-b)) +ok(7 ==a.remainder(b)) +ok(7 ==a.remainder(-b)) +ok(-7 == (-a).remainder(b)) +ok(-7 == (-a).remainder(-b)) + check "string & char" ok("abcd" == "abcd") diff --git a/string.c b/string.c index f6ae91bdf1..7943465ef3 100644 --- a/string.c +++ b/string.c @@ -329,7 +329,8 @@ rb_str_substr(str, beg, len) VALUE str2; if (len < 0) return Qnil; - if (beg >= RSTRING(str)->len) return Qnil; + if (beg > RSTRING(str)->len) return Qnil; + if (beg == RSTRING(str)->len && len > 0) return Qnil; if (beg < 0) { beg += RSTRING(str)->len; if (beg < 0) return Qnil; @@ -2226,7 +2227,11 @@ rb_str_split_m(argc, argv, str) } } if (!NIL_P(limit) || RSTRING(str)->len > beg || lim < 0) { - rb_ary_push(result, rb_str_substr(str, beg, RSTRING(str)->len-beg)); + if (RSTRING(str)->len == beg) + tmp = rb_str_new(0, 0); + else + tmp = rb_str_substr(str, beg, RSTRING(str)->len-beg); + rb_ary_push(result, tmp); } if (NIL_P(limit) && lim == 0) { while (RARRAY(result)->len > 0 && diff --git a/version.h b/version.h index 8d8fffad0e..1a3c02dd66 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.5.4" -#define RUBY_RELEASE_DATE "2000-06-22" +#define RUBY_RELEASE_DATE "2000-06-23" #define RUBY_VERSION_CODE 154 -#define RUBY_RELEASE_CODE 20000622 +#define RUBY_RELEASE_CODE 20000623 -- cgit v1.2.3