From dea6ce41b404df35944ab6063c614497b1b2984e Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 24 Aug 2000 06:21:43 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 19 +++++++++++++++++++ ToDo | 1 + array.c | 14 +++++++++++--- error.c | 4 ++-- eval.c | 35 ++++++++++++++++++++++++----------- ext/extmk.rb.in | 15 ++++++++++----- ext/socket/socket.c | 7 +++++++ file.c | 5 +++++ lib/mkmf.rb | 15 ++++++++++----- range.c | 6 +++--- regex.c | 9 ++++----- time.c | 6 +++++- version.h | 4 ++-- 13 files changed, 103 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2a0c661de..e72e49574d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,21 @@ Sat Aug 19 01:34:02 2000 WATANABE Hirofumi * ext/sdbm/_sdbm.c (makroom): fill hole with 0 on Win32 too. +Fri Aug 18 13:23:59 2000 Yukihiro Matsumoto + + * eval.c (rb_eval): should preserve and clear $! value before + compilation. + + * eval.c (eval): ditto. + +Fri Aug 18 11:06:19 2000 Shugo Maeda + + * ext/socket/socket.c (s_accept): start GC on EMFILE/ENFILE. + +Thu Aug 17 16:04:48 2000 Yukihiro Matsumoto + + * eval.c (is_defined): should clear ruby_errinfo. + Thu Aug 17 04:26:31 2000 Minero Aoki * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.27. @@ -13,6 +28,10 @@ Thu Aug 17 04:26:31 2000 Minero Aoki * lib/net/smtp.rb: send_mail accepts many destinations. +Wed Aug 16 00:43:47 2000 Yukihiro Matsumoto + + * time.c (time_s_times): use CLK_TCK for HZ if it's defined. + Tue Aug 15 17:30:59 2000 Yukihiro Matsumoto * eval.c (frame_dup): should set flag FRAME_MALLOC after diff --git a/ToDo b/ToDo index 8af987f091..8478dd4392 100644 --- a/ToDo +++ b/ToDo @@ -88,6 +88,7 @@ Standard Libraries * optional stepsize argument for succ() * Ruby module -- Ruby::Version, Ruby::Interpreter * introduce Boolean class; super of TrueClass, FalseClass +* Process::waitall [ruby-talk:4557] Extension Libraries diff --git a/array.c b/array.c index 7fc0d5b01d..e3e058fd4b 100644 --- a/array.c +++ b/array.c @@ -893,8 +893,8 @@ rb_ary_reverse(ary) VALUE *p1, *p2; VALUE tmp; + if (RARRAY(ary)->len <= 1) return ary; rb_ary_modify(ary); - if (RARRAY(ary)->len == 0) return ary; p1 = RARRAY(ary)->ptr; p2 = p1 + RARRAY(ary)->len - 1; /* points last item */ @@ -909,6 +909,14 @@ rb_ary_reverse(ary) return ary; } +static VALUE +rb_ary_reverse_bang(ary) + VALUE ary; +{ + if (RARRAY(ary)->len <= 1) return Qnil; + return rb_ary_reverse(ary); +} + static VALUE rb_ary_reverse_m(ary) VALUE ary; @@ -965,7 +973,7 @@ rb_ary_sort_bang(ary) VALUE ary; { rb_ary_modify(ary); - if (RARRAY(ary)->len <= 1) return ary; + if (RARRAY(ary)->len <= 1) return Qnil; FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */ rb_ensure(sort_internal, ary, sort_unlock, ary); @@ -1625,7 +1633,7 @@ Init_Array() rb_define_method(rb_cArray, "clone", rb_ary_clone, 0); rb_define_method(rb_cArray, "join", rb_ary_join_m, -1); rb_define_method(rb_cArray, "reverse", rb_ary_reverse_m, 0); - rb_define_method(rb_cArray, "reverse!", rb_ary_reverse, 0); + rb_define_method(rb_cArray, "reverse!", rb_ary_reverse_bang, 0); rb_define_method(rb_cArray, "sort", rb_ary_sort, 0); rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0); rb_define_method(rb_cArray, "collect", rb_ary_collect, 0); diff --git a/error.c b/error.c index 073ddfcebe..736598ca6d 100644 --- a/error.c +++ b/error.c @@ -1087,8 +1087,8 @@ err_append(s) else { VALUE str = rb_str_to_str(ruby_errinfo); - rb_str_cat(str, "\n", 1); - rb_str_cat(str, s, strlen(s)); + rb_str_cat2(str, "\n"); + rb_str_cat2(str, s); ruby_errinfo = rb_exc_new3(rb_eSyntaxError, str); } } diff --git a/eval.c b/eval.c index 42ca67efc7..837fe1c706 100644 --- a/eval.c +++ b/eval.c @@ -1141,18 +1141,17 @@ compile_error(at) const char *at; { VALUE str; - char *mesg; - int len; - mesg = rb_str2cstr(ruby_errinfo, &len); ruby_nerrs = 0; str = rb_str_new2("compile error"); if (at) { - rb_str_cat(str, " in ", 4); - rb_str_cat(str, at, strlen(at)); + rb_str_cat2(str, " in "); + rb_str_cat2(str, at); } rb_str_cat(str, "\n", 1); - rb_str_cat(str, mesg, len); + if (!NIL_P(ruby_errinfo)) { + rb_str_concat(str, ruby_errinfo); + } rb_exc_raise(rb_exc_new3(rb_eSyntaxError, str)); } @@ -1678,7 +1677,10 @@ is_defined(self, node, buf) val = CLASS_OF(val); } POP_TAG(); - if (state) return 0; + if (state) { + ruby_errinfo = Qnil; + return 0; + } check_bound: if (rb_method_boundp(val, node->nd_mid, nd_type(node)== NODE_CALL)) { return arg_defined(self, node->nd_args, buf, "method"); @@ -1748,7 +1750,10 @@ is_defined(self, node, buf) val = rb_eval(self, node->nd_head); } POP_TAG(); - if (state) return 0; + if (state) { + ruby_errinfo = Qnil; + return 0; + } else { switch (TYPE(val)) { case T_CLASS: @@ -1786,6 +1791,7 @@ is_defined(self, node, buf) if (!state) { return "expression"; } + ruby_errinfo = Qnil; break; } return 0; @@ -2722,6 +2728,8 @@ rb_eval(self, n) str2 = list->nd_head->nd_lit; break; case NODE_EVSTR: + result = ruby_errinfo; + ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list->nd_head = compile(list->nd_head->nd_lit, @@ -2732,10 +2740,10 @@ rb_eval(self, n) if (ruby_nerrs > 0) { compile_error("string expansion"); } + if (!NIL_P(result)) ruby_errinfo = result; /* fall through */ default: - str2 = rb_eval(self, list->nd_head); - str2 = rb_obj_as_string(str2); + str2 = rb_obj_as_string(rb_eval(self, list->nd_head)); break; } rb_str_append(str, str2); @@ -4569,10 +4577,15 @@ eval(self, src, scope, file, line) } PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { - NODE *node = compile(src, file, line); + NODE *node; + + result = ruby_errinfo; + ruby_errinfo = Qnil; + node = compile(src, file, line); if (ruby_nerrs > 0) { compile_error(0); } + if (!NIL_P(result)) ruby_errinfo = result; result = eval_node(self, node); } POP_TAG(); diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index b0cd861025..c8e55e0edb 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -311,22 +311,27 @@ def create_header() end end -def dir_config(target) - dir = with_config("%s-dir"%target) +def dir_config(target, idefault=nil, ldefault=nil) + if idefault && ldefault == nil + default = idefault + idefault = default + "/include" + ldefault = default + "/lib" + end + dir = with_config("%s-dir"%target, default) if dir idir = " -I"+dir+"/include" ldir = " -L"+dir+"/lib" end unless idir - dir = with_config("%s-include"%target) + dir = with_config("%s-include"%target, idefault) idir = " -I"+dir if dir end unless ldir - dir = with_config("%s-lib"%target) + dir = with_config("%s-lib"%target, ldefault) ldir = " -L"+dir if dir end - $CPPFLAGS += idir if idir + $CFLAGS += idir if idir $LDFLAGS += ldir if ldir end diff --git a/ext/socket/socket.c b/ext/socket/socket.c index c65de566e4..c9df07c279 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1044,6 +1044,7 @@ s_accept(class, fd, sockaddr, len) socklen_t *len; { int fd2; + int retry = 0; rb_secure(3); retry: @@ -1053,6 +1054,12 @@ s_accept(class, fd, sockaddr, len) TRAP_END; if (fd2 < 0) { switch (errno) { + case EMFILE: + case ENFILE: + if (retry) break; + rb_gc(); + retry = 1; + goto retry; case EINTR: rb_thread_schedule(); goto retry; diff --git a/file.c b/file.c index 85e82046e2..5c4dcaec01 100644 --- a/file.c +++ b/file.c @@ -1590,6 +1590,11 @@ rb_f_test(argc, argv) int cmd; if (argc == 0) rb_raise(rb_eArgError, "wrong # of arguments"); +#if 0 /* 1.7 behavior? */ + if (argc == 1) { + return RTEST(argv[0]) ? Qtrue : Qfalse; + } +#endif cmd = NUM2CHR(argv[0]); if (cmd == 0) return Qfalse; if (strchr("bcdefgGkloOprRsSuwWxXz", cmd)) { diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 41ffe4c726..83afac63ab 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -313,18 +313,23 @@ def create_header() end end -def dir_config(target) - dir = with_config("%s-dir"%target) +def dir_config(target, idefault=nil, ldefault=nil) + if idefault && ldefault == nil + default = idefault + idefault = default + "/include" + ldefault = default + "/lib" + end + dir = with_config("%s-dir"%target, default) if dir idir = " -I"+dir+"/include" ldir = " -L"+dir+"/lib" end unless idir - dir = with_config("%s-include"%target) + dir = with_config("%s-include"%target, idefault) idir = " -I"+dir if dir end unless ldir - dir = with_config("%s-lib"%target) + dir = with_config("%s-lib"%target, ldefault) ldir = " -L"+dir if dir end @@ -386,7 +391,7 @@ hdrdir = #{$hdrdir} CC = #{CONFIG["CC"]} CFLAGS = #{CONFIG["CCDLFLAGS"]} #{CFLAGS} #{$CFLAGS} - CPPFLAGS = -I$(hdrdir) -I#{CONFIG["includedir"]} #{$defs.join(" ")} #{CONFIG["CPPFLAGS"]} +CPPFLAGS = -I$(hdrdir) -I#{CONFIG["includedir"]} #{$defs.join(" ")} #{CONFIG["CPPFLAGS"]} CXXFLAGS = $(CFLAGS) DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS} LDSHARED = #{CONFIG["LDSHARED"]} #{defflag} diff --git a/range.c b/range.c index de46bec353..5accc14c5d 100644 --- a/range.c +++ b/range.c @@ -98,12 +98,12 @@ range_eqq(range, obj) end = rb_ivar_get(range, id_end); if (FIXNUM_P(beg) && FIXNUM_P(obj) && FIXNUM_P(end)) { - if (NUM2LONG(beg) <= NUM2LONG(obj)) { + if (FIX2LONG(beg) <= FIX2LONG(obj)) { if (EXCL(range)) { - if (NUM2LONG(obj) < NUM2LONG(end)) return Qtrue; + if (FIX2LONG(obj) < FIX2LONG(end)) return Qtrue; } else { - if (NUM2LONG(obj) <= NUM2LONG(end)) return Qtrue; + if (FIX2LONG(obj) <= FIX2LONG(end)) return Qtrue; } } return Qfalse; diff --git a/regex.c b/regex.c index 189c28205a..f5a27c3d0c 100644 --- a/regex.c +++ b/regex.c @@ -1991,7 +1991,7 @@ re_compile_pattern(pattern, size, bufp) break; } - /* If lower_bound == upper_bound, repeat cound can be removed */ + /* If lower_bound == upper_bound, repeat count can be removed */ if (lower_bound == upper_bound) { int mcnt; int skip_stop_paren = 0; @@ -2069,7 +2069,7 @@ re_compile_pattern(pattern, size, bufp) jump back only `upper_bound - 1' times. */ GET_BUFFER_SPACE(5); store_jump_n(b, greedy?jump_n:finalize_push_n, laststart + 5, - upper_bound - 1); + upper_bound/* - 1*/); b += 5; /* The location we want to set is the second @@ -2087,7 +2087,7 @@ re_compile_pattern(pattern, size, bufp) so that if we fail during matching, we'll reinitialize the bounds. */ insert_op_2(set_number_at, laststart, b, b - laststart, - upper_bound - 1); + upper_bound/* - 1*/); b += 5; } } @@ -3408,8 +3408,7 @@ re_search(bufp, string, size, startpos, range, regs) do { unsigned this_reg; \ for (this_reg = 0; this_reg < num_regs; this_reg++) { \ if (IS_ACTIVE(reg_info[this_reg])) \ - MATCHED_SOMETHING(reg_info[this_reg]) \ - = 1; \ + MATCHED_SOMETHING(reg_info[this_reg]) = 1; \ else \ MATCHED_SOMETHING(reg_info[this_reg]) = 0; \ } \ diff --git a/time.c b/time.c index 6598919977..3fb535e26c 100644 --- a/time.c +++ b/time.c @@ -946,7 +946,11 @@ time_s_times(obj) { #ifdef HAVE_TIMES #ifndef HZ -#define HZ 60 /* Universal constant :-) */ +# ifdef CLK_TCK +# define HZ CLK_TCK +# else +# define HZ 60 +# endif #endif /* HZ */ struct tms buf; diff --git a/version.h b/version.h index dc8cc8d570..5e42aa3aa2 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.5.5" -#define RUBY_RELEASE_DATE "2000-08-15" +#define RUBY_RELEASE_DATE "2000-08-16" #define RUBY_VERSION_CODE 155 -#define RUBY_RELEASE_CODE 20000815 +#define RUBY_RELEASE_CODE 20000816 -- cgit v1.2.3