1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2001-07-31 06:24:45 +00:00
parent 645170199c
commit c8a7361e45
9 changed files with 73 additions and 13 deletions

View file

@ -1,14 +1,43 @@
Tue Jul 31 12:11:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* marshal.c (Init_marshal): new constant Marshal::MAJOR_VERSION
and Marshal::MINOR_VERSION.
Tue Jul 31 07:18:04 2001 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* 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 <akira@ruby-lang.org>
* marshal.c (marshal_load): ruby_verbose test should be wrapped by
RTEST().
Mon Jul 30 17:54:23 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <matz@ruby-lang.org>
* 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 <amos+ruby@utdallas.edu>
* lib/net/imap.rb: added new commands for managing folder quotas
and folder ACLs.
Mon Jul 30 03:19:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* bignum.c (rb_cstr2inum): "0 ff".hex should return 0, not 255.
Fri Jul 27 22:29:41 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* file.c (rb_file_s_expand_path): fixed using CharNext().
Fri Jul 27 18:07:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_provided): extension should be guessed using

View file

@ -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);
}

6
file.c
View file

@ -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

2
hash.c
View file

@ -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);

View file

@ -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

View file

@ -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__

View file

@ -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

View file

@ -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);

View file

@ -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