* 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:
matz 2005-09-19 16:01:06 +00:00
Родитель 5363e91dba
Коммит 7559d2fd7a
6 изменённых файлов: 56 добавлений и 7 удалений

Просмотреть файл

@ -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>
* 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>
* 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.
[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>
* 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>
* 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.
Sat Sep 17 23:25:04 2005 sheepman <sheepman@sheepman.sakura.ne.jp>

15
file.c
Просмотреть файл

@ -88,7 +88,8 @@ rb_get_path(VALUE obj)
if (rb_respond_to(obj, to_path)) {
obj = rb_funcall(obj, to_path, 0, 0);
}
tmp = rb_str_to_str(obj);
tmp = obj;
StringValueCStr(tmp);
exit:
if (obj != tmp) {
rb_check_safe_obj(tmp);
@ -2271,6 +2272,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
long buflen, dirlen;
int tainted;
FilePathValue(fname);
s = StringValuePtr(fname);
BUFINIT();
tainted = OBJ_TAINTED(fname);
@ -2737,7 +2739,7 @@ rb_file_join(VALUE ary, VALUE sep)
}
break;
default:
tmp = rb_obj_as_string(tmp);
FilePathValue(tmp);
}
name = StringValueCStr(result);
if (i > 0 && !NIL_P(sep)) {
@ -2884,11 +2886,20 @@ static int
rb_thread_flock(int fd, int op, OpenFile *fptr)
{
if (rb_thread_alone() || (op & LOCK_NB)) {
<<<<<<< file.c
int n;
TRAP_BEG;
n = flock(fd, op);
TRAP_END;
return n;
=======
int ret;
TRAP_BEG;
ret = flock(fd, op);
TRAP_END;
return ret;
>>>>>>> 1.208
}
op |= LOCK_NB;
while (flock(fd, op) < 0) {

4
io.c
Просмотреть файл

@ -2064,6 +2064,10 @@ rb_io_close_m(VALUE io)
static VALUE
io_close(VALUE io)
{
if (TYPE(io) == T_FILE) {
rb_io_close(io);
return Qnil;
}
return rb_funcall(io, rb_intern("close"), 0, 0);
}

Просмотреть файл

@ -116,17 +116,22 @@ class Prime
end
class Fixnum
remove_method :/
alias / quo
alias_method :/, :quo
p :fixdiv
p [[:fixdiv, 1.div(1)]]
end
class Bignum
remove_method :/
alias / quo
end
class Rational
Unify = true
remove_method(:inspect)
remove_method :inspect
def inspect
format "%s/%s", numerator.inspect, denominator.inspect
end

Просмотреть файл

@ -37,6 +37,7 @@
#
def Rational(a, b = 1)
p [:Rational, a, b]
if a.kind_of?(Rational) && b == 1
a
else
@ -54,9 +55,13 @@ class Rational < Numeric
num = -num
den = -den
end
p [:reduce, num, den]
gcd = num.gcd(den)
p [:div1, num, num.class, gcd]
num = num.div(gcd)
p [:div2, den, gcd]
den = den.div(gcd)
p [:gcd=, gcd]
if den == 1 && defined?(Unify)
num
else
@ -333,6 +338,7 @@ end
class Fixnum
undef quo
def quo(other)
p [:quo, self, other]
Rational.new!(self,1) / other
end
alias rdiv quo

Просмотреть файл

@ -259,7 +259,6 @@ num_div(VALUE x, VALUE y)
}
/*
* call-seq:
* 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_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);