~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to debian/patches/114_bignum.patch

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
* numeric.c (fix_plus): addition in Fixnum will never overflow
2
 
  long.  a patch from Ondrej Bilka <neleai at seznam.cz>.
3
 
  [ruby-core:08794]
4
 
* numeric.c (fix_minus): ditto.
5
 
* bignum.c (rb_big_pow): eagerly truncate resulting bignum.
6
 
  [ruby-core:08794]
7
 
 
8
 
diff -ruN ruby-1.8.5.orig/bignum.c ruby-1.8.5/bignum.c
9
 
--- ruby-1.8.5.orig/bignum.c    2006-04-10 01:10:36.000000000 +0900
10
 
+++ ruby-1.8.5/bignum.c 2006-09-19 14:44:51.000000000 +0900
11
 
@@ -3,7 +3,7 @@
12
 
   bignum.c -
13
 
 
14
 
   $Author: matz $
15
 
-  $Date: 2006/04/09 16:10:36 $
16
 
+  $Date: 2006/09/09 15:27:34 $
17
 
   created at: Fri Jun 10 00:48:55 JST 1994
18
 
 
19
 
   Copyright (C) 1993-2003 Yukihiro Matsumoto
20
 
@@ -1206,15 +1206,8 @@
21
 
     }
22
 
 }
23
 
 
24
 
-/*
25
 
- *  call-seq:
26
 
- *     big * other  => Numeric
27
 
- *
28
 
- *  Multiplies big and other, returning the result.
29
 
- */
30
 
-
31
 
 VALUE
32
 
-rb_big_mul(x, y)
33
 
+rb_big_mul0(x, y)
34
 
     VALUE x, y;
35
 
 {
36
 
     long i, j;
37
 
@@ -1257,7 +1250,21 @@
38
 
        }
39
 
     }
40
 
 
41
 
-    return bignorm(z);
42
 
+    return z;
43
 
+}
44
 
+
45
 
+/*
46
 
+ *  call-seq:
47
 
+ *     big * other  => Numeric
48
 
+ *
49
 
+ *  Multiplies big and other, returning the result.
50
 
+ */
51
 
+
52
 
+VALUE
53
 
+rb_big_mul(x, y)
54
 
+    VALUE x, y;
55
 
+{
56
 
+    return bignorm(rb_big_mul0(x, y));
57
 
 }
58
 
 
59
 
 static void
60
 
@@ -1616,9 +1623,11 @@
61
 
                if (yy == 0) break;
62
 
                while (yy % 2 == 0) {
63
 
                    yy /= 2;
64
 
-                   x = rb_big_mul(x, x);
65
 
+                   x = rb_big_mul0(x, x);
66
 
+                   if (!BDIGITS(x)[RBIGNUM(x)->len-1]) RBIGNUM(x)->len--;
67
 
                }
68
 
-               z = rb_big_mul(z, x);
69
 
+               z = rb_big_mul0(z, x);
70
 
+               if (!BDIGITS(z)[RBIGNUM(z)->len-1]) RBIGNUM(z)->len--;
71
 
            }
72
 
            return bignorm(z);
73
 
        }
74
 
diff -ruN ruby-1.8.5.orig/numeric.c ruby-1.8.5/numeric.c
75
 
--- ruby-1.8.5.orig/numeric.c   2006-05-01 12:46:46.000000000 +0900
76
 
+++ ruby-1.8.5/numeric.c        2006-09-19 14:44:51.000000000 +0900
77
 
@@ -1982,11 +1982,8 @@
78
 
        a = FIX2LONG(x);
79
 
        b = FIX2LONG(y);
80
 
        c = a + b;
81
 
-       r = LONG2FIX(c);
82
 
+       r = LONG2NUM(c);
83
 
 
84
 
-       if (FIX2LONG(r) != c) {
85
 
-           r = rb_big_plus(rb_int2big(a), rb_int2big(b));
86
 
-       }
87
 
        return r;
88
 
     }
89
 
     if (TYPE(y) == T_FLOAT) {
90
 
@@ -2015,11 +2012,8 @@
91
 
        a = FIX2LONG(x);
92
 
        b = FIX2LONG(y);
93
 
        c = a - b;
94
 
-       r = LONG2FIX(c);
95
 
+       r = LONG2NUM(c);
96
 
 
97
 
-       if (FIX2LONG(r) != c) {
98
 
-           r = rb_big_minus(rb_int2big(a), rb_int2big(b));
99
 
-       }
100
 
        return r;
101
 
     }
102
 
     if (TYPE(y) == T_FLOAT) {