wok-6.x diff mpfr/stuff/mpfr-3.1.0.patch @ rev 19144

electricsheep, gejengel: ffmpeg > 2.4 support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu May 19 15:51:15 2016 +0200 (2016-05-19)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mpfr/stuff/mpfr-3.1.0.patch	Thu May 19 15:51:15 2016 +0200
     1.3 @@ -0,0 +1,473 @@
     1.4 +Submitted By:            Matt Burgess <matthew_at_linuxfromscratch_dot_org>
     1.5 +Date:                    2011-12-22
     1.6 +Initial Package Version: 3.1.0
     1.7 +Upstream Status:         Already in upstream patch repo
     1.8 +Origin:                  Upstream
     1.9 +Description:             This patch contains patches for several bugs in MPFR,
    1.10 +                         the main one being a rounding related error with the
    1.11 +                         mpfr_*printf functions.
    1.12 +
    1.13 +diff -Naur mpfr-3.1.0.orig/PATCHES mpfr-3.1.0/PATCHES
    1.14 +--- mpfr-3.1.0.orig/PATCHES	2011-10-03 08:17:15.000000000 +0000
    1.15 ++++ mpfr-3.1.0/PATCHES	2011-12-22 11:08:42.188819413 +0000
    1.16 +@@ -0,0 +1,4 @@
    1.17 ++gmp41compat
    1.18 ++vasprintf
    1.19 ++lib-search-path
    1.20 ++mpfr_unlikely
    1.21 +diff -Naur mpfr-3.1.0.orig/VERSION mpfr-3.1.0/VERSION
    1.22 +--- mpfr-3.1.0.orig/VERSION	2011-10-03 08:17:15.000000000 +0000
    1.23 ++++ mpfr-3.1.0/VERSION	2011-11-28 12:22:52.000000000 +0000
    1.24 +@@ -1 +1 @@
    1.25 +-3.1.0
    1.26 ++3.1.0-p4
    1.27 +diff -Naur mpfr-3.1.0.orig/doc/mpfr.info mpfr-3.1.0/doc/mpfr.info
    1.28 +--- mpfr-3.1.0.orig/doc/mpfr.info	2011-10-03 09:43:04.000000000 +0000
    1.29 ++++ mpfr-3.1.0/doc/mpfr.info	2011-11-28 12:22:52.000000000 +0000
    1.30 +@@ -2994,11 +2994,12 @@
    1.31 + 
    1.32 +    * `mpfr_urandom' and `mpfr_urandomb' changed in MPFR 3.1.  Their
    1.33 +      behavior no longer depends on the platform (assuming this is also
    1.34 +-     true for GMP's random generator).  As a consequence, the returned
    1.35 +-     values can be different between MPFR 3.1 and previous MPFR
    1.36 +-     versions.  Note: as the reproducibility of these functions was not
    1.37 +-     specified before MPFR 3.1, the MPFR 3.1 behavior is _not_ regarded
    1.38 +-     as backward incompatible with previous versions.
    1.39 ++     true for GMP's random generator, which is not the case between GMP
    1.40 ++     4.1 and 4.2 if `gmp_randinit_default' is used).  As a consequence,
    1.41 ++     the returned values can be different between MPFR 3.1 and previous
    1.42 ++     MPFR versions.  Note: as the reproducibility of these functions
    1.43 ++     was not specified before MPFR 3.1, the MPFR 3.1 behavior is _not_
    1.44 ++     regarded as backward incompatible with previous versions.
    1.45 + 
    1.46 + 
    1.47 + 
    1.48 +@@ -4239,13 +4240,13 @@
    1.49 + Node: Type and Macro Changes129308
    1.50 + Node: Added Functions132029
    1.51 + Node: Changed Functions134972
    1.52 +-Node: Removed Functions139167
    1.53 +-Node: Other Changes139579
    1.54 +-Node: Contributors141108
    1.55 +-Node: References143574
    1.56 +-Node: GNU Free Documentation License145315
    1.57 +-Node: Concept Index167758
    1.58 +-Node: Function and Type Index173677
    1.59 ++Node: Removed Functions139253
    1.60 ++Node: Other Changes139665
    1.61 ++Node: Contributors141194
    1.62 ++Node: References143660
    1.63 ++Node: GNU Free Documentation License145401
    1.64 ++Node: Concept Index167844
    1.65 ++Node: Function and Type Index173763
    1.66 + 
    1.67 + End Tag Table
    1.68 + 
    1.69 +diff -Naur mpfr-3.1.0.orig/doc/mpfr.texi mpfr-3.1.0/doc/mpfr.texi
    1.70 +--- mpfr-3.1.0.orig/doc/mpfr.texi	2011-10-03 08:17:14.000000000 +0000
    1.71 ++++ mpfr-3.1.0/doc/mpfr.texi	2011-11-28 12:22:52.000000000 +0000
    1.72 +@@ -3466,8 +3466,9 @@
    1.73 + a lack of specification.
    1.74 + 
    1.75 + @item @code{mpfr_urandom} and @code{mpfr_urandomb} changed in MPFR 3.1.
    1.76 +-Their behavior no longer depends on the platform (assuming this is also
    1.77 +-true for GMP's random generator).  As a consequence, the returned values
    1.78 ++Their behavior no longer depends on the platform (assuming this is also true
    1.79 ++for GMP's random generator, which is not the case between GMP 4.1 and 4.2 if
    1.80 ++@code{gmp_randinit_default} is used).  As a consequence, the returned values
    1.81 + can be different between MPFR 3.1 and previous MPFR versions.
    1.82 + Note: as the reproducibility of these functions was not specified
    1.83 + before MPFR 3.1, the MPFR 3.1 behavior is @emph{not} regarded as
    1.84 +diff -Naur mpfr-3.1.0.orig/src/mpfr-impl.h mpfr-3.1.0/src/mpfr-impl.h
    1.85 +--- mpfr-3.1.0.orig/src/mpfr-impl.h	2011-10-03 08:17:09.000000000 +0000
    1.86 ++++ mpfr-3.1.0/src/mpfr-impl.h	2011-10-05 21:39:57.000000000 +0000
    1.87 +@@ -988,10 +988,11 @@
    1.88 +  ******************************************************/
    1.89 + 
    1.90 + /* Theses macros help the compiler to determine if a test is
    1.91 +- * likely or unlikely. */
    1.92 ++   likely or unlikely. The !! is necessary in case x is larger
    1.93 ++   than a long. */
    1.94 + #if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
    1.95 + # define MPFR_LIKELY(x) (__builtin_expect(!!(x),1))
    1.96 +-# define MPFR_UNLIKELY(x) (__builtin_expect((x),0))
    1.97 ++# define MPFR_UNLIKELY(x) (__builtin_expect(!!(x),0))
    1.98 + #else
    1.99 + # define MPFR_LIKELY(x) (x)
   1.100 + # define MPFR_UNLIKELY(x) (x)
   1.101 +diff -Naur mpfr-3.1.0.orig/src/mpfr.h mpfr-3.1.0/src/mpfr.h
   1.102 +--- mpfr-3.1.0.orig/src/mpfr.h	2011-10-03 08:17:09.000000000 +0000
   1.103 ++++ mpfr-3.1.0/src/mpfr.h	2011-11-28 12:22:52.000000000 +0000
   1.104 +@@ -27,7 +27,7 @@
   1.105 + #define MPFR_VERSION_MAJOR 3
   1.106 + #define MPFR_VERSION_MINOR 1
   1.107 + #define MPFR_VERSION_PATCHLEVEL 0
   1.108 +-#define MPFR_VERSION_STRING "3.1.0"
   1.109 ++#define MPFR_VERSION_STRING "3.1.0-p4"
   1.110 + 
   1.111 + /* Macros dealing with MPFR VERSION */
   1.112 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   1.113 +diff -Naur mpfr-3.1.0.orig/src/vasprintf.c mpfr-3.1.0/src/vasprintf.c
   1.114 +--- mpfr-3.1.0.orig/src/vasprintf.c	2011-10-03 08:17:09.000000000 +0000
   1.115 ++++ mpfr-3.1.0/src/vasprintf.c	2011-11-03 15:15:11.000000000 +0000
   1.116 +@@ -1178,7 +1178,7 @@
   1.117 +   mpfr_exp_t exp;
   1.118 +   char * str;
   1.119 +   const int spec_g = (spec.spec == 'g' || spec.spec == 'G');
   1.120 +-  const int keep_trailing_zeros = spec_g && spec.alt;
   1.121 ++  const int keep_trailing_zeros = !spec_g || spec.alt;
   1.122 + 
   1.123 +   /* WARNING: an empty precision field is forbidden (it means precision = 6
   1.124 +      and it should have been changed to 6 before the function call) */
   1.125 +@@ -1356,7 +1356,7 @@
   1.126 +   else
   1.127 +     /* 1 <= |p| */
   1.128 +     {
   1.129 +-      size_t nsd;  /* Number of significant digits */
   1.130 ++      size_t str_len;
   1.131 + 
   1.132 +       /* Determine the position of the most significant decimal digit. */
   1.133 +       exp = floor_log10 (p);
   1.134 +@@ -1365,12 +1365,10 @@
   1.135 +         /* P is too large to print all its integral part digits */
   1.136 +         return -1;
   1.137 + 
   1.138 +-      np->ip_size = exp + 1;
   1.139 +-
   1.140 +-      nsd = spec.prec + np->ip_size;
   1.141 +       if (dec_info == NULL)
   1.142 +-        {
   1.143 +-          str = mpfr_get_str (NULL, &exp, 10, nsd, p, spec.rnd_mode);
   1.144 ++        { /* this case occurs with mpfr_printf ("%.0RUf", x) with x=9.5 */
   1.145 ++          str =
   1.146 ++            mpfr_get_str (NULL, &exp, 10, spec.prec+exp+1, p, spec.rnd_mode);
   1.147 +           register_string (np->sl, str);
   1.148 +         }
   1.149 +       else
   1.150 +@@ -1379,81 +1377,60 @@
   1.151 +           str = dec_info->str;
   1.152 +         }
   1.153 +       np->ip_ptr = MPFR_IS_NEG (p) ? ++str : str; /* skip sign */
   1.154 ++      str_len = strlen (str);
   1.155 ++
   1.156 ++      /* integral part */
   1.157 ++      if (exp > str_len)
   1.158 ++        /* mpfr_get_str gives no trailing zero when p is rounded up to the next
   1.159 ++           power of 10 (p integer, so no fractional part) */
   1.160 ++        {
   1.161 ++          np->ip_trailing_zeros = exp - str_len;
   1.162 ++          np->ip_size = str_len;
   1.163 ++        }
   1.164 ++      else
   1.165 ++        np->ip_size = exp;
   1.166 + 
   1.167 +       if (spec.group)
   1.168 +         /* thousands separator in integral part */
   1.169 +         np->thousands_sep = MPFR_THOUSANDS_SEPARATOR;
   1.170 + 
   1.171 +-      if (nsd == 0 || (spec_g && !spec.alt))
   1.172 +-        /* compute how much non-zero digits in integral and fractional
   1.173 +-           parts */
   1.174 ++      /* fractional part */
   1.175 ++      str += np->ip_size;
   1.176 ++      str_len -= np->ip_size;
   1.177 ++      if (!keep_trailing_zeros)
   1.178 ++        /* remove trailing zeros, if any */
   1.179 +         {
   1.180 +-          size_t str_len;
   1.181 +-          str_len = strlen (str); /* note: the sign has been skipped */
   1.182 +-
   1.183 +-          if (exp > str_len)
   1.184 +-            /* mpfr_get_str doesn't give the trailing zeros when p is a
   1.185 +-               multiple of 10 (p integer, so no fractional part) */
   1.186 ++          char *ptr = str + str_len - 1; /* pointer to the last digit of
   1.187 ++                                            str */
   1.188 ++          while ((*ptr == '0') && (str_len != 0))
   1.189 +             {
   1.190 +-              np->ip_trailing_zeros = exp - str_len;
   1.191 +-              np->ip_size = str_len;
   1.192 +-              if (spec.alt)
   1.193 +-                np->point = MPFR_DECIMAL_POINT;
   1.194 +-            }
   1.195 +-          else
   1.196 +-            /* str may contain some digits which are in fractional part */
   1.197 +-            {
   1.198 +-              char *ptr;
   1.199 +-
   1.200 +-              ptr = str + str_len - 1; /* points to the end of str */
   1.201 +-              str_len -= np->ip_size;  /* number of digits in fractional
   1.202 +-                                          part */
   1.203 +-
   1.204 +-              if (!keep_trailing_zeros)
   1.205 +-                /* remove trailing zeros, if any */
   1.206 +-                {
   1.207 +-                  while ((*ptr == '0') && (str_len != 0))
   1.208 +-                    {
   1.209 +-                      --ptr;
   1.210 +-                      --str_len;
   1.211 +-                    }
   1.212 +-                }
   1.213 +-
   1.214 +-              if (str_len > INT_MAX)
   1.215 +-                /* too many digits in fractional part */
   1.216 +-                return -1;
   1.217 +-
   1.218 +-              if (str_len != 0)
   1.219 +-                /* some digits in fractional part */
   1.220 +-                {
   1.221 +-                  np->point = MPFR_DECIMAL_POINT;
   1.222 +-                  np->fp_ptr = str + np->ip_size;
   1.223 +-                  np->fp_size = str_len;
   1.224 +-                }
   1.225 ++              --ptr;
   1.226 ++              --str_len;
   1.227 +             }
   1.228 +         }
   1.229 +-      else
   1.230 +-        /* spec.prec digits in fractional part */
   1.231 +-        {
   1.232 +-          if (np->ip_size == exp - 1)
   1.233 +-            /* the absolute value of the number has been rounded up to a power
   1.234 +-               of ten.
   1.235 +-               Insert an additional zero in integral part and put the rest of
   1.236 +-               them in fractional part. */
   1.237 +-            np->ip_trailing_zeros = 1;
   1.238 + 
   1.239 +-          if (spec.prec != 0)
   1.240 +-            {
   1.241 +-              MPFR_ASSERTD (np->ip_size + np->ip_trailing_zeros == exp);
   1.242 +-              MPFR_ASSERTD (np->ip_size + spec.prec == nsd);
   1.243 ++      if (str_len > 0)
   1.244 ++        /* some nonzero digits in fractional part */
   1.245 ++        {
   1.246 ++          if (str_len > INT_MAX)
   1.247 ++            /* too many digits in fractional part */
   1.248 ++            return -1;
   1.249 ++
   1.250 ++          np->point = MPFR_DECIMAL_POINT;
   1.251 ++          np->fp_ptr = str;
   1.252 ++          np->fp_size = str_len;
   1.253 ++        }
   1.254 + 
   1.255 +-              np->point = MPFR_DECIMAL_POINT;
   1.256 +-              np->fp_ptr = str + np->ip_size;
   1.257 +-              np->fp_size = spec.prec;
   1.258 +-            }
   1.259 +-          else if (spec.alt)
   1.260 +-            np->point = MPFR_DECIMAL_POINT;
   1.261 ++      if (keep_trailing_zeros && str_len < spec.prec)
   1.262 ++        /* add missing trailing zeros */
   1.263 ++        {
   1.264 ++          np->point = MPFR_DECIMAL_POINT;
   1.265 ++          np->fp_trailing_zeros = spec.prec - np->fp_size;
   1.266 +         }
   1.267 ++
   1.268 ++      if (spec.alt)
   1.269 ++        /* add decimal point even if no digits follow it */
   1.270 ++        np->point = MPFR_DECIMAL_POINT;
   1.271 +     }
   1.272 + 
   1.273 +   return 0;
   1.274 +diff -Naur mpfr-3.1.0.orig/src/version.c mpfr-3.1.0/src/version.c
   1.275 +--- mpfr-3.1.0.orig/src/version.c	2011-10-03 08:17:09.000000000 +0000
   1.276 ++++ mpfr-3.1.0/src/version.c	2011-11-28 12:22:52.000000000 +0000
   1.277 +@@ -25,5 +25,5 @@
   1.278 + const char *
   1.279 + mpfr_get_version (void)
   1.280 + {
   1.281 +-  return "3.1.0";
   1.282 ++  return "3.1.0-p4";
   1.283 + }
   1.284 +diff -Naur mpfr-3.1.0.orig/tests/Makefile.am mpfr-3.1.0/tests/Makefile.am
   1.285 +--- mpfr-3.1.0.orig/tests/Makefile.am	2011-10-03 08:17:14.000000000 +0000
   1.286 ++++ mpfr-3.1.0/tests/Makefile.am	2011-10-03 08:17:14.000000000 +0000
   1.287 +@@ -65,8 +65,24 @@
   1.288 + TESTS = $(check_PROGRAMS)
   1.289 + TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
   1.290 + 
   1.291 +-# Option to prevent libtool from generating wrapper scripts for the tests.
   1.292 ++# The -no-install option prevents libtool from generating wrapper scripts
   1.293 ++# for the tests.
   1.294 + # This is useful to easily run the test scripts under valgrind or gdb.
   1.295 + # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
   1.296 + # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
   1.297 +-AM_LDFLAGS = -no-install
   1.298 ++#
   1.299 ++# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
   1.300 ++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
   1.301 ++# library is already installed in the corresponding lib directory: its
   1.302 ++# purpose is to make sure that the local .libs comes first in the library
   1.303 ++# search path (otherwise the tests are linked against the old MPFR library
   1.304 ++# by the LINK command -- see the generated Makefile). See:
   1.305 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
   1.306 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
   1.307 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
   1.308 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
   1.309 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
   1.310 ++# and
   1.311 ++#   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
   1.312 ++#
   1.313 ++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
   1.314 +diff -Naur mpfr-3.1.0.orig/tests/Makefile.in mpfr-3.1.0/tests/Makefile.in
   1.315 +--- mpfr-3.1.0.orig/tests/Makefile.in	2011-10-03 08:17:35.000000000 +0000
   1.316 ++++ mpfr-3.1.0/tests/Makefile.in	2011-10-03 08:17:35.000000000 +0000
   1.317 +@@ -1124,11 +1124,27 @@
   1.318 + TESTS = $(check_PROGRAMS)
   1.319 + TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
   1.320 + 
   1.321 +-# Option to prevent libtool from generating wrapper scripts for the tests.
   1.322 ++# The -no-install option prevents libtool from generating wrapper scripts
   1.323 ++# for the tests.
   1.324 + # This is useful to easily run the test scripts under valgrind or gdb.
   1.325 + # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
   1.326 + # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
   1.327 +-AM_LDFLAGS = -no-install
   1.328 ++#
   1.329 ++# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
   1.330 ++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
   1.331 ++# library is already installed in the corresponding lib directory: its
   1.332 ++# purpose is to make sure that the local .libs comes first in the library
   1.333 ++# search path (otherwise the tests are linked against the old MPFR library
   1.334 ++# by the LINK command -- see the generated Makefile). See:
   1.335 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
   1.336 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
   1.337 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
   1.338 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
   1.339 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
   1.340 ++# and
   1.341 ++#   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
   1.342 ++#
   1.343 ++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
   1.344 + all: all-am
   1.345 + 
   1.346 + .SUFFIXES:
   1.347 +diff -Naur mpfr-3.1.0.orig/tests/trandom.c mpfr-3.1.0/tests/trandom.c
   1.348 +--- mpfr-3.1.0.orig/tests/trandom.c	2011-10-03 08:17:14.000000000 +0000
   1.349 ++++ mpfr-3.1.0/tests/trandom.c	2011-11-28 12:22:52.000000000 +0000
   1.350 +@@ -114,21 +114,29 @@
   1.351 +   mpfr_t x;
   1.352 +   gmp_randstate_t s;
   1.353 + 
   1.354 ++#if __MPFR_GMP(4,2,0)
   1.355 ++# define C1 "0.895943"
   1.356 ++# define C2 "0.848824"
   1.357 ++#else
   1.358 ++# define C1 "0.479652"
   1.359 ++# define C2 "0.648529"
   1.360 ++#endif
   1.361 ++
   1.362 +   gmp_randinit_default (s);
   1.363 +   gmp_randseed_ui (s, 42);
   1.364 +   mpfr_init2 (x, 17);
   1.365 +   mpfr_urandomb (x, s);
   1.366 +-  if (mpfr_cmp_str1 (x, "0.895943") != 0)
   1.367 ++  if (mpfr_cmp_str1 (x, C1) != 0)
   1.368 +     {
   1.369 +-      printf ("Error in bug20100914, expected 0.895943, got ");
   1.370 ++      printf ("Error in bug20100914, expected " C1 ", got ");
   1.371 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   1.372 +       printf ("\n");
   1.373 +       exit (1);
   1.374 +     }
   1.375 +   mpfr_urandomb (x, s);
   1.376 +-  if (mpfr_cmp_str1 (x, "0.848824") != 0)
   1.377 ++  if (mpfr_cmp_str1 (x, C2) != 0)
   1.378 +     {
   1.379 +-      printf ("Error in bug20100914, expected 0.848824, got ");
   1.380 ++      printf ("Error in bug20100914, expected " C2 ", got ");
   1.381 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   1.382 +       printf ("\n");
   1.383 +       exit (1);
   1.384 +diff -Naur mpfr-3.1.0.orig/tests/tsprintf.c mpfr-3.1.0/tests/tsprintf.c
   1.385 +--- mpfr-3.1.0.orig/tests/tsprintf.c	2011-10-03 08:17:14.000000000 +0000
   1.386 ++++ mpfr-3.1.0/tests/tsprintf.c	2011-11-03 15:15:11.000000000 +0000
   1.387 +@@ -475,6 +475,18 @@
   1.388 +   check_sprintf ("-1.", "%- #0.1RG", x);
   1.389 + 
   1.390 +   /* precision zero */
   1.391 ++  mpfr_set_d (x, 9.5, MPFR_RNDN);
   1.392 ++  check_sprintf ("9",    "%.0RDf", x);
   1.393 ++  check_sprintf ("10",    "%.0RUf", x);
   1.394 ++
   1.395 ++  mpfr_set_d (x, 19.5, MPFR_RNDN);
   1.396 ++  check_sprintf ("19",    "%.0RDf", x);
   1.397 ++  check_sprintf ("20",    "%.0RUf", x);
   1.398 ++
   1.399 ++  mpfr_set_d (x, 99.5, MPFR_RNDN);
   1.400 ++  check_sprintf ("99",    "%.0RDf", x);
   1.401 ++  check_sprintf ("100",   "%.0RUf", x);
   1.402 ++
   1.403 +   mpfr_set_d (x, -9.5, MPFR_RNDN);
   1.404 +   check_sprintf ("-10",    "%.0RDf", x);
   1.405 +   check_sprintf ("-10",    "%.0RYf", x);
   1.406 +@@ -1078,6 +1090,23 @@
   1.407 +   mpfr_clear (x);
   1.408 + }
   1.409 + 
   1.410 ++static void
   1.411 ++bug20111102 (void)
   1.412 ++{
   1.413 ++  mpfr_t t;
   1.414 ++  char s[100];
   1.415 ++
   1.416 ++  mpfr_init2 (t, 84);
   1.417 ++  mpfr_set_str (t, "999.99999999999999999999", 10, MPFR_RNDN);
   1.418 ++  mpfr_sprintf (s, "%.20RNg", t);
   1.419 ++  if (strcmp (s, "1000") != 0)
   1.420 ++    {
   1.421 ++      printf ("Error in bug20111102, expected 1000, got %s\n", s);
   1.422 ++      exit (1);
   1.423 ++    }
   1.424 ++  mpfr_clear (t);
   1.425 ++}
   1.426 ++
   1.427 + /* In particular, the following test makes sure that the rounding
   1.428 +  * for %Ra and %Rb is not done on the MPFR number itself (as it
   1.429 +  * would overflow). Note: it has been reported on comp.std.c that
   1.430 +@@ -1161,6 +1190,7 @@
   1.431 +   locale = setlocale (LC_ALL, "C");
   1.432 + #endif
   1.433 + 
   1.434 ++  bug20111102 ();
   1.435 +   native_types ();
   1.436 +   hexadecimal ();
   1.437 +   binary ();
   1.438 +diff -Naur mpfr-3.1.0.orig/tests/turandom.c mpfr-3.1.0/tests/turandom.c
   1.439 +--- mpfr-3.1.0.orig/tests/turandom.c	2011-10-03 08:17:14.000000000 +0000
   1.440 ++++ mpfr-3.1.0/tests/turandom.c	2011-11-28 12:22:52.000000000 +0000
   1.441 +@@ -160,23 +160,29 @@
   1.442 +   mpfr_t x;
   1.443 +   gmp_randstate_t s;
   1.444 + 
   1.445 ++#if __MPFR_GMP(4,2,0)
   1.446 ++# define C1 "0.8488312"
   1.447 ++# define C2 "0.8156509"
   1.448 ++#else
   1.449 ++# define C1 "0.6485367"
   1.450 ++# define C2 "0.9362717"
   1.451 ++#endif
   1.452 ++
   1.453 +   gmp_randinit_default (s);
   1.454 +   gmp_randseed_ui (s, 42);
   1.455 +   mpfr_init2 (x, 17);
   1.456 +   mpfr_urandom (x, s, MPFR_RNDN);
   1.457 +-  /* the following values are obtained on a 32-bit computer, we should get
   1.458 +-     the same values on a 64-bit computer */
   1.459 +-  if (mpfr_cmp_str1 (x, "0.8488312") != 0)
   1.460 ++  if (mpfr_cmp_str1 (x, C1) != 0)
   1.461 +     {
   1.462 +-      printf ("Error in bug20100914, expected 0.8488312, got ");
   1.463 ++      printf ("Error in bug20100914, expected " C1 ", got ");
   1.464 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   1.465 +       printf ("\n");
   1.466 +       exit (1);
   1.467 +     }
   1.468 +   mpfr_urandom (x, s, MPFR_RNDN);
   1.469 +-  if (mpfr_cmp_str1 (x, "0.8156509") != 0)
   1.470 ++  if (mpfr_cmp_str1 (x, C2) != 0)
   1.471 +     {
   1.472 +-      printf ("Error in bug20100914, expected 0.8156509, got ");
   1.473 ++      printf ("Error in bug20100914, expected " C2 ", got ");
   1.474 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   1.475 +       printf ("\n");
   1.476 +       exit (1);