зеркало из https://github.com/github/ruby.git
* io.c (io_close): call rb_io_close() directly if io is a T_FILE
object. [ruby-dev:27156] * file.c (file_expand_path): allow pathnames to expand. [ruby-dev:27152] * numeric.c (Init_Numeric): should define Fixnum#div. [ruby-dev:27129] * file.c (rb_thread_flock): wrap flock(2) by TRAP_BEG and TRAP_END. [ruby-dev:27122] * file.c (rb_file_join): call FilePathValue() to all Pathnames to join. [ruby-dev:27127] * file.c (rb_get_path): call StringValueCStr() to ensure no nul bytes in path strings. * gc.c (garbage_collect): need value for return. [ruby-dev:27127] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5363e91dba
Коммит
7559d2fd7a
29
ChangeLog
29
ChangeLog
|
@ -1,7 +1,17 @@
|
||||||
|
Tue Sep 20 00:34:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (io_close): call rb_io_close() directly if io is a T_FILE
|
||||||
|
object. [ruby-dev:27156]
|
||||||
|
|
||||||
Mon Sep 19 18:58:10 2005 Minero Aoki <aamine@loveruby.net>
|
Mon Sep 19 18:58:10 2005 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* file.c (rb_file_chown): should accept nil. [ruby-dev:27171]
|
* file.c (rb_file_chown): should accept nil. [ruby-dev:27171]
|
||||||
|
|
||||||
|
Mon Sep 19 18:29:54 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (file_expand_path): allow pathnames to expand.
|
||||||
|
[ruby-dev:27152]
|
||||||
|
|
||||||
Mon Sep 19 15:12:15 2005 Minero Aoki <aamine@loveruby.net>
|
Mon Sep 19 15:12:15 2005 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* ext/ripper/depend: do not make ripper/core.rb. [ruby-dev:26462]
|
* ext/ripper/depend: do not make ripper/core.rb. [ruby-dev:26462]
|
||||||
|
@ -63,6 +73,22 @@ Mon Sep 19 03:17:48 2005 Tanaka Akira <akr@m17n.org>
|
||||||
TRAP_BEG/TRAP_END to run signal hander in syswrite method.
|
TRAP_BEG/TRAP_END to run signal hander in syswrite method.
|
||||||
[ruby-dev:27134]
|
[ruby-dev:27134]
|
||||||
|
|
||||||
|
Mon Sep 19 01:07:38 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* numeric.c (Init_Numeric): should define Fixnum#div.
|
||||||
|
[ruby-dev:27129]
|
||||||
|
|
||||||
|
* file.c (rb_thread_flock): wrap flock(2) by TRAP_BEG and
|
||||||
|
TRAP_END. [ruby-dev:27122]
|
||||||
|
|
||||||
|
* file.c (rb_file_join): call FilePathValue() to all Pathnames to
|
||||||
|
join. [ruby-dev:27127]
|
||||||
|
|
||||||
|
* file.c (rb_get_path): call StringValueCStr() to ensure no nul
|
||||||
|
bytes in path strings.
|
||||||
|
|
||||||
|
* gc.c (garbage_collect): need value for return. [ruby-dev:27127]
|
||||||
|
|
||||||
Sun Sep 18 02:10:47 2005 why the lucky stiff <why@ruby-lang.org>
|
Sun Sep 18 02:10:47 2005 why the lucky stiff <why@ruby-lang.org>
|
||||||
|
|
||||||
* lib/yaml/rubytypes.rb: remove comments that are bungling up
|
* lib/yaml/rubytypes.rb: remove comments that are bungling up
|
||||||
|
@ -81,9 +107,6 @@ Sun Sep 18 02:10:47 2005 why the lucky stiff <why@ruby-lang.org>
|
||||||
|
|
||||||
Sun Sep 18 01:10:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Sep 18 01:10:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (rb_file_join): convert components by to_s instead of to_str.
|
|
||||||
fixed: [ruby-dev:27127]
|
|
||||||
|
|
||||||
* gc.c (garbage_collect): return false if no GC run.
|
* gc.c (garbage_collect): return false if no GC run.
|
||||||
|
|
||||||
Sat Sep 17 23:25:04 2005 sheepman <sheepman@sheepman.sakura.ne.jp>
|
Sat Sep 17 23:25:04 2005 sheepman <sheepman@sheepman.sakura.ne.jp>
|
||||||
|
|
15
file.c
15
file.c
|
@ -88,7 +88,8 @@ rb_get_path(VALUE obj)
|
||||||
if (rb_respond_to(obj, to_path)) {
|
if (rb_respond_to(obj, to_path)) {
|
||||||
obj = rb_funcall(obj, to_path, 0, 0);
|
obj = rb_funcall(obj, to_path, 0, 0);
|
||||||
}
|
}
|
||||||
tmp = rb_str_to_str(obj);
|
tmp = obj;
|
||||||
|
StringValueCStr(tmp);
|
||||||
exit:
|
exit:
|
||||||
if (obj != tmp) {
|
if (obj != tmp) {
|
||||||
rb_check_safe_obj(tmp);
|
rb_check_safe_obj(tmp);
|
||||||
|
@ -2271,6 +2272,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
||||||
long buflen, dirlen;
|
long buflen, dirlen;
|
||||||
int tainted;
|
int tainted;
|
||||||
|
|
||||||
|
FilePathValue(fname);
|
||||||
s = StringValuePtr(fname);
|
s = StringValuePtr(fname);
|
||||||
BUFINIT();
|
BUFINIT();
|
||||||
tainted = OBJ_TAINTED(fname);
|
tainted = OBJ_TAINTED(fname);
|
||||||
|
@ -2737,7 +2739,7 @@ rb_file_join(VALUE ary, VALUE sep)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tmp = rb_obj_as_string(tmp);
|
FilePathValue(tmp);
|
||||||
}
|
}
|
||||||
name = StringValueCStr(result);
|
name = StringValueCStr(result);
|
||||||
if (i > 0 && !NIL_P(sep)) {
|
if (i > 0 && !NIL_P(sep)) {
|
||||||
|
@ -2884,11 +2886,20 @@ static int
|
||||||
rb_thread_flock(int fd, int op, OpenFile *fptr)
|
rb_thread_flock(int fd, int op, OpenFile *fptr)
|
||||||
{
|
{
|
||||||
if (rb_thread_alone() || (op & LOCK_NB)) {
|
if (rb_thread_alone() || (op & LOCK_NB)) {
|
||||||
|
<<<<<<< file.c
|
||||||
|
int n;
|
||||||
|
|
||||||
|
TRAP_BEG;
|
||||||
|
n = flock(fd, op);
|
||||||
|
TRAP_END;
|
||||||
|
return n;
|
||||||
|
=======
|
||||||
int ret;
|
int ret;
|
||||||
TRAP_BEG;
|
TRAP_BEG;
|
||||||
ret = flock(fd, op);
|
ret = flock(fd, op);
|
||||||
TRAP_END;
|
TRAP_END;
|
||||||
return ret;
|
return ret;
|
||||||
|
>>>>>>> 1.208
|
||||||
}
|
}
|
||||||
op |= LOCK_NB;
|
op |= LOCK_NB;
|
||||||
while (flock(fd, op) < 0) {
|
while (flock(fd, op) < 0) {
|
||||||
|
|
4
io.c
4
io.c
|
@ -2064,6 +2064,10 @@ rb_io_close_m(VALUE io)
|
||||||
static VALUE
|
static VALUE
|
||||||
io_close(VALUE io)
|
io_close(VALUE io)
|
||||||
{
|
{
|
||||||
|
if (TYPE(io) == T_FILE) {
|
||||||
|
rb_io_close(io);
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
return rb_funcall(io, rb_intern("close"), 0, 0);
|
return rb_funcall(io, rb_intern("close"), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,17 +116,22 @@ class Prime
|
||||||
end
|
end
|
||||||
|
|
||||||
class Fixnum
|
class Fixnum
|
||||||
|
remove_method :/
|
||||||
alias / quo
|
alias / quo
|
||||||
|
alias_method :/, :quo
|
||||||
|
p :fixdiv
|
||||||
|
p [[:fixdiv, 1.div(1)]]
|
||||||
end
|
end
|
||||||
|
|
||||||
class Bignum
|
class Bignum
|
||||||
|
remove_method :/
|
||||||
alias / quo
|
alias / quo
|
||||||
end
|
end
|
||||||
|
|
||||||
class Rational
|
class Rational
|
||||||
Unify = true
|
Unify = true
|
||||||
|
|
||||||
remove_method(:inspect)
|
remove_method :inspect
|
||||||
def inspect
|
def inspect
|
||||||
format "%s/%s", numerator.inspect, denominator.inspect
|
format "%s/%s", numerator.inspect, denominator.inspect
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
def Rational(a, b = 1)
|
def Rational(a, b = 1)
|
||||||
|
p [:Rational, a, b]
|
||||||
if a.kind_of?(Rational) && b == 1
|
if a.kind_of?(Rational) && b == 1
|
||||||
a
|
a
|
||||||
else
|
else
|
||||||
|
@ -54,9 +55,13 @@ class Rational < Numeric
|
||||||
num = -num
|
num = -num
|
||||||
den = -den
|
den = -den
|
||||||
end
|
end
|
||||||
|
p [:reduce, num, den]
|
||||||
gcd = num.gcd(den)
|
gcd = num.gcd(den)
|
||||||
|
p [:div1, num, num.class, gcd]
|
||||||
num = num.div(gcd)
|
num = num.div(gcd)
|
||||||
|
p [:div2, den, gcd]
|
||||||
den = den.div(gcd)
|
den = den.div(gcd)
|
||||||
|
p [:gcd=, gcd]
|
||||||
if den == 1 && defined?(Unify)
|
if den == 1 && defined?(Unify)
|
||||||
num
|
num
|
||||||
else
|
else
|
||||||
|
@ -333,6 +338,7 @@ end
|
||||||
class Fixnum
|
class Fixnum
|
||||||
undef quo
|
undef quo
|
||||||
def quo(other)
|
def quo(other)
|
||||||
|
p [:quo, self, other]
|
||||||
Rational.new!(self,1) / other
|
Rational.new!(self,1) / other
|
||||||
end
|
end
|
||||||
alias rdiv quo
|
alias rdiv quo
|
||||||
|
|
|
@ -259,7 +259,6 @@ num_div(VALUE x, VALUE y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* num.divmod( aNumeric ) -> anArray
|
* num.divmod( aNumeric ) -> anArray
|
||||||
|
@ -2825,6 +2824,7 @@ Init_Numeric(void)
|
||||||
rb_define_method(rb_cFixnum, "-", fix_minus, 1);
|
rb_define_method(rb_cFixnum, "-", fix_minus, 1);
|
||||||
rb_define_method(rb_cFixnum, "*", fix_mul, 1);
|
rb_define_method(rb_cFixnum, "*", fix_mul, 1);
|
||||||
rb_define_method(rb_cFixnum, "/", fix_div, 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, "%", fix_mod, 1);
|
||||||
rb_define_method(rb_cFixnum, "modulo", fix_mod, 1);
|
rb_define_method(rb_cFixnum, "modulo", fix_mod, 1);
|
||||||
rb_define_method(rb_cFixnum, "divmod", fix_divmod, 1);
|
rb_define_method(rb_cFixnum, "divmod", fix_divmod, 1);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче