From c8a7361e45e3a149b970ae9cd74cbbcfbfd1d501 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 31 Jul 2001 06:24:45 +0000 Subject: * marshal.c (Init_marshal): new constant Marshal::MAJOR_VERSION and Marshal::MINOR_VERSION. * marshal.c (marshal_load): ruby_verbose test should be wrapped by RTEST(). * hash.c (rb_hash_index): should return nil (not the default value) if value is not in the hash. * numeric.c (num_div): new method added. alias to '/' which should be preserved even if '/' is redefined (e.g. by mathn). [new] * bignum.c (rb_cstr2inum): "0 ff".hex should return 0, not 255. * file.c (rb_file_s_expand_path): fixed using CharNext(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 29 +++++++++++++++++++++++++++++ bignum.c | 6 +++++- file.c | 6 ++++++ hash.c | 2 +- lib/pstore.rb | 13 ++++++++----- lib/singleton.rb | 12 +++++++++--- marshal.c | 5 ++++- numeric.c | 9 +++++++++ version.h | 4 ++-- 9 files changed, 73 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index cde19e45d3..2d6014cc4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,14 +1,43 @@ +Tue Jul 31 12:11:42 2001 Yukihiro Matsumoto + + * marshal.c (Init_marshal): new constant Marshal::MAJOR_VERSION + and Marshal::MINOR_VERSION. + Tue Jul 31 07:18:04 2001 Nobuyoshi Nakada * file.c (rb_file_s_expand_path): scans per path element not per byte/character, including fix of [ruby-talk:18152] and multi-byte pathname support. +Tue Jul 31 11:52:10 2001 akira yamada + + * marshal.c (marshal_load): ruby_verbose test should be wrapped by + RTEST(). + +Mon Jul 30 17:54:23 2001 Yukihiro Matsumoto + + * hash.c (rb_hash_index): should return nil (not the default + value) if value is not in the hash. + +Mon Jul 30 12:55:47 2001 Yukihiro Matsumoto + + * numeric.c (num_div): new method added. alias to '/' which + should be preserved even if '/' is redefined (e.g. by + mathn). [new] + Mon Jul 30 11:12:14 2001 Amos Gouaux * lib/net/imap.rb: added new commands for managing folder quotas and folder ACLs. +Mon Jul 30 03:19:53 2001 Yukihiro Matsumoto + + * bignum.c (rb_cstr2inum): "0 ff".hex should return 0, not 255. + +Fri Jul 27 22:29:41 2001 Nobuyoshi Nakada + + * file.c (rb_file_s_expand_path): fixed using CharNext(). + Fri Jul 27 18:07:27 2001 Yukihiro Matsumoto * eval.c (rb_provided): extension should be guessed using diff --git a/bignum.c b/bignum.c index 4100d409c4..1bcd62c7e9 100644 --- a/bignum.c +++ b/bignum.c @@ -239,10 +239,14 @@ rb_cstr2inum(str, base) if (base == 16 && str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) { str += 2; } - if (base == 2 && str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) { + else if (base == 2 && str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) { str += 2; } while (*str && *str == '0') str++; + if (ISSPACE(*str)) { + if (badcheck) goto bad; + return INT2FIX(0); + } if (!*str) str--; len = 4*strlen(str)*sizeof(char); } diff --git a/file.c b/file.c index 76076e47a2..2241efa19d 100644 --- a/file.c +++ b/file.c @@ -1438,6 +1438,12 @@ rb_file_s_expand_path(argc, argv) } b = ++s; } + else { + p = CharNext(p); + *p++ = '.'; + *p = '.'; + if (p >= bend) goto toolong; + } break; case '/': #if defined DOSISH diff --git a/hash.c b/hash.c index 75132c9d56..9b3bb3f97a 100644 --- a/hash.c +++ b/hash.c @@ -364,7 +364,7 @@ rb_hash_index(hash, value) VALUE args[2]; args[0] = value; - args[1] = RHASH(hash)->ifnone; + args[1] = Qnil; st_foreach(RHASH(hash)->tbl, index_i, args); diff --git a/lib/pstore.rb b/lib/pstore.rb index d74d712a56..43a0530dc8 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -79,7 +79,7 @@ class PStore throw :pstore_abort_transaction end - def transaction + def transaction(read_only=false) raise PStore::Error, "nested transaction" if @transaction begin @transaction = true @@ -89,10 +89,13 @@ class PStore file = File::open(@filename, "r+") orig = true rescue Errno::ENOENT + raise if read_only file = File::open(@filename, "w+") end - file.flock(File::LOCK_EX) - if orig + file.flock(read_only ? File::LOCK_SH : File::LOCK_EX) + if read_only + @table = Marshal::load(file) + elsif orig content = file.read @table = Marshal::load(content) size = content.size @@ -109,7 +112,7 @@ class PStore @abort = true raise ensure - unless @abort + if !read_only && !@abort file.rewind content = Marshal::dump(@table) if !md5 || size != content.size || md5 != MD5.new(content).digest @@ -150,7 +153,7 @@ if __FILE__ == $0 end end - db.transaction do + db.transaction(true) do p db["root"] end end diff --git a/lib/singleton.rb b/lib/singleton.rb index f5c2d8346b..1945c4446b 100644 --- a/lib/singleton.rb +++ b/lib/singleton.rb @@ -16,12 +16,18 @@ module Singleton klass.instance_eval %{ @__instance__ = nil def instance - unless @__instance__ + if defined? @__allocating__ + until @__instance__ + sleep 0.5 + end + elsif ! @__instance__ Thread.critical = true + @__allocating__ = true + Thread.critical = false begin - @__instance__ ||= new + @__instance__ = new ensure - Thread.critical = false + remove_instance_variable(:@__allocating__) end end return @__instance__ diff --git a/marshal.c b/marshal.c index d8f7703092..ce417be426 100644 --- a/marshal.c +++ b/marshal.c @@ -1071,7 +1071,7 @@ marshal_load(argc, argv) \tformat version %d.%d required; %d.%d given", MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); } - if (ruby_verbose && minor != MARSHAL_MINOR) { + if (RTEST(ruby_verbose) && minor != MARSHAL_MINOR) { rb_warn("incompatible marshal file format (can be read)\n\ \tformat version %d.%d required; %d.%d given", MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); @@ -1096,6 +1096,9 @@ Init_marshal() 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_const(rb_mMarshal, "MAJOR_VERSION", INT2FIX(MAJOR_VERSION)); + rb_define_const(rb_mMarshal, "MINOR_VERSION", INT2FIX(MINOR_VERSION)); } VALUE diff --git a/numeric.c b/numeric.c index 55ab2a8118..027ee6366b 100644 --- a/numeric.c +++ b/numeric.c @@ -115,6 +115,13 @@ num_uminus(num) return rb_funcall(zero, '-', 1, num); } +static VALUE +num_div(x, y) + VALUE x, y; +{ + return rb_funcall(x, '/', 1, y); +} + static VALUE num_divmod(x, y) VALUE x, y; @@ -1543,6 +1550,7 @@ Init_Numeric() rb_define_method(rb_cNumeric, "-@", num_uminus, 0); rb_define_method(rb_cNumeric, "===", num_equal, 1); rb_define_method(rb_cNumeric, "eql?", num_eql, 1); + rb_define_method(rb_cNumeric, "div", num_div, 1); rb_define_method(rb_cNumeric, "divmod", num_divmod, 1); rb_define_method(rb_cNumeric, "modulo", num_modulo, 1); rb_define_method(rb_cNumeric, "remainder", num_remainder, 1); @@ -1591,6 +1599,7 @@ Init_Numeric() rb_define_method(rb_cFixnum, "-", fix_minus, 1); rb_define_method(rb_cFixnum, "*", fix_mul, 1); rb_define_method(rb_cFixnum, "/", fix_div, 1); + rb_define_method(rb_cFixnum, "div", fix_div, 1); rb_define_method(rb_cFixnum, "%", fix_mod, 1); rb_define_method(rb_cFixnum, "modulo", fix_mod, 1); rb_define_method(rb_cFixnum, "divmod", fix_divmod, 1); diff --git a/version.h b/version.h index 49dffd31ce..c9948e2b27 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.1" -#define RUBY_RELEASE_DATE "2001-07-26" +#define RUBY_RELEASE_DATE "2001-07-31" #define RUBY_VERSION_CODE 171 -#define RUBY_RELEASE_CODE 20010726 +#define RUBY_RELEASE_CODE 20010731 -- cgit v1.2.3