summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-19 16:01:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-19 16:01:06 +0000
commit047849e878344cedf991a20525c955495b4268fe (patch)
treee5b382e3e6dc23c0eef00a2da9fb50c0e2281495
parent13e32804c892bc8f4171f4c9cd73b7fed7645dc3 (diff)
downloadruby-047849e878344cedf991a20525c955495b4268fe.tar.gz
ruby-047849e878344cedf991a20525c955495b4268fe.tar.xz
ruby-047849e878344cedf991a20525c955495b4268fe.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@9236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog29
-rw-r--r--file.c15
-rw-r--r--io.c4
-rw-r--r--lib/mathn.rb7
-rw-r--r--lib/rational.rb6
-rw-r--r--numeric.c2
6 files changed, 56 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c13417d51..043c3e330 100644
--- a/ChangeLog
+++ b/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>
* 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>
diff --git a/file.c b/file.c
index 6302bb893..d4a993be2 100644
--- a/file.c
+++ b/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) {
diff --git a/io.c b/io.c
index 04e46e085..f3badc966 100644
--- a/io.c
+++ b/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);
}
diff --git a/lib/mathn.rb b/lib/mathn.rb
index 19325f299..ddfca5768 100644
--- a/lib/mathn.rb
+++ b/lib/mathn.rb
@@ -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
diff --git a/lib/rational.rb b/lib/rational.rb
index 224100485..f4570bd30 100644
--- a/lib/rational.rb
+++ b/lib/rational.rb
@@ -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
diff --git a/numeric.c b/numeric.c
index f30d959a8..8ab8cd662 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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);