summaryrefslogtreecommitdiff
path: root/patches/mpfr/3.1.2/200-vasprintf.patch
blob: 43848f7b1166e6fd30306fd9fd7a6952b05d52fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
--- mpfr-3.1.2-a/PATCHES	2014-06-30 15:17:53.337268149 +0000
+++ mpfr-3.1.2-b/PATCHES	2014-06-30 15:17:53.417270314 +0000
@@ -0,0 +1 @@
+vasprintf
diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
--- mpfr-3.1.2-a/VERSION	2014-06-30 15:17:53.337268149 +0000
+++ mpfr-3.1.2-b/VERSION	2014-06-30 15:17:53.413270206 +0000
@@ -1 +1 @@
-3.1.2-p9
+3.1.2-p10
diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
--- mpfr-3.1.2-a/src/mpfr.h	2014-06-30 15:17:53.337268149 +0000
+++ mpfr-3.1.2-b/src/mpfr.h	2014-06-30 15:17:53.413270206 +0000
@@ -27,7 +27,7 @@
 #define MPFR_VERSION_MAJOR 3
 #define MPFR_VERSION_MINOR 1
 #define MPFR_VERSION_PATCHLEVEL 2
-#define MPFR_VERSION_STRING "3.1.2-p9"
+#define MPFR_VERSION_STRING "3.1.2-p10"
 
 /* Macros dealing with MPFR VERSION */
 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.1.2-a/src/vasprintf.c mpfr-3.1.2-b/src/vasprintf.c
--- mpfr-3.1.2-a/src/vasprintf.c	2013-11-15 00:51:49.267334408 +0000
+++ mpfr-3.1.2-b/src/vasprintf.c	2014-06-30 15:17:53.377269231 +0000
@@ -884,14 +884,18 @@
            first digit, we want the exponent for radix two and the decimal
            point AFTER the first digit. */
         {
-          MPFR_ASSERTN (exp > MPFR_EMIN_MIN /4); /* possible overflow */
+          /* An integer overflow is normally not possible since MPFR_EXP_MIN
+             is twice as large as MPFR_EMIN_MIN. */
+          MPFR_ASSERTN (exp > (MPFR_EXP_MIN + 3) / 4);
           exp = (exp - 1) * 4;
         }
       else
         /* EXP is the exponent for decimal point BEFORE the first digit, we
            want the exponent for decimal point AFTER the first digit. */
         {
-          MPFR_ASSERTN (exp > MPFR_EMIN_MIN); /* possible overflow */
+          /* An integer overflow is normally not possible since MPFR_EXP_MIN
+             is twice as large as MPFR_EMIN_MIN. */
+          MPFR_ASSERTN (exp > MPFR_EXP_MIN);
           --exp;
         }
     }
diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
--- mpfr-3.1.2-a/src/version.c	2014-06-30 15:17:53.337268149 +0000
+++ mpfr-3.1.2-b/src/version.c	2014-06-30 15:17:53.413270206 +0000
@@ -25,5 +25,5 @@
 const char *
 mpfr_get_version (void)
 {
-  return "3.1.2-p9";
+  return "3.1.2-p10";
 }
diff -Naurd mpfr-3.1.2-a/tests/tsprintf.c mpfr-3.1.2-b/tests/tsprintf.c
--- mpfr-3.1.2-a/tests/tsprintf.c	2013-11-15 00:51:49.267334408 +0000
+++ mpfr-3.1.2-b/tests/tsprintf.c	2014-06-30 15:17:53.377269231 +0000
@@ -1184,6 +1184,69 @@
   check_emax_aux (MPFR_EMAX_MAX);
 }
 
+static void
+check_emin_aux (mpfr_exp_t e)
+{
+  mpfr_t x;
+  char *s1, s2[256];
+  int i;
+  mpfr_exp_t emin;
+  mpz_t ee;
+
+  MPFR_ASSERTN (e >= LONG_MIN);
+  emin = mpfr_get_emin ();
+  set_emin (e);
+
+  mpfr_init2 (x, 16);
+  mpz_init (ee);
+
+  mpfr_setmin (x, e);
+  mpz_set_si (ee, e);
+  mpz_sub_ui (ee, ee, 1);
+
+  i = mpfr_asprintf (&s1, "%Ra", x);
+  MPFR_ASSERTN (i > 0);
+
+  gmp_snprintf (s2, 256, "0x1p%Zd", ee);
+
+  if (strcmp (s1, s2) != 0)
+    {
+      printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
+      printf ("Expected %s\n", s2);
+      printf ("Got      %s\n", s1);
+      exit (1);
+    }
+
+  mpfr_free_str (s1);
+
+  i = mpfr_asprintf (&s1, "%Rb", x);
+  MPFR_ASSERTN (i > 0);
+
+  gmp_snprintf (s2, 256, "1p%Zd", ee);
+
+  if (strcmp (s1, s2) != 0)
+    {
+      printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
+      printf ("Expected %s\n", s2);
+      printf ("Got      %s\n", s1);
+      exit (1);
+    }
+
+  mpfr_free_str (s1);
+
+  mpfr_clear (x);
+  mpz_clear (ee);
+  set_emin (emin);
+}
+
+static void
+check_emin (void)
+{
+  check_emin_aux (-15);
+  check_emin_aux (mpfr_get_emin ());
+  check_emin_aux (MPFR_EMIN_MIN);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -1203,6 +1266,7 @@
   decimal ();
   mixed ();
   check_emax ();
+  check_emin ();
 
 #if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE)
   locale_da_DK ();