summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--eval.c2
-rw-r--r--lib/rational.rb36
3 files changed, 18 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 036fe99605..e7a5c155a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,18 @@
+Mon Feb 20 01:05:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/rational.rb (Integer::gcd): replaced by gcd4 in
+ [ruby-core:07390]. [ruby-core:07377]
+
Mon Feb 20 00:57:02 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl.h (OSSL_Debug): should not use __func__.
[ruby-dev:28339]
+Sun Feb 19 04:46:29 2006 Guy Decoux <ts@moulon.inra.fr>
+
+ * eval.c: initial value for block_unique must be 1.
+ [ruby-talk:180420]
+
Sat Feb 18 23:58:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/tracer.rb (Tracer::Tracer.add_filter): turn on tracer mode
diff --git a/eval.c b/eval.c
index 8a26fc36d3..dc72e7425d 100644
--- a/eval.c
+++ b/eval.c
@@ -755,7 +755,7 @@ struct SCOPE *ruby_scope;
static struct FRAME *top_frame;
static struct SCOPE *top_scope;
-static unsigned long frame_unique = 0;
+static unsigned long frame_unique = 1;
#define PUSH_FRAME() do { \
struct FRAME _frame; \
diff --git a/lib/rational.rb b/lib/rational.rb
index 3f15cfafa8..5220f319f2 100644
--- a/lib/rational.rb
+++ b/lib/rational.rb
@@ -436,36 +436,14 @@ class Integer
# The result is positive, no matter the sign of the arguments.
#
def gcd(n)
- m = self.abs
- n = n.abs
-
- return n if m == 0
- return m if n == 0
-
- b = 0
- while n[0] == 0 && m[0] == 0
- b += 1; n >>= 1; m >>= 1
- end
- m >>= 1 while m[0] == 0
- n >>= 1 while n[0] == 0
- while m != n
- m, n = n, m if n > m
- m -= n; m >>= 1 while m[0] == 0
- end
- m << b
- end
-
- def gcd2(int)
- a = self.abs
- b = int.abs
-
- a, b = b, a if a < b
-
- while b != 0
- void, a = a.divmod(b)
- a, b = b, a
+ min = self.abs
+ max = other.abs
+ while min > 0
+ tmp = min
+ min = max % min
+ max = tmp
end
- return a
+ max
end
#