]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge remote-tracking branch 'origin/master' into feature/bignum
authorTom Tromey <tom@tromey.com>
Thu, 9 Aug 2018 23:56:53 +0000 (17:56 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 9 Aug 2018 23:56:53 +0000 (17:56 -0600)
46 files changed:
1  2 
configure.ac
doc/lispref/numbers.texi
etc/NEWS
src/Makefile.in
src/alloc.c
src/callint.c
src/casetab.c
src/character.c
src/chartab.c
src/dbusbind.c
src/dired.c
src/dispextern.h
src/editfns.c
src/emacs.c
src/eval.c
src/fileio.c
src/floatfns.c
src/fns.c
src/frame.c
src/gnutls.c
src/image.c
src/intervals.c
src/json.c
src/keyboard.c
src/lisp.h
src/lread.c
src/menu.c
src/nsfns.m
src/nsmenu.m
src/nsselect.m
src/print.c
src/process.c
src/search.c
src/syntax.c
src/terminal.c
src/textprop.c
src/w32cygwinx.c
src/w32term.c
src/xdisp.c
src/xfaces.c
src/xfns.c
src/xmenu.c
src/xselect.c
src/xwidget.c
test/src/editfns-tests.el
test/src/fns-tests.el

diff --cc configure.ac
Simple merge
index d9fb43258eaafe28d1aba26d23e1aab06e3c6f22,a3317c9a260408d62e1e9686bb5f8522dc1336fe..89205f9df39c18247d9a83955193eef47fe58a3d
@@@ -358,14 -366,18 +370,18 @@@ if so, @code{nil} otherwise.  The argum
  @cindex comparing numbers
  
    To test numbers for numerical equality, you should normally use
- @code{=}, not @code{eq}.  There can be many distinct floating-point
- and large integer objects with the same numeric value.  If you use
- @code{eq} to compare them, then you test whether two values are the
- same @emph{object}.  By contrast, @code{=} compares only the numeric
- values of the objects.
+ @code{=} instead of non-numeric comparison predicates like @code{eq},
 -@code{eql} and @code{equal}.  Distinct floating-point objects can be
 -numerically equal.  If you use @code{eq} to compare them, you test
 -whether they are the same @emph{object}; if you use @code{eql} or
 -@code{equal}, you test whether their values are
++@code{eql} and @code{equal}.  Distinct floating-point and large
++integer objects can be numerically equal.  If you use @code{eq} to
++compare them, you test whether they are the same @emph{object}; if you
++use @code{eql} or @code{equal}, you test whether their values are
+ @emph{indistinguishable}.  In contrast, @code{=} uses numeric
+ comparison, and sometimes returns @code{t} when a non-numeric
+ comparison would return @code{nil} and vice versa.  @xref{Float
+ Basics}.
  
 -  In Emacs Lisp, each integer is a unique Lisp object.
 -Therefore, @code{eq} is equivalent to @code{=} where integers are
 +  In Emacs Lisp, each small integer is a unique Lisp object.
 +Therefore, @code{eq} is equivalent to @code{=} where small integers are
  concerned.  It is sometimes convenient to use @code{eq} for comparing
  an unknown value with an integer, because @code{eq} does not report an
  error if the unknown value is not a number---it accepts arguments of
diff --cc etc/NEWS
index 2be4fe983a36671fbf035fc562f7e93672bbbad9,21887f5bfd39882bfd13e99f444da76517b24b06..081325a478ad9828a1d52d69afcbaf533cb66e51
+++ b/etc/NEWS
@@@ -645,8 -752,17 +755,8 @@@ as new-style, bind the new variable 'fo
  
  ** When formatting a floating-point number as an octal or hexadecimal
  integer, Emacs now signals an error if the number is too large for the
- implementation to format (Bug#30408).
+ implementation to format.
  
 -+++
 -** The Lisp reader now signals an overflow for plain decimal integers
 -that do not end in '.' and are outside Emacs range.  Formerly the Lisp
 -reader silently converted them to floating-point numbers, and signaled
 -overflow only for integers with a radix that are outside machine range.
 -To get the old behavior, set the new, experimental variable
 -read-integer-overflow-as-float to t and please email
 -30408@debbugs.gnu.org if you need that.
 -
  ---
  ** Some functions and variables obsolete since Emacs 22 have been removed:
  archive-mouse-extract, assoc-ignore-case, assoc-ignore-representation,
@@@ -700,13 -817,9 +811,14 @@@ manual for more details
  +++
  ** New function 'proper-list-p'.
  Given a proper list as argument, this predicate returns its length;
- otherwise, it returns nil.
+ otherwise, it returns nil.  'format-proper-list-p' is now an obsolete
+ alias for the new function.
  
 ++++
 +** Emacs Lisp integers can be of arbitrary precision.  The new
 +predicates 'bignump' and 'fixnump' can be used to distinguish between
 +the types of integers.
 +
  ** define-minor-mode automatically documents the meaning of ARG
  
  +++
diff --cc src/Makefile.in
Simple merge
diff --cc src/alloc.c
Simple merge
diff --cc src/callint.c
index c8b75859e608c58172cfd81a8f61692a15e422e8,807e1cca9ccd232f076ef6294219c6eaa78a4911..81efb267bdfb76842076e806afafa19b75e4ee16
@@@ -200,8 -200,8 +200,8 @@@ fix_command (Lisp_Object input, Lisp_Ob
                  carelt = XCAR (elt);
                  /* If it is (if X Y), look at Y.  */
                  if (EQ (carelt, Qif)
-                     && EQ (Fnthcdr (make_fixnum (3), elt), Qnil))
 -                    && NILP (Fnthcdr (make_number (3), elt)))
 -                  elt = Fnth (make_number (2), elt);
++                    && NILP (Fnthcdr (make_fixnum (3), elt)))
 +                  elt = Fnth (make_fixnum (2), elt);
                  /* If it is (when ... Y), look at Y.  */
                  else if (EQ (carelt, Qwhen))
                    {
diff --cc src/casetab.c
Simple merge
diff --cc src/character.c
Simple merge
diff --cc src/chartab.c
index 0383a84a04d90e54c98036e0954ac29a979d5ce3,89983503ac6171206163c0decfdde195d3e4409d..3d38b3ce12eec6066edbc99d9f451bb87a0dfb26
@@@ -605,10 -605,10 +605,10 @@@ a cons of character codes (for characte
    Lisp_Object val;
    CHECK_CHAR_TABLE (char_table);
  
-   if (EQ (range, Qnil))
+   if (NILP (range))
      val = XCHAR_TABLE (char_table)->defalt;
    else if (CHARACTERP (range))
 -    val = CHAR_TABLE_REF (char_table, XFASTINT (range));
 +    val = CHAR_TABLE_REF (char_table, XFIXNAT (range));
    else if (CONSP (range))
      {
        int from, to;
@@@ -642,10 -642,10 +642,10 @@@ or a character code.  Return VALUE.  */
        for (i = 0; i < chartab_size[0]; i++)
        set_char_table_contents (char_table, i, value);
      }
-   else if (EQ (range, Qnil))
+   else if (NILP (range))
      set_char_table_defalt (char_table, value);
    else if (CHARACTERP (range))
 -    char_table_set (char_table, XINT (range), value);
 +    char_table_set (char_table, XFIXNUM (range), value);
    else if (CONSP (range))
      {
        CHECK_CHARACTER_CAR (range);
diff --cc src/dbusbind.c
index 4cf5604d7459bee784cb68c0e8dbfc2bc9e9755e,96429810e22a4f76af3ecdc65cd97e1cf387a5d2..fe92d3997bdae3a0712f6de381a1184bf6dc4df6
@@@ -200,9 -200,9 +200,9 @@@ xd_symbol_to_dbus_type (Lisp_Object obj
     `dbus-send-signal', into corresponding C values appended as
     arguments to a D-Bus message.  */
  #define XD_OBJECT_TO_DBUS_TYPE(object)                                        \
-   ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN         \
+   ((EQ (object, Qt) || NILP (object)) ? DBUS_TYPE_BOOLEAN             \
 -   : (NATNUMP (object)) ? DBUS_TYPE_UINT32                            \
 -   : (INTEGERP (object)) ? DBUS_TYPE_INT32                            \
 +   : (FIXNATP (object)) ? DBUS_TYPE_UINT32                            \
 +   : (FIXNUMP (object)) ? DBUS_TYPE_INT32                             \
     : (FLOATP (object)) ? DBUS_TYPE_DOUBLE                             \
     : (STRINGP (object)) ? DBUS_TYPE_STRING                            \
     : (XD_DBUS_TYPE_P (object)) ? xd_symbol_to_dbus_type (object)      \
diff --cc src/dired.c
Simple merge
Simple merge
diff --cc src/editfns.c
Simple merge
diff --cc src/emacs.c
Simple merge
diff --cc src/eval.c
Simple merge
diff --cc src/fileio.c
index 14089dcf49a334fab2044ee5b2d62c48aa35f1ce,2dcfb73b0d5888fa93b70ca8e16566e9b03c36eb..04e763f83b5d9bc02706c18716e47186270575ff
@@@ -5712,9 -5735,9 +5735,9 @@@ A non-nil CURRENT-ONLY argument means s
                    > (BUF_Z (b) - BUF_BEG (b)) * 13)
                /* A short file is likely to change a large fraction;
                   spare the user annoying messages.  */
 -              && XFASTINT (BVAR (b, save_length)) > 5000
 +              && XFIXNAT (BVAR (b, save_length)) > 5000
                /* These messages are frequent and annoying for `*mail*'.  */
-               && !EQ (BVAR (b, filename), Qnil)
+               && !NILP (BVAR (b, filename))
                && NILP (no_message))
              {
                /* It has shrunk too much; turn off auto-saving here.  */
diff --cc src/floatfns.c
Simple merge
diff --cc src/fns.c
index 92a853e1755d7667263198ee14afcb7f92815c43,5247140ead46db8cef2e9d3534e1a93955cbf2cf..38b2d281f0717f9a62b3f96e27f875bcd78be97f
+++ b/src/fns.c
@@@ -2170,12 -2215,14 +2215,16 @@@ The PLIST is modified by side effects
  }
  \f
  DEFUN ("eql", Feql, Seql, 2, 2, 0,
-        doc: /* Return t if the two args are the same Lisp object.
- Floating-point numbers of equal value are `eql', but they may not be `eq'.  */)
+        doc: /* Return t if the two args are `eq' or are indistinguishable numbers.
+ Floating-point values with the same sign, exponent and fraction are `eql'.
+ This differs from numeric comparison: (eql 0.0 -0.0) returns nil and
+ \(eql 0.0e+NaN 0.0e+NaN) returns t, whereas `=' does the opposite.  */)
    (Lisp_Object obj1, Lisp_Object obj2)
  {
-   if (FLOATP (obj1) || BIGNUMP (obj1))
+   if (FLOATP (obj1))
+     return FLOATP (obj2) && same_float (obj1, obj2) ? Qt : Qnil;
++  else if (BIGNUMP (obj1))
 +    return equal_no_quit (obj1, obj2) ? Qt : Qnil;
    else
      return EQ (obj1, obj2) ? Qt : Qnil;
  }
@@@ -3705,25 -3744,18 +3748,24 @@@ HASH_NEXT (struct Lisp_Hash_Table *h, p
  static ptrdiff_t
  HASH_INDEX (struct Lisp_Hash_Table *h, ptrdiff_t idx)
  {
 -  return XINT (AREF (h->index, idx));
 +  return XFIXNUM (AREF (h->index, idx));
  }
  
- /* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
-    HASH2 in hash table H using `eql'.  Value is true if KEY1 and
-    KEY2 are the same.  */
+ /* Compare KEY1 and KEY2 in hash table HT using `eql'.  Value is true
+    if KEY1 and KEY2 are the same.  KEY1 and KEY2 must not be eq.  */
  
  static bool
  cmpfn_eql (struct hash_table_test *ht,
           Lisp_Object key1,
           Lisp_Object key2)
  {
 -  return FLOATP (key1) && FLOATP (key2) && same_float (key1, key2);
 +  if (FLOATP (key1)
 +      && FLOATP (key2)
-       && XFLOAT_DATA (key1) == XFLOAT_DATA (key2))
++      && same_float (key1, key2))
 +    return true;
 +  return (BIGNUMP (key1)
 +        && BIGNUMP (key2)
 +        && mpz_cmp (XBIGNUM (key1)->value, XBIGNUM (key2)->value) == 0);
  }
  
  
diff --cc src/frame.c
Simple merge
diff --cc src/gnutls.c
index 111dc612483295de7c63b5c91cd3f73da0b46f96,4e98f16f484afa8dd578c1556c179144d2483ef9..2d455ea1ba12b5923f82b02af5d201b4b1cf552f
@@@ -2071,9 -2071,16 +2071,16 @@@ gnutls_symmetric (bool encrypting, Lisp
      cipher = intern (SSDATA (cipher));
  
    if (SYMBOLP (cipher))
-     info = XCDR (Fassq (cipher, Fgnutls_ciphers ()));
+     {
+       info = Fassq (cipher, Fgnutls_ciphers ());
+       if (!CONSP (info))
+       xsignal2 (Qerror,
+                 build_string ("GnuTLS cipher is invalid or not found"),
+                 cipher);
+       info = XCDR (info);
+     }
 -  else if (TYPE_RANGED_INTEGERP (gnutls_cipher_algorithm_t, cipher))
 -    gca = XINT (cipher);
 +  else if (TYPE_RANGED_FIXNUMP (gnutls_cipher_algorithm_t, cipher))
 +    gca = XFIXNUM (cipher);
    else
      info = cipher;
  
@@@ -2342,9 -2350,16 +2350,16 @@@ itself. */
      hash_method = intern (SSDATA (hash_method));
  
    if (SYMBOLP (hash_method))
-     info = XCDR (Fassq (hash_method, Fgnutls_macs ()));
+     {
+       info = Fassq (hash_method, Fgnutls_macs ());
+       if (!CONSP (info))
+       xsignal2 (Qerror,
+                 build_string ("GnuTLS MAC-method is invalid or not found"),
+                 hash_method);
+       info = XCDR (info);
+     }
 -  else if (TYPE_RANGED_INTEGERP (gnutls_mac_algorithm_t, hash_method))
 -    gma = XINT (hash_method);
 +  else if (TYPE_RANGED_FIXNUMP (gnutls_mac_algorithm_t, hash_method))
 +    gma = XFIXNUM (hash_method);
    else
      info = hash_method;
  
@@@ -2423,9 -2440,16 +2440,16 @@@ the number itself. */
      digest_method = intern (SSDATA (digest_method));
  
    if (SYMBOLP (digest_method))
-     info = XCDR (Fassq (digest_method, Fgnutls_digests ()));
+     {
+       info = Fassq (digest_method, Fgnutls_digests ());
+       if (!CONSP (info))
+       xsignal2 (Qerror,
+                 build_string ("GnuTLS digest-method is invalid or not found"),
+                 digest_method);
+       info = XCDR (info);
+     }
 -  else if (TYPE_RANGED_INTEGERP (gnutls_digest_algorithm_t, digest_method))
 -    gda = XINT (digest_method);
 +  else if (TYPE_RANGED_FIXNUMP (gnutls_digest_algorithm_t, digest_method))
 +    gda = XFIXNUM (digest_method);
    else
      info = digest_method;
  
diff --cc src/image.c
Simple merge
diff --cc src/intervals.c
Simple merge
diff --cc src/json.c
Simple merge
diff --cc src/keyboard.c
index 4c8807d680125f2c319839948b55d956900fe458,7ab9a6069ad73639cbdfe8dc75535bfdf1f34018..e596b2880b000fb999bb4b59e6208b7c7b7d7068
@@@ -3256,15 -3260,15 +3260,15 @@@ record_char (Lisp_Object c
    /* Write c to the dribble file.  If c is a lispy event, write
       the event's symbol to the dribble file, in <brackets>.  Bleaugh.
       If you, dear reader, have a better idea, you've got the source.  :-) */
-   if (dribble)
+   if (dribble && NILP (Vexecuting_kbd_macro))
      {
        block_input ();
 -      if (INTEGERP (c))
 +      if (FIXNUMP (c))
        {
 -        if (XUINT (c) < 0x100)
 -          putc_unlocked (XUINT (c), dribble);
 +        if (XUFIXNUM (c) < 0x100)
 +          putc_unlocked (XUFIXNUM (c), dribble);
          else
 -          fprintf (dribble, " 0x%"pI"x", XUINT (c));
 +          fprintf (dribble, " 0x%"pI"x", XUFIXNUM (c));
        }
        else
        {
diff --cc src/lisp.h
Simple merge
diff --cc src/lread.c
Simple merge
diff --cc src/menu.c
Simple merge
diff --cc src/nsfns.m
Simple merge
diff --cc src/nsmenu.m
Simple merge
diff --cc src/nsselect.m
Simple merge
diff --cc src/print.c
Simple merge
diff --cc src/process.c
Simple merge
diff --cc src/search.c
index 5385c890f9833e3df0b0d6460ea8c57d2f45eee0,4e5a25301148aa160d5c27f1f57eb7b22c580474..f5c771963eac20a8bd81ebc70d0680e32aa1ea85
@@@ -3054,16 -3057,13 +3057,13 @@@ If optional arg RESEAT is non-nil, mak
            if (MARKERP (marker) && XMARKER (marker)->buffer == 0)
              XSETFASTINT (marker, 0);
  
 -          CHECK_NUMBER_COERCE_MARKER (marker);
 -          if (PTRDIFF_MIN <= XINT (from) && XINT (from) <= PTRDIFF_MAX
 -              && PTRDIFF_MIN <= XINT (marker)
 -              && XINT (marker) <= PTRDIFF_MAX)
 +          CHECK_FIXNUM_COERCE_MARKER (marker);
-           if ((XFIXNUM (from) < 0
-                ? TYPE_MINIMUM (regoff_t) <= XFIXNUM (from)
-                : XFIXNUM (from) <= TYPE_MAXIMUM (regoff_t))
-               && (XFIXNUM (marker) < 0
-                   ? TYPE_MINIMUM (regoff_t) <= XFIXNUM (marker)
-                   : XFIXNUM (marker) <= TYPE_MAXIMUM (regoff_t)))
++          if (PTRDIFF_MIN <= XFIXNUM (from) && XFIXNUM (from) <= PTRDIFF_MAX
++              && PTRDIFF_MIN <= XFIXNUM (marker)
++              && XFIXNUM (marker) <= PTRDIFF_MAX)
              {
 -              search_regs.start[i] = XINT (from);
 -              search_regs.end[i] = XINT (marker);
 +              search_regs.start[i] = XFIXNUM (from);
 +              search_regs.end[i] = XFIXNUM (marker);
              }
            else
              {
diff --cc src/syntax.c
Simple merge
diff --cc src/terminal.c
Simple merge
diff --cc src/textprop.c
index 4bd4892b730b91f21ce3d180a308dece3b203ee7,ea1ae3b1a547ceea2994ccec08aa45b4114d75c9..8e8baf43d9f8ced1a91ce6180d930cf5c4ba4fe0
@@@ -2269,10 -2285,10 +2285,10 @@@ verify_interval_modification (struct bu
        if (!inhibit_modification_hooks)
        {
          hooks = Fnreverse (hooks);
-         while (! EQ (hooks, Qnil))
+         while (! NILP (hooks))
            {
 -            call_mod_hooks (Fcar (hooks), make_number (start),
 -                            make_number (end));
 +            call_mod_hooks (Fcar (hooks), make_fixnum (start),
 +                            make_fixnum (end));
              hooks = Fcdr (hooks);
            }
        }
Simple merge
diff --cc src/w32term.c
Simple merge
diff --cc src/xdisp.c
index e30f800b7eee8ceb19b16e4caac3be3b2bf361f7,956535c2dba1a12b9be3874a7e39509f6b76c603..76fde99f3233750a3156ec9c123e9bb7efc7762f
@@@ -23610,8 -23622,17 +23622,17 @@@ display_mode_element (struct it *it, in
                        = Fdelq (aelt, mode_line_proptrans_alist);
  
                    elt = Fcopy_sequence (elt);
-                   Fset_text_properties (make_fixnum (0), Flength (elt),
-                                         props, elt);
+                   /* PROPS might cause set-text-properties to signal
+                      an error, so we call it via internal_condition_case_n,
+                      to avoid an infloop in redisplay due to the error.  */
+                   internal_condition_case_n (safe_set_text_properties,
+                                              4,
+                                              ((Lisp_Object [])
 -                                             {make_number (0),
++                                             {make_fixnum (0),
+                                                  Flength (elt),
+                                                  props,
+                                                  elt}),
+                                              Qt, safe_eval_handler);
                    /* Add this item to mode_line_proptrans_alist.  */
                    mode_line_proptrans_alist
                      = Fcons (Fcons (elt, props),
diff --cc src/xfaces.c
Simple merge
diff --cc src/xfns.c
Simple merge
diff --cc src/xmenu.c
Simple merge
diff --cc src/xselect.c
Simple merge
diff --cc src/xwidget.c
Simple merge
index 501e0d87818398dcfb47c6ed1912873e575c4c13,2951270dbf7f270e281629fc1f8f02606b8a75a0..8dee4bdc0fd23333c93d37907cd21beced6eaaba
    (should-error (format "%x" 18446744073709551616.0)
                  :type 'overflow-error))
  (ert-deftest read-large-integer ()
 -  (should-error (read (format "%d0" most-negative-fixnum))
 -                :type 'overflow-error)
 -  (should-error (read (format "%+d" (* -8.0 most-negative-fixnum)))
 -                :type 'overflow-error)
 -  (should-error (read (substring (format "%d" most-negative-fixnum) 1))
 -                :type 'overflow-error)
 +  (should (eq (type-of (read (format "%d0" most-negative-fixnum))) 'integer))
 +  (should (eq (type-of (read (format "%+d" (* -8.0 most-negative-fixnum))))
 +              'integer))
 +  (should (eq (type-of (read (substring (format "%d" most-negative-fixnum) 1)))
 +              'integer))
 +  (should (eq (type-of (read (format "#x%x" most-negative-fixnum)))
 +              'integer))
 +  (should (eq (type-of (read (format "#o%o" most-negative-fixnum)))
 +              'integer))
 +  (should (eq (type-of (read (format "#32rG%x" most-positive-fixnum)))
-               'integer)))
++              'integer))
+   (let ((binary-as-unsigned nil))
+     (dolist (fmt '("%d" "%s" "#o%o" "#x%x"))
+       (dolist (val (list most-negative-fixnum (1+ most-negative-fixnum)
+                          -1 0 1
+                          (1- most-positive-fixnum) most-positive-fixnum))
 -        (should (eq val (read (format fmt val)))))))
 -  (should-error (read (format "#32rG%x" most-positive-fixnum))
 -                :type 'overflow-error))
++        (should (eq val (read (format fmt val))))))))
  
  (ert-deftest format-%o-invalid-float ()
    (should-error (format "%o" -1e-37)
Simple merge