* 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:
parent
448610abec
commit
89dbf99bac
10
ChangeLog
10
ChangeLog
@ -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>
|
Fri Jul 26 23:03:53 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* eval.c (rb_eval): no need to convert to string twice.
|
* eval.c (rb_eval): no need to convert to string twice.
|
||||||
|
@ -104,7 +104,7 @@ module IRB
|
|||||||
|
|
||||||
def EXCB.install_extend_commands
|
def EXCB.install_extend_commands
|
||||||
for args in @EXTEND_COMMANDS
|
for args in @EXTEND_COMMANDS
|
||||||
def_extend_command *args
|
def_extend_command(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ module IRB
|
|||||||
|
|
||||||
def CE.install_extend_commands
|
def CE.install_extend_commands
|
||||||
for args in @EXTEND_COMMANDS
|
for args in @EXTEND_COMMANDS
|
||||||
def_extend_command *args
|
def_extend_command(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -737,7 +737,7 @@ class RubyLex
|
|||||||
def identify_identifier
|
def identify_identifier
|
||||||
token = ""
|
token = ""
|
||||||
if peek(0) =~ /[$@]/
|
if peek(0) =~ /[$@]/
|
||||||
token.concat (c = getc)
|
token.concat(c = getc)
|
||||||
if c == "@" and peek(0) == "@"
|
if c == "@" and peek(0) == "@"
|
||||||
token.concat getc
|
token.concat getc
|
||||||
end
|
end
|
||||||
|
@ -289,14 +289,14 @@ module Net
|
|||||||
|
|
||||||
def send_mail( mailsrc, from_addr, *to_addrs )
|
def send_mail( mailsrc, from_addr, *to_addrs )
|
||||||
do_ready from_addr, to_addrs.flatten
|
do_ready from_addr, to_addrs.flatten
|
||||||
command().write_mail mailsrc
|
command().write_mail(mailsrc)
|
||||||
end
|
end
|
||||||
|
|
||||||
alias sendmail send_mail
|
alias sendmail send_mail
|
||||||
|
|
||||||
def ready( from_addr, *to_addrs, &block )
|
def ready( from_addr, *to_addrs, &block )
|
||||||
do_ready from_addr, to_addrs.flatten
|
do_ready from_addr, to_addrs.flatten
|
||||||
command().through_mail &block
|
command().through_mail(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -304,7 +304,7 @@ module Net
|
|||||||
def do_ready( from_addr, to_addrs )
|
def do_ready( from_addr, to_addrs )
|
||||||
raise ArgumentError, 'mail destination does not given' if to_addrs.empty?
|
raise ArgumentError, 'mail destination does not given' if to_addrs.empty?
|
||||||
command().mailfrom from_addr
|
command().mailfrom from_addr
|
||||||
command().rcpt to_addrs
|
command().rcpt(to_addrs)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -73,7 +73,7 @@ def parseArgs(argc, nopt, single_opts, *opts)
|
|||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
print "Format Error!! : \"" + nopt + "\"\t[parseArgs]\n"
|
print "Format Error!! : \"" + nopt + "\"\t[parseArgs]\n"
|
||||||
exit! -1
|
exit!(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ARGV.length < argc
|
if ARGV.length < argc
|
||||||
|
23
numeric.c
23
numeric.c
@ -200,6 +200,13 @@ num_nonzero_p(num)
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
num_to_int(num)
|
||||||
|
VALUE num;
|
||||||
|
{
|
||||||
|
return rb_funcall(num, id_to_i, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_float_new(d)
|
rb_float_new(d)
|
||||||
double d;
|
double d;
|
||||||
@ -838,7 +845,7 @@ rb_num2long(val)
|
|||||||
VALUE val;
|
VALUE val;
|
||||||
{
|
{
|
||||||
if (NIL_P(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);
|
if (FIXNUM_P(val)) return FIX2LONG(val);
|
||||||
@ -861,16 +868,6 @@ rb_num2long(val)
|
|||||||
case T_BIGNUM:
|
case T_BIGNUM:
|
||||||
return rb_big2long(val);
|
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:
|
default:
|
||||||
val = rb_to_int(val);
|
val = rb_to_int(val);
|
||||||
return NUM2LONG(val);
|
return NUM2LONG(val);
|
||||||
@ -1052,7 +1049,7 @@ rb_int_induced_from(klass, x)
|
|||||||
case T_BIGNUM:
|
case T_BIGNUM:
|
||||||
return x;
|
return x;
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
return rb_funcall(x, rb_intern("to_i"), 0);
|
return rb_funcall(x, id_to_i, 0);
|
||||||
default:
|
default:
|
||||||
rb_raise(rb_eTypeError, "failed to convert %s into Integer",
|
rb_raise(rb_eTypeError, "failed to convert %s into Integer",
|
||||||
rb_class2name(CLASS_OF(x)));
|
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, "modulo", num_modulo, 1);
|
||||||
rb_define_method(rb_cNumeric, "remainder", num_remainder, 1);
|
rb_define_method(rb_cNumeric, "remainder", num_remainder, 1);
|
||||||
rb_define_method(rb_cNumeric, "abs", num_abs, 0);
|
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, "integer?", num_int_p, 0);
|
||||||
rb_define_method(rb_cNumeric, "zero?", num_zero_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, "zero?", flo_zero_p, 0);
|
||||||
|
|
||||||
rb_define_method(rb_cFloat, "to_i", flo_truncate, 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, "floor", flo_floor, 0);
|
||||||
rb_define_method(rb_cFloat, "ceil", flo_ceil, 0);
|
rb_define_method(rb_cFloat, "ceil", flo_ceil, 0);
|
||||||
rb_define_method(rb_cFloat, "round", flo_round, 0);
|
rb_define_method(rb_cFloat, "round", flo_round, 0);
|
||||||
|
3
re.c
3
re.c
@ -1205,6 +1205,9 @@ rb_reg_quote(str)
|
|||||||
meta_found:
|
meta_found:
|
||||||
tmp = rb_str_new(0, RSTRING(str)->len*2);
|
tmp = rb_str_new(0, RSTRING(str)->len*2);
|
||||||
t = RSTRING(tmp)->ptr;
|
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++) {
|
for (; s < send; s++) {
|
||||||
c = *s;
|
c = *s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user