From 0e47c138c9bba4396fc7d956b05e5725000012f1 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 22 Dec 2000 03:22:25 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 24 +++++++++++ bignum.c | 12 +++++- eval.c | 50 +++++++++++---------- ext/extmk.rb.in | 93 ++++++++++++++++++++++++++------------- ext/socket/extconf.rb | 5 ++- gc.c | 1 - io.c | 2 +- lib/mkmf.rb | 115 ++++++++++++++++++++++++++++++++----------------- lib/parsedate.rb | 4 +- lib/tracer.rb | 28 ++++++------ parse.y | 48 +++++++++++++++------ time.c | 4 ++ version.h | 4 +- win32/Makefile.sub | 26 ++++++----- win32/config.status.in | 2 +- 15 files changed, 277 insertions(+), 141 deletions(-) diff --git a/ChangeLog b/ChangeLog index a282c5a98e..c8452651b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,30 @@ Thu Dec 21 13:01:46 2000 Tanaka Akira * lib/net/ftp.rb (makeport): don't use TCPsocket.getaddress. +Wed Dec 20 12:00:15 2000 Yukihiro Matsumoto + + * bignum.c (rb_big_lshift): should cast up to BDIGIT_DBL. + + * parse.y (yylex): disallow trailin '_' for numeric litrals. + + * bignum.c (rb_cstr2inum): allow `_' within converting string. + + * eval.c (specific_eval): should take no argument if block is + supplied. + +Tue Dec 19 13:44:50 2000 K.Kosako + + * io.c (rb_f_p): should flush rb_defout, not stdout. + +Tue Dec 19 00:57:10 2000 Yukihiro Matsumoto + + * time.c (time_minus): usec might overflow (ruby-bugs-ja:#PR#35). + + * eval.c (rb_obj_extend): Object#extend should take at least one + argument. + + * parse.y (mrhs_basic): should check value_expr($3), not $1. + Mon Dec 18 23:18:39 2000 WATANABE Hirofumi * util.c (mblen, __crt0_glob_function): add for multibyte diff --git a/bignum.c b/bignum.c index 2ae471190d..8a47a449e6 100644 --- a/bignum.c +++ b/bignum.c @@ -231,7 +231,9 @@ rb_cstr2inum(str, base) } } if (base == 8) { - while (str[0] == '0') str++; + while (*str == '0') str++; + if (!*str) return INT2FIX(0); + while (*str == '_') str++; len = 3*strlen(str)*sizeof(char); } else { /* base == 10, 2 or 16 */ @@ -249,6 +251,7 @@ rb_cstr2inum(str, base) if (len <= (sizeof(VALUE)*CHAR_BIT)) { unsigned long val = strtoul((char*)str, &end, base); + if (*end == '_') goto bigparse; if (badcheck) { if (end == str) goto bad; /* no number */ while (*end && ISSPACE(*end)) end++; @@ -271,7 +274,9 @@ rb_cstr2inum(str, base) return big; } } + bigparse: len = (len/BITSPERDIG)+1; + if (badcheck && *str == '_') goto bad; z = bignew(len, sign); zds = BDIGITS(z); @@ -290,6 +295,8 @@ rb_cstr2inum(str, base) case 'D': case 'E': case 'F': c = c - 'A' + 10; break; + case '_': + continue; default: if (badcheck) { if (ISSPACE(c)) { @@ -317,6 +324,7 @@ rb_cstr2inum(str, base) break; } } + if (badcheck && s+2 < str && str[-2] == '_') goto bad; return bignorm(z); } @@ -1252,7 +1260,7 @@ rb_big_lshift(x, y) } xds = BDIGITS(x); for (i=0; i 0) { - if (ruby_safe_level >= 4) { - Check_Type(argv[0], T_STRING); + if (rb_block_given_p()) { + if (argc > 0) { + rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc); } - else { - Check_SafeStr(argv[0]); - } - if (argc > 3) { - rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}", - rb_id2name(ruby_frame->last_func), - rb_id2name(ruby_frame->last_func)); - } - if (argc > 1) file = STR2CSTR(argv[1]); - if (argc > 2) line = NUM2INT(argv[2]); - } - else if (!iter) { - rb_raise(rb_eArgError, "block not supplied"); - } - - if (iter) { return yield_under(klass, self); } else { + char *file = "(eval)"; + int line = 1; + + if (argc == 0) { + rb_raise(rb_eArgError, "block not supplied"); + } + else { + if (ruby_safe_level >= 4) { + Check_Type(argv[0], T_STRING); + } + else { + Check_SafeStr(argv[0]); + } + if (argc > 3) { + rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}", + rb_id2name(ruby_frame->last_func), + rb_id2name(ruby_frame->last_func)); + } + if (argc > 1) file = STR2CSTR(argv[1]); + if (argc > 2) line = NUM2INT(argv[2]); + } return eval_under(klass, self, argv[0], file, line); } } @@ -5551,6 +5552,9 @@ rb_obj_extend(argc, argv, obj) { int i; + if (argc == 0) { + rb_raise(rb_eArgError, "wrong # of arguments(0 for 1)"); + } for (i=0; ias.basic.flags == 0) return; /* free cell */ if (obj->as.basic.flags & FL_MARK) return; /* already marked */ diff --git a/io.c b/io.c index 91d44c87d1..a422cc0869 100644 --- a/io.c +++ b/io.c @@ -2156,7 +2156,7 @@ rb_f_p(argc, argv) for (i=0; i ">", "return" => "<", "class" => "C", - "end" => "E"} + "end" => "E", + "c-call" => ">", + "c-return" => "<", + } def initialize @threads = Hash.new @@ -59,8 +62,8 @@ class Tracer off end else - set_trace_func proc{|event, file, line, id, binding, klass| - trace_func event, file, line, id, binding + set_trace_func proc{|event, file, line, id, binding, klass, *rest| + trace_func event, file, line, id, binding, klass } stdout.print "Trace on\n" if Tracer.verbose? end @@ -85,7 +88,6 @@ class Tracer end unless list = LINES__[file] -# stdout.print file if $DEBUG begin f = open(file) begin @@ -112,21 +114,21 @@ class Tracer end end - def trace_func(event, file, line, id, binding) + def trace_func(event, file, line, id, binding, klass) return if file == MY_FILE_NAME - #stdout.printf "Th: %s\n", Thread.current.inspect for p in @filters - return unless p.call event, file, line, id, binding + return unless p.call event, file, line, id, binding, klass end Thread.critical = true - stdout.printf("#%d:%s:%d:%s: %s", - get_thread_no, - file, - line, - EVENT_SYMBOL[event], - get_line(file, line)) + stdout.printf("#%d:%s:%d:%s:%s: %s", + get_thread_no, + file, + line, + klass || '', + EVENT_SYMBOL[event], + get_line(file, line)) Thread.critical = false end diff --git a/parse.y b/parse.y index 6dbb364c55..ea0e33f609 100644 --- a/parse.y +++ b/parse.y @@ -1022,7 +1022,7 @@ mrhs : arg mrhs_basic : args ',' arg { - value_expr($1); + value_expr($3); $$ = list_append($1, $3); } | args ',' tSTAR arg @@ -3126,9 +3126,9 @@ yylex() case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { - int is_float, seen_point, seen_e; + int is_float, seen_point, seen_e, seen_uc; - is_float = seen_point = seen_e = 0; + is_float = seen_point = seen_e = seen_uc = 0; lex_state = EXPR_END; newtok(); if (c == '-' || c == '+') { @@ -3140,44 +3140,59 @@ yylex() if (c == 'x' || c == 'X') { /* hexadecimal */ c = nextc(); - if (!ISXDIGIT(c)) { - yyerror("hexadecimal number without hex-digits"); - } do { - if (c == '_') continue; + if (c == '_') { + seen_uc = 1; + continue; + } if (!ISXDIGIT(c)) break; + seen_uc = 0; tokadd(c); } while (c = nextc()); pushback(c); tokfix(); + if (toklen() == 0) { + yyerror("hexadecimal number without hex-digits"); + } + else if (seen_uc) goto trailing_uc; yylval.val = rb_cstr2inum(tok(), 16); return tINTEGER; } if (c == 'b' || c == 'B') { /* binary */ c = nextc(); - if (c != '0' && c != '1') { - yyerror("numeric literal without digits"); - } do { - if (c == '_') continue; + if (c == '_') { + seen_uc = 1; + continue; + } if (c != '0'&& c != '1') break; + seen_uc = 0; tokadd(c); } while (c = nextc()); pushback(c); tokfix(); + if (toklen() == 0) { + yyerror("numeric literal without digits"); + } + else if (seen_uc) goto trailing_uc; yylval.val = rb_cstr2inum(tok(), 2); return tINTEGER; } if (c >= '0' && c <= '7' || c == '_') { /* octal */ do { - if (c == '_') continue; + if (c == '_') { + seen_uc = 1; + continue; + } if (c < '0' || c > '7') break; + seen_uc = 0; tokadd(c); } while (c = nextc()); pushback(c); tokfix(); + if (seen_uc) goto trailing_uc; yylval.val = rb_cstr2inum(tok(), 8); return tINTEGER; } @@ -3198,6 +3213,7 @@ yylex() switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + seen_uc = 0; tokadd(c); break; @@ -3217,6 +3233,7 @@ yylex() tokadd(c); is_float++; seen_point++; + seen_uc = 0; break; case 'e': @@ -3233,7 +3250,8 @@ yylex() continue; break; - case '_': /* `_' in decimal just ignored */ + case '_': /* `_' in number just ignored */ + seen_uc = 1; break; default: @@ -3245,6 +3263,10 @@ yylex() decode_num: pushback(c); tokfix(); + if (seen_uc) { + trailing_uc: + yyerror("trailing `_' in number"); + } if (is_float) { double d = strtod(tok(), 0); if (errno == ERANGE) { diff --git a/time.c b/time.c index 2ef06eb6f7..e45e2e854a 100644 --- a/time.c +++ b/time.c @@ -696,6 +696,10 @@ time_minus(time1, time2) sec = tobj->tv.tv_sec - sec; } + if (usec >= 1000000) { /* usec overflow */ + sec++; + usec -= 1000000; + } if (usec < 0) { /* usec underflow */ sec--; usec += 1000000; diff --git a/version.h b/version.h index 0891bff976..7a8db96961 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.6.2" -#define RUBY_RELEASE_DATE "2000-12-18" +#define RUBY_RELEASE_DATE "2000-12-22" #define RUBY_VERSION_CODE 162 -#define RUBY_RELEASE_CODE 20001218 +#define RUBY_RELEASE_CODE 20001222 diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 36df32cfab..403f5453b1 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -21,6 +21,7 @@ RUBY_SO_NAME = rubymw ############### VPATH = $(srcdir):$(srcdir)/missing +.SUFFIXES: .y CC = cl YACC = byacc @@ -186,22 +187,25 @@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(LIBRUBY_SO).rc: rbconfig.rb #config.status: $(srcdir)/configure # $(SHELL) ./config.status --recheck +{$(srcdir)/missing}.c.obj: + $(CC) $(CFLAGS) -I. -I$( parse.c - @rm y.tab.c +{$(srcdir)}.y.c: + $(YACC) $(YFLAGS) $(<:\=/) + sed -e "s!^extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@ + @del y.tab.c + +{$(srcdir)}parse.c: parse.y alloca.obj: $(srcdir)/missing/alloca.c crypt.obj: $(srcdir)/missing/crypt.c @@ -236,7 +240,7 @@ win32.obj: $(srcdir)/win32/win32.c # Prevent GNU make v3 from overflowing arg limit on SysV. .NOEXPORT: ### -parse.obj: $(srcdir)/parse.c $(srcdir)/ruby.h config.h $(srcdir)/defines.h $(srcdir)/intern.h $(srcdir)/env.h $(srcdir)/node.h $(srcdir)/st.h $(srcdir)/regex.h $(srcdir)/util.h $(srcdir)/lex.c +parse.obj: {$(srcdir)}parse.c $(srcdir)/ruby.h config.h $(srcdir)/defines.h $(srcdir)/intern.h $(srcdir)/env.h $(srcdir)/node.h $(srcdir)/st.h $(srcdir)/regex.h $(srcdir)/util.h $(srcdir)/lex.c ### array.obj: $(srcdir)/array.c $(srcdir)/ruby.h config.h $(srcdir)/defines.h $(srcdir)/intern.h bignum.obj: $(srcdir)/bignum.c $(srcdir)/ruby.h config.h $(srcdir)/defines.h $(srcdir)/intern.h diff --git a/win32/config.status.in b/win32/config.status.in index f3636581aa..461877b886 100644 --- a/win32/config.status.in +++ b/win32/config.status.in @@ -57,7 +57,7 @@ s%@LIBRUBY_A@%lib$(RUBY_INSTALL_NAME).lib%g s%@LIBRUBY_SO@%%g s%@LIBRUBY_ALIASES@%%g s%@LIBRUBY@%$(RUBY_SO_NAME).lib%g -s%@LIBRUBYARG@%$(topdir)/$(RUBY_SO_NAME).lib%g +s%@LIBRUBYARG@%$(RUBY_SO_NAME).lib%g s%@SOLIBS@%%g s%@DLDLIBS@%%g s%@arch@%i586-mswin32%g -- cgit v1.2.3