]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bignum FIXME in emacs-module.c
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 31 Aug 2018 01:10:18 +0000 (18:10 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 31 Aug 2018 01:10:56 +0000 (18:10 -0700)
* src/emacs-module.c: Do not include bignum.h; no longer needed.
(module_extract_integer): Use bignum_to_intmax to avoid
incorrectly signaling overflow on platforms where intmax_t
is wider than long int.

src/emacs-module.c

index cf92b0fdb51c2b880df3845f7f510d8a5751776b..2ba5540d9a13ad04c0fd4d696809daa1e7992971 100644 (file)
@@ -27,7 +27,6 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 
 #include "lisp.h"
-#include "bignum.h"
 #include "dynlib.h"
 #include "coding.h"
 #include "keyboard.h"
@@ -522,11 +521,10 @@ module_extract_integer (emacs_env *env, emacs_value n)
   CHECK_INTEGER (l);
   if (BIGNUMP (l))
     {
-      /* FIXME: This can incorrectly signal overflow on platforms
-        where long is narrower than intmax_t.  */
-      if (!mpz_fits_slong_p (XBIGNUM (l)->value))
+      intmax_t i = bignum_to_intmax (l);
+      if (i == 0)
        xsignal1 (Qoverflow_error, l);
-      return mpz_get_si (XBIGNUM (l)->value);
+      return i;
     }
   return XFIXNUM (l);
 }