* numeric.c (num_to_int): default to_int implementaion for every

numeric class.

* re.c (rb_reg_quote): initial part of the string was never copied
  to the quoted string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-07-29 06:14:10 +00:00
parent 448610abec
commit 89dbf99bac
7 changed files with 31 additions and 19 deletions

View File

@ -1,3 +1,13 @@
Sat Jul 27 23:07:52 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (num_to_int): default to_int implementaion for every
numeric class.
Sat Jul 27 08:09:03 2002 Booker C. Bense <bbense@slac.stanford.edu>
* re.c (rb_reg_quote): initial part of the string was never copied
to the quoted string.
Fri Jul 26 23:03:53 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (rb_eval): no need to convert to string twice.

View File

@ -104,7 +104,7 @@ module IRB
def EXCB.install_extend_commands
for args in @EXTEND_COMMANDS
def_extend_command *args
def_extend_command(*args)
end
end
@ -193,7 +193,7 @@ module IRB
def CE.install_extend_commands
for args in @EXTEND_COMMANDS
def_extend_command *args
def_extend_command(*args)
end
end

View File

@ -737,7 +737,7 @@ class RubyLex
def identify_identifier
token = ""
if peek(0) =~ /[$@]/
token.concat (c = getc)
token.concat(c = getc)
if c == "@" and peek(0) == "@"
token.concat getc
end

View File

@ -289,14 +289,14 @@ module Net
def send_mail( mailsrc, from_addr, *to_addrs )
do_ready from_addr, to_addrs.flatten
command().write_mail mailsrc
command().write_mail(mailsrc)
end
alias sendmail send_mail
def ready( from_addr, *to_addrs, &block )
do_ready from_addr, to_addrs.flatten
command().through_mail &block
command().through_mail(&block)
end
private
@ -304,7 +304,7 @@ module Net
def do_ready( from_addr, to_addrs )
raise ArgumentError, 'mail destination does not given' if to_addrs.empty?
command().mailfrom from_addr
command().rcpt to_addrs
command().rcpt(to_addrs)
end
end

View File

@ -73,7 +73,7 @@ def parseArgs(argc, nopt, single_opts, *opts)
end
rescue
print "Format Error!! : \"" + nopt + "\"\t[parseArgs]\n"
exit! -1
exit!(-1)
end
end
if ARGV.length < argc

View File

@ -200,6 +200,13 @@ num_nonzero_p(num)
return num;
}
static VALUE
num_to_int(num)
VALUE num;
{
return rb_funcall(num, id_to_i, 0, 0);
}
VALUE
rb_float_new(d)
double d;
@ -838,7 +845,7 @@ rb_num2long(val)
VALUE val;
{
if (NIL_P(val)) {
rb_raise(rb_eTypeError, "no implicit conversion to integer from nil");
rb_raise(rb_eTypeError, "no implicit conversion from nil to integer");
}
if (FIXNUM_P(val)) return FIX2LONG(val);
@ -861,16 +868,6 @@ rb_num2long(val)
case T_BIGNUM:
return rb_big2long(val);
#if 0
case T_STRING:
rb_raise(rb_eTypeError, "no implicit conversion to integer from string");
return Qnil; /* not reached */
case T_TRUE:
case T_FALSE:
rb_raise(rb_eTypeError, "no implicit conversion to integer from boolean");
return Qnil; /* not reached */
#endif
default:
val = rb_to_int(val);
return NUM2LONG(val);
@ -1052,7 +1049,7 @@ rb_int_induced_from(klass, x)
case T_BIGNUM:
return x;
case T_FLOAT:
return rb_funcall(x, rb_intern("to_i"), 0);
return rb_funcall(x, id_to_i, 0);
default:
rb_raise(rb_eTypeError, "failed to convert %s into Integer",
rb_class2name(CLASS_OF(x)));
@ -1635,6 +1632,7 @@ Init_Numeric()
rb_define_method(rb_cNumeric, "modulo", num_modulo, 1);
rb_define_method(rb_cNumeric, "remainder", num_remainder, 1);
rb_define_method(rb_cNumeric, "abs", num_abs, 0);
rb_define_method(rb_cNumeric, "to_int", num_to_int, 0);
rb_define_method(rb_cNumeric, "integer?", num_int_p, 0);
rb_define_method(rb_cNumeric, "zero?", num_zero_p, 0);
@ -1739,6 +1737,7 @@ Init_Numeric()
rb_define_method(rb_cFloat, "zero?", flo_zero_p, 0);
rb_define_method(rb_cFloat, "to_i", flo_truncate, 0);
rb_define_method(rb_cFloat, "to_int", flo_truncate, 0);
rb_define_method(rb_cFloat, "floor", flo_floor, 0);
rb_define_method(rb_cFloat, "ceil", flo_ceil, 0);
rb_define_method(rb_cFloat, "round", flo_round, 0);

3
re.c
View File

@ -1205,6 +1205,9 @@ rb_reg_quote(str)
meta_found:
tmp = rb_str_new(0, RSTRING(str)->len*2);
t = RSTRING(tmp)->ptr;
/* copy upto metacharacter */
memcpy(t, RSTRING(str)->ptr, s - RSTRING(str)->ptr);
t += s - RSTRING(str)->ptr;
for (; s < send; s++) {
c = *s;