From af328b152b68bb21549e52df230b17a8672795c3 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 8 Nov 2000 05:29:37 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 24 ++++++++++++++++++++++++ bignum.c | 35 ++++++++++++++++++++++------------- error.c | 19 ++++++++++++++++--- eval.c | 3 +++ ext/dbm/dbm.c | 6 +++--- ext/gdbm/gdbm.c | 4 ++-- ext/sdbm/init.c | 4 ++-- ext/socket/socket.c | 1 - io.c | 39 +++++++++++++++++++++++++++++++-------- lib/jcode.rb | 6 +++--- lib/open3.rb | 2 +- time.c | 5 ----- version.h | 4 ++-- 13 files changed, 109 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec2a142f3a..a65ba334a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Nov 8 03:08:53 2000 Yukihiro Matsumoto + + * io.c (io_fflush): ensure fflush(3) would not block by calling + rb_thread_fd_writable(). + Tue Nov 7 20:29:56 2000 Minero Aoki * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.30 @@ -6,6 +11,25 @@ Tue Nov 7 20:29:56 2000 Minero Aoki * lib/net/http.rb: read header when also "100 Continue" +Tue Nov 7 04:32:19 2000 Yukihiro Matsumoto + + * bignum.c (bigdivrem): use bit shift to make y's MSB set. + +Mon Nov 6 1:22:49 2000 Yukihiro Matsumoto + + * error.c (warn_print): do not use err_append(), to ensure output + to stderr. + + * error.c (rb_warn): use warn_print() instead of err_print(). + + * error.c (rb_warning): ditto. + + * error.c (rb_bug): ditto. + + * eval.c (rb_load): re-raise exceptions during load. + + * time.c (make_time_t): remove useless adjust + Thu Nov 2 18:01:16 2000 Yukihiro Matsumoto * random.c (rb_f_rand): half-baked float support fixed. This fix diff --git a/bignum.c b/bignum.c index e7f84dc6f9..74cd1507dd 100644 --- a/bignum.c +++ b/bignum.c @@ -830,31 +830,39 @@ bigdivrem(x, y, divp, modp) zds = BDIGITS(z); if (nx==ny) zds[nx+1] = 0; while (!yds[ny-1]) ny--; - if ((dd = BIGRAD/(BDIGIT_DBL_SIGNED)(yds[ny-1]+1)) != 1) { + + dd = 0; + q = yds[ny-1]; + while ((q & (1<<(BITSPERDIG-1))) == 0) { + q <<= 1; + dd++; + } + if (dd) { yy = rb_big_clone(y); tds = BDIGITS(yy); j = 0; - num = 0; + t2 = 0; while (j> dd; + q = zds[i]; + zds[i] = BIGLO(t2); + t2 = BIGUP(q); } } RBIGNUM(*modp)->len = ny; diff --git a/error.c b/error.c index 736598ca6d..540e57dd61 100644 --- a/error.c +++ b/error.c @@ -100,6 +100,19 @@ rb_compile_error_append(fmt, va_alist) err_append(buf); } +static void +warn_print(fmt, args) + const char *fmt; + va_list args; +{ + char buf[BUFSIZ]; + + err_snprintf(buf, BUFSIZ, fmt, args); + fputs(buf, stderr); + fputs("\n", stderr); + fflush(stderr); +} + void #ifdef HAVE_STDARG_PROTOTYPES rb_warn(const char *fmt, ...) @@ -115,7 +128,7 @@ rb_warn(fmt, va_alist) snprintf(buf, BUFSIZ, "warning: %s", fmt); va_init_list(args, fmt); - err_print(buf, args); + warn_print(buf, args); va_end(args); } @@ -137,7 +150,7 @@ rb_warning(fmt, va_alist) snprintf(buf, BUFSIZ, "warning: %s", fmt); va_init_list(args, fmt); - err_print(buf, args); + warn_print(buf, args); va_end(args); } @@ -157,7 +170,7 @@ rb_bug(fmt, va_alist) ruby_in_eval = 0; va_init_list(args, fmt); - err_print(buf, args); + warn_print(buf, args); va_end(args); ruby_show_version(); abort(); diff --git a/eval.c b/eval.c index 969def2a20..232090386d 100644 --- a/eval.c +++ b/eval.c @@ -4947,6 +4947,7 @@ rb_load(fname, wrap) rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr); } + ruby_errinfo = Qnil; /* ensure */ PUSH_VARS(); PUSH_CLASS(); wrapper = ruby_wrapper; @@ -5013,6 +5014,8 @@ rb_load(fname, wrap) } TMP_PROTECT_END; if (state) JUMP_TAG(state); + if (!NIL_P(ruby_errinfo)) /* exception during load */ + rb_exc_raise(ruby_errinfo); } void diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index b1564793d1..830a616804 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -76,14 +76,14 @@ fdbm_s_open(argc, argv, klass) dbm = dbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode); } if (!dbm) { - mode = 0666; - dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, mode); + dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, 0); } if (!dbm) { - dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, mode); + dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, 0); } if (!dbm) { + printf("mode: %o\n", mode); if (mode == -1) return Qnil; rb_sys_fail(RSTRING(file)->ptr); } diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c index da57a79dd6..d84c7bedd4 100644 --- a/ext/gdbm/gdbm.c +++ b/ext/gdbm/gdbm.c @@ -72,10 +72,10 @@ fgdbm_s_open(argc, argv, klass) O_RDWR|O_CREAT, mode, MY_FATAL_FUNC); if (!dbm) dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE, - O_RDWR, mode, MY_FATAL_FUNC); + O_RDWR, 0, MY_FATAL_FUNC); if (!dbm) dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE, - O_RDONLY, mode, MY_FATAL_FUNC); + O_RDONLY, 0, MY_FATAL_FUNC); if (!dbm) { if (mode == -1) return Qnil; diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c index f6dd73b9bc..87136e9bdb 100644 --- a/ext/sdbm/init.c +++ b/ext/sdbm/init.c @@ -70,9 +70,9 @@ fsdbm_s_open(argc, argv, klass) if (mode >= 0) dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode); if (!dbm) - dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR, mode); + dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR, 0); if (!dbm) - dbm = sdbm_open(RSTRING(file)->ptr, O_RDONLY, mode); + dbm = sdbm_open(RSTRING(file)->ptr, O_RDONLY, 0); if (!dbm) { if (mode == -1) return Qnil; diff --git a/ext/socket/socket.c b/ext/socket/socket.c index c9df07c279..b815c3f935 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -768,7 +768,6 @@ ruby_connect(fd, sockaddr, len, socks) } } #ifdef HAVE_FCNTL - mode &= ~NONBLOCKING; fcntl(fd, F_SETFL, mode); #endif return status; diff --git a/io.c b/io.c index 59058d7294..626cee7934 100644 --- a/io.c +++ b/io.c @@ -123,6 +123,20 @@ extern int ReadDataPending(); }\ } while(0) +#ifndef EWOULDBLOCK +#define EWOULDBLOCK EAGAIN +#endif + +#ifdef O_NDELAY +# define NONBLOCKING O_NDELAY +#else +#ifdef O_NBIO +# define NONBLOCKING O_NBIO +#else +# define NONBLOCKING O_NONBLOCK +#endif +#endif + void rb_eof_error() { @@ -194,6 +208,15 @@ rb_dup(orig) return fd; } +static void +io_fflush(f, path) + FILE *f; + const char *path; +{ + rb_thread_fd_writable(fileno(f)); + if (fflush(f) == EOF) rb_sys_fail(path); +} + /* writing functions */ static VALUE io_write(io, str) @@ -235,7 +258,7 @@ io_write(io, str) } #endif if (fptr->mode & FMODE_SYNC) { - if (fflush(f) == EOF) rb_sys_fail(fptr->path); + io_fflush(f, fptr->path); } return INT2FIX(n); @@ -266,8 +289,8 @@ rb_io_flush(io) GetOpenFile(io, fptr); rb_io_check_writable(fptr); f = GetWriteFile(fptr); - - if (fflush(f) == EOF) rb_sys_fail(fptr->path); + + io_fflush(f, fptr->path); return io; } @@ -1779,10 +1802,10 @@ io_reopen(io, nfile) pos = ftell(orig->f); } if (orig->f2) { - if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path); + io_fflush(orig->f2, orig->path); } else if (orig->mode & FMODE_WRITABLE) { - if (fflush(orig->f) == EOF) rb_sys_fail(orig->path); + io_fflush(orig->f, orig->path); } rb_thread_fd_close(fileno(fptr->f)); @@ -1905,10 +1928,10 @@ rb_io_clone(io) MakeOpenFile(clone, fptr); if (orig->f2) { - if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path); + io_fflush(orig->f2, orig->path); } else if (orig->mode & FMODE_WRITABLE) { - if (fflush(orig->f) == EOF) rb_sys_fail(orig->path); + io_fflush(orig->f, orig->path); } /* copy OpenFile structure */ @@ -2033,7 +2056,7 @@ rb_io_putc(io, ch) if (fputc(c, f) == EOF) rb_sys_fail(fptr->path); if (fptr->mode & FMODE_SYNC) { - if (fflush(f) == EOF) rb_sys_fail(fptr->path); + io_fflush(f, fptr->path); } return ch; diff --git a/lib/jcode.rb b/lib/jcode.rb index 0f53b7185b..3ce692fc50 100644 --- a/lib/jcode.rb +++ b/lib/jcode.rb @@ -5,8 +5,8 @@ class String printf STDERR, "feel free for some warnings:\n" if $VERBOSE def _regex_quote(str) - str.gsub(/\W/){|s| - if s == "-" then s elsif s == "\\" then "\\\\" else "\\\\#{s}" end + str.gsub(/[][.\\|*?+{}()]/n){|s| + if s == "\\" then "\\\\" else "\\\\#{s}" end } end private :_regex_quote @@ -93,7 +93,7 @@ class String def _expand_ch str a = [] - str.scan(/(.|\n)-(.|\n)|(.|\n)/) do |r| + str.scan(/(.)-(.)|(.)/m) do |r| if $3 a.push $3 elsif $1.length != $2.length diff --git a/lib/open3.rb b/lib/open3.rb index 18984f5726..58de740393 100644 --- a/lib/open3.rb +++ b/lib/open3.rb @@ -41,7 +41,7 @@ module Open3 pi = [pw[1], pr[0], pe[0]] if defined? yield begin - return yield *pi + return yield(*pi) ensure pi.each{|p| p.close unless p.closed?} end diff --git a/time.c b/time.c index f8426adf4f..6cd6a0daff 100644 --- a/time.c +++ b/time.c @@ -328,11 +328,6 @@ make_time_t(tptr, utc_or_local) tm = localtime(&guess); if (!tm) goto error; guess -= tm->tm_gmtoff; - tm = localtime(&guess); - if (!tm) goto error; - if (tm->tm_hour != tptr->tm_hour) { - guess += (tptr->tm_hour - tm->tm_hour)*3600; - } #else struct tm gt, lt; long tzsec; diff --git a/version.h b/version.h index b6e59e278a..8dd99cfa7e 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.6.2" -#define RUBY_RELEASE_DATE "2000-11-04" +#define RUBY_RELEASE_DATE "2000-11-08" #define RUBY_VERSION_CODE 162 -#define RUBY_RELEASE_CODE 20001104 +#define RUBY_RELEASE_CODE 20001108 -- cgit v1.2.3