1. 21 Aug, 2018 7 commits
    • Paul Eggert's avatar
      Audit use of lsh and fix glitches · f18af6cd
      Paul Eggert authored
      I audited use of lsh in the Lisp source code, and fixed the
      glitches that I found.  While I was at it, I replaced uses of lsh
      with ash when either will do.  Replacement is OK when either
      argument is known to be nonnegative, or when only the low-order
      bits of the result matter, and is a (minor) win since ash is a bit
      more solid than lsh nowadays, and is a bit faster.
      * lisp/calc/calc-ext.el (math-check-fixnum):
      Prefer most-positive-fixnum to (lsh -1 -1).
      * lisp/vc/vc-hg.el (vc-hg-state-fast): When testing fixnum width,
      prefer (zerop (ash most-positive-fixnum -32)) to (zerop (lsh -1
      32)) (Bug#32485#11).
      * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode):
      Tighten sanity-check for bytecode overflow, by checking that the
      result of (ash pc -8) is nonnegative.  Formerly this check was not
      needed since lsh was used and the number overflowed differently.
      * lisp/net/dns.el (dns-write): Fix some obvious sign typos in
      shift counts.  Evidently this part of the code has never been
      exercised.
      * lisp/progmodes/hideif.el (hif-shiftleft, hif-shiftright):
      * lisp/term/common-win.el (x-setup-function-keys):
      Simplify.
      * admin/unidata/unidata-gen.el, admin/unidata/uvs.el:
      * doc/lispref/keymaps.texi, doc/lispref/syntax.texi:
      * doc/misc/calc.texi, doc/misc/cl.texi, etc/NEWS.19:
      * lisp/arc-mode.el, lisp/calc/calc-bin.el, lisp/calc/calc-comb.el:
      * lisp/calc/calc-ext.el, lisp/calc/calc-math.el:
      * lisp/cedet/semantic/wisent/comp.el, lisp/composite.el:
      * lisp/disp-table.el, lisp/dos-fns.el, lisp/edmacro.el:
      * lisp/emacs-lisp/bindat.el, lisp/emacs-lisp/byte-opt.el:
      * lisp/emacs-lisp/bytecomp.el, lisp/emacs-lisp/cl-extra.el:
      * lisp/erc/erc-dcc.el, lisp/facemenu.el, lisp/gnus/message.el:
      * lisp/gnus/nndoc.el, lisp/gnus/nnmaildir.el, lisp/image.el:
      * lisp/international/ccl.el, lisp/international/fontset.el:
      * lisp/international/mule-cmds.el, lisp/international/mule.el:
      * lisp/json.el, lisp/mail/binhex.el, lisp/mail/rmail.el:
      * lisp/mail/uudecode.el, lisp/md4.el, lisp/net/dns.el:
      * lisp/net/ntlm.el, lisp/net/sasl.el, lisp/net/socks.el:
      * lisp/net/tramp.el, lisp/obsolete/levents.el:
      * lisp/obsolete/pgg-parse.el, lisp/org/org.el:
      * lisp/org/ox-publish.el, lisp/progmodes/cc-defs.el:
      * lisp/progmodes/ebnf2ps.el, lisp/progmodes/hideif.el:
      * lisp/ps-bdf.el, lisp/ps-print.el, lisp/simple.el:
      * lisp/tar-mode.el, lisp/term/common-win.el:
      * lisp/term/tty-colors.el, lisp/term/xterm.el, lisp/vc/vc-git.el:
      * lisp/vc/vc-hg.el, lisp/x-dnd.el, test/src/data-tests.el:
      Prefer ash to lsh when either will do.
      f18af6cd
    • Paul Eggert's avatar
      Fix bignum bugs with nth, elt, = · 81e7eef8
      Paul Eggert authored
      * src/bytecode.c (exec_byte_code): Support bignums
      when implementing nth, elt, and =.
      * src/lisp.h (SMALL_LIST_LEN_MAX): New constant.
      * src/fns.c (Fnthcdr): Use it.
      (Felt): Do not reject bignum indexes.
      81e7eef8
    • Glenn Morris's avatar
      Restore compatibility with Texinfo < 6 · ad31afc3
      Glenn Morris authored
      * doc/lispref/numbers.texi (Integer Basics, Bitwise Operations):
      Don't use Texinfo 6.0's "@sup" command.
      ad31afc3
    • Eli Zaretskii's avatar
    • Eli Zaretskii's avatar
      Improve documentation of 'integer-width' · 43b1bf35
      Eli Zaretskii authored
      * etc/NEWS: Minor rewording of the recent addition.
      
      * doc/lispref/numbers.texi (Bitwise Operations): Use @dots{}
      for ellipsis.  Improve indexing.
      43b1bf35
    • Paul Eggert's avatar
      Avoid libgmp aborts by imposing limits · d6a497dd
      Paul Eggert authored
      libgmp calls ‘abort’ when given numbers too big for its
      internal data structures.  The numeric limit is large and
      platform-dependent; with 64-bit GMP 6.1.2 it is around
      2**2**37.  Work around the problem by refusing to call libgmp
      functions with arguments that would cause an abort.  With luck
      libgmp will have a better way to do this in the future.
      Also, introduce a variable integer-width that lets the user
      control how large bignums can be.  This currently defaults
      to 2**16, i.e., it allows bignums up to 2**2**16.  This
      should be enough for ordinary computation, and should
      help Emacs to avoid thrashing or hanging.
      Problem noted by Pip Cet (Bug#32463#71).
      * doc/lispref/numbers.texi, etc/NEWS:
      Document recent bignum changes, including this one.
      Improve documentation for bitwise operations, in the light
      of bignums.
      * src/alloc.c (make_number): Enforce integer-width.
      (integer_overflow): New function.
      (xrealloc_for_gmp, xfree_for_gmp):
      Move here from emacs.c, as it's memory allocation.
      (init_alloc): Initialize GMP here, rather than in emacs.c.
      (integer_width): New var.
      * src/data.c (GMP_NLIMBS_MAX, NLIMBS_LIMIT): New constants.
      (emacs_mpz_size, emacs_mpz_mul)
      (emacs_mpz_mul_2exp, emacs_mpz_pow_ui): New functions.
      (arith_driver, Fash, expt_integer): Use them.
      (expt_integer): New function, containing integer code
      that was out of place in floatfns.c.
      (check_bignum_size, xmalloc_for_gmp): Remove.
      * src/emacs.c (main): Do not initialize GMP here.
      * src/floatfns.c (Fexpt): Use expt_integer, which
      now contains integer code moved from here.
      * src/lisp.h (GMP_NUMB_BITS): Define if gmp.h doesn’t.
      d6a497dd
    • Paul Eggert's avatar
      Fix glitches introduced by nthcdr changes · 77fc2725
      Paul Eggert authored
      * src/fns.c (Fnthcdr): Fix recently-introduced bug when
      nthcdr is supposed to yield a non-nil non-cons.
      Reported by Glenn Morris and by Pip Cet here:
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00699.html
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00708.html
      Speed up nthcdr for small N, as suggested by Pip Cet here:
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00707.html
      * test/src/fns-tests.el (test-nthcdr-simple): New test.
      77fc2725
  2. 20 Aug, 2018 3 commits
    • Paul Eggert's avatar
      Speed up (nthcdr N L) when L is circular · eb83344f
      Paul Eggert authored
      Also, fix bug when N is a positive bignum, a problem reported
      by Eli Zaretskii and Pip Cet in:
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00690.html
      * src/fns.c (Fnthcdr): If a cycle is found, reduce the count
      modulo the cycle length before continuing.  This reduces the
      worst-case cost of (nthcdr N L) from N to min(N, C) where C is
      the number of distinct cdrs of L.  Reducing modulo the cycle
      length also allows us to do arithmetic with machine words
      instead of with GMP.
      * test/src/fns-tests.el (test-nthcdr-circular): New test.
      eb83344f
    • Andy Moreton's avatar
      Define get_proc_addr in Cygwin-w32 build · 36de7bd7
      Andy Moreton authored
      * src/w32common.h (get_proc_addr, DEF_DLL_FN, LOAD_DLL_FN): Move
      definitions here from src/w32.h.
      * src/decompress.c [WINDOWSNT]:
      * src/gnutls.c [WINDOWSNT]:
      * src/image.c [WINDOWSNT]:
      * src/json.c [WINDOWSNT]:
      * src/lcms.c [WINDOWSNT]:
      * src/w32font.c [WINDOWSNT]:
      * src/w32uniscribe.c:
      * src/xml.c [WINDOWSNT]: Include w32common.h.
      36de7bd7
    • Paul Eggert's avatar
      nthcdr now works with bignums · 21397837
      Paul Eggert authored
      Problem reported by Karl Fogel in:
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00671.html
      * src/fns.c (Fnthcdr): Support bignum counts.
      21397837
  3. 19 Aug, 2018 9 commits
    • Paul Eggert's avatar
      Fix expt signedness bug --without-wide-int · ecd7a940
      Paul Eggert authored
      Problem reported by Federico in:
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00619.html
      * src/floatfns.c (Fexpt): Use TYPE_RANGED_FIXNUMP, not
      RANGED_FIXNUMP, to fix bug with unsigned comparison on
      platforms built --without-wide-int.
      ecd7a940
    • Stefan Monnier's avatar
      5c3dba24
    • Paul Eggert's avatar
      Add bignum support to expt · 47b7a5bd
      Paul Eggert authored
      Problem and initial solution reported by Andy Moreton in:
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00503.html
      * doc/lispref/numbers.texi (Math Functions): expt integer
      overflow no longer causes truncation; it now signals an error
      since bignum overflow is a big deal.
      * src/floatfns.c (Fexpt): Support bignum arguments.
      * test/src/floatfns-tests.el (bignum-expt): New test.
      47b7a5bd
    • Paul Eggert's avatar
      Fix bug with ‘mod’ and float+bignum · 06b5bcd6
      Paul Eggert authored
      Problem reported by Andy Moreton in:
      https://lists.gnu.org/r/emacs-devel/2018-08/msg00442.html
      * src/floatfns.c (fmod_float): Work even if an arg is a bignum.
      * test/src/floatfns-tests.el (bignum-mod): New test.
      06b5bcd6
    • Paul Eggert's avatar
      Update from Gnulib · 35185923
      Paul Eggert authored
      This incorporates:
      2018-08-18 Avoid -Wcast-function-type warnings from casts
      * build-aux/config.sub, lib/gettimeofday.c: Copy from Gnulib.
      35185923
    • Paul Eggert's avatar
      Tweak integer division · 7ea369e5
      Paul Eggert authored
      * src/data.c (arith_driver): Reorder to remove unnecessary
      FIXNUMP.  Tighten test for whether to convert the divisor from
      fixnum to mpz_t.  Simplify.
      7ea369e5
    • Paul Eggert's avatar
      Simplify float_arith_driver · a1b79567
      Paul Eggert authored
      * src/data.c (float_arith_driver): Simplify, as we needn’t
      worry about that 30-year-old compiler bug any more.
      a1b79567
    • Paul Eggert's avatar
      Minor fixups for intmax_t→mpz_t conversion · b1840206
      Paul Eggert authored
      * src/alloc.c (mpz_set_intmax_slow): Tighten assertion.
      Work even in the unlikely case where libgmp uses nails.
      * src/data.c (FIXNUMS_FIT_IN_LONG): New constant.
      (arith_driver): Use it to tighten compile-time checks.
      * src/lisp.h (mpz_set_intmax): Do not assume that converting
      an out-of-range value to ‘long’ is harmless, as it might raise
      a signal.  Use simpler expression; compiler can optimize.
      b1840206
    • Paul Eggert's avatar
      Improve --with-wide-int mpz_t→fixnum conversion · 6eade1ef
      Paul Eggert authored
      These tuneups and minor simplifications should affect only
      platforms with EMACS_INT wider than ‘long’.
      * src/alloc.c (make_number): If the number fits in long but
      not in fixnum, do not attempt to convert to fixnum again.
      Tighten the compile-time check for whether the second attempt
      is worth trying, from sizeof (long) < sizeof (EMACS_INT) to
      LONG_WIDTH < FIXNUM_BITS.  Do not bother computing the sign of
      the value to tighten the bounds for whether to try the second
      attempt, as it’s not worth the effort.  Do not call mpz_size,
      which is unnecessary since the number of bits is already known
      and the loop can iterate over a shift count instead.  Avoid
      unnecessary casts.  Use + instead of | where either will do,
      as + is typically better for optimization.
      
      Improve mpz_t to fixnum when --with-wide-int
      * src/alloc.c (make_number): Avoid undefined behavior
      when shifting an EMACS_UINT by more than EMACS_UINT_WIDTH bits.
      Check for integer overflow when shifting.
      6eade1ef
  4. 18 Aug, 2018 4 commits
    • Paul Eggert's avatar
      Improve bignum comparison (Bug#32463#50) · 1d2df2fd
      Paul Eggert authored
      * src/data.c (isnan): Remove, as we can assume C99.
      (bignumcompare): Remove, folding its functionality
      into arithcompare.
      (arithcompare): Compare bignums directly here.
      Fix bugs when comparing NaNs to bignums.
      When comparing a bignum to a fixnum, just look at the
      bignum’s sign, as that’s all that is needed.
      Decrease scope of locals when this is easy.
      * test/src/data-tests.el (data-tests-bignum): Test bignum vs NaN.
      1d2df2fd
    • Paul Eggert's avatar
      Document that ‘random’ is limited to fixnums · 97d27303
      Paul Eggert authored
      Problem reported by Pip Cet (Bug#32463#20).
      * doc/lispref/numbers.texi (Random Numbers):
      * src/fns.c (Frandom): Adjust doc.
      97d27303
    • Paul Eggert's avatar
      Restore traditional lsh behavior on fixnums · 673b1785
      Paul Eggert authored
      * doc/lispref/numbers.texi (Bitwise Operations): Document that
      the traditional (lsh A B) behavior is for fixnums, and that it
      is an error if A and B are both negative and A is a bignum.
      See Bug#32463.
      * lisp/subr.el (lsh): New function, moved here from src/data.c.
      * src/data.c (ash_lsh_impl): Remove, moving body into Fash
      since it’s the only caller now.
      (Fash): Check for out-of-range counts.  If COUNT is zero,
      return first argument instead of going through libgmp.  Omit
      lsh code since lsh is now done in Lisp.  Add code for shifting
      fixnums right, to avoid a round trip through libgmp.
      (Flsh): Remove; moved to lisp/subr.el.
      * test/lisp/international/ccl-tests.el (shift):
      Test for traditional lsh behavior, instead of assuming
      lsh is like ash when bignums are present.
      * test/src/data-tests.el (data-tests-logand)
      (data-tests-logior, data-tests-logxor, data-tests-ash-lsh):
      New tests.
      673b1785
    • Eli Zaretskii's avatar
      Avoid compilation warning in w32fns.c · 877cd22f
      Eli Zaretskii authored
      * src/w32fns.c (Fw32_read_registry): Avoid compiler warning
      regarding possible use of 'rootkey' without initializing it
      first.  Reported by Andy Moreton <andrewjmoreton@gmail.com>.
      877cd22f
  5. 17 Aug, 2018 7 commits
    • Paul Eggert's avatar
      Improve ‘abs’ performance · 33002872
      Paul Eggert authored
      * src/floatfns.c (Fabs): Improve performance by not copying
      the argument if it would eql the result.  As a minor detail,
      don't assume fixnums are two’s complement.
      33002872
    • Eli Zaretskii's avatar
      Improve documentation of bignums · 9189afc1
      Eli Zaretskii authored
      * etc/NEWS: Enhance the announcement of bignums.
      
      * doc/lispref/numbers.texi (Integer Basics): Add a missing
      period.  Reported by Basil L. Contovounesios <contovob@tcd.ie>.
      9189afc1
    • Andy Moreton's avatar
      Pacify -Wcast-function-type warnings in GCC 8.1 · cc5325b0
      Andy Moreton authored
      * src/image.c: Move attributes into DEF_DLL_FN call.
      * src/dynlib.c (dynlib_addr): Use get_proc_addr.
      * src/w32.h: (get_proc_addr): New function.
      (LOAD_DLL_FN): Use it.
      (DEF_DLL_FN): Allow function attributes after argument
      list.  Add function pointer type used by LOAD_DLL_FN.
      * src/w32.c (open_process_token, get_token_information)
      (lookup_account_sid, get_sid_sub_authority)
      (get_sid_sub_authority_count, get_security_info)
      (get_file_security, set_file_security)
      (set_named_security_info)
      (get_security_descriptor_owner, get_security_descriptor_group)
      (get_security_descriptor_dacl, is_valid_sid, equal_sid)
      (get_length_sid, copy_sid, get_native_system_info)
      (get_system_times, create_symbolic_link)
      (is_valid_security_descriptor, convert_sd_to_sddl)
      (convert_sddl_to_sd, get_adapters_info, reg_open_key_ex_w)
      (reg_query_value_ex_w, expand_environment_strings_w)
      (init_environment, create_toolhelp32_snapshot)
      (process32_first, process32_next, open_thread_token)
      (impersonate_self, revert_to_self, get_process_memory_info)
      (get_process_working_set_size, global_memory_status)
      (global_memory_status_ex, init_winsock)
      (maybe_load_unicows_dll, globals_of_w32): Use get_proc_addr.
      * src/w32fns.c (setup_w32_kbdhook, Ffile_system_info)
      (get_dll_version, w32_reset_stack_overflow_guard)
      (w32_backtrace, globals_of_w32fns): Use get_proc_addr.
      * src/w32font.c (get_outline_metrics_w, get_text_metrics_w)
      (get_glyph_outline_w, get_char_width_32_w): Use get_proc_addr.
      * src/w32heap.c (init_heap): Use get_proc_addr.
      * src/w32menu.c (globals_of_w32menu): Use get_proc_addr.
      * src/w32proc.c (init_timers, sys_kill, w32_compare_strings):
      Use get_proc_addr.
      * src/w32uniscribe.c (syms_of_w32uniscribe): Use get_proc_addr.
      cc5325b0
    • Allen Li's avatar
      Don't include text properties when making autoloads · 58e5f10f
      Allen Li authored
      * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads):
      Ignore text properties when finding autoload defs.  Otherwise,
      autoload generation is less deterministic, as the exact format of the
      generated autoloads depends on whether the files are visited in
      Emacs.  (Bug#32395)
      58e5f10f
    • Paul Eggert's avatar
      Fix problems with logxor etc. and fixnums · 64eb9b71
      Paul Eggert authored
      These operations incorrectly treated negative fixnums as
      bignums greater than most-positive-fixnum.
      * src/alloc.c (mpz_set_intmax_slow): Avoid undefined
      behavior if signed unary negation overflows, while
      we’re in the neighborhood.
      (mpz_set_uintmax_slow): Remove.  All uses removed.
      * src/data.c (arith_driver): Treat fixnums as signed, not
      unsigned, even for logical operations.
      * src/lisp.h (mpz_set_uintmax): Remove.  All uses removed.
      * test/src/data-tests.el (data-tests-logand)
      (data-tests-logior, data-tests-logxor): New tests.
      64eb9b71
    • Paul Eggert's avatar
      Reject outlandishly-wide bignums · 3b9017b5
      Paul Eggert authored
      Do not allow bignums that are so wide that their log base 2
      might not fit into a fixnum, as this will cause problems elsewhere.
      We already have a similar limitation for bool-vectors.
      * src/emacs.c (check_bignum_size, xmalloc_for_gmp): New function.
      (xrealloc_for_gmp): Check for too-large bignum.
      (main): Use xmalloc_for_gmp.
      3b9017b5
    • Paul Eggert's avatar
      Speed up logcount on bignums · bb7e0338
      Paul Eggert authored
      * src/data.c (Flogcount): Speed up by using the mpz equivalent
      of ~X instead of -X-1.
      bb7e0338
  6. 16 Aug, 2018 6 commits
    • Michael Albinus's avatar
      Fix Bug#32454 · 44ad4a15
      Michael Albinus authored
      * lisp/files.el (find-alternate-file): Handle the wildcards case.
      (Bug#32454)
      44ad4a15
    • Ken Brown's avatar
      Pacify GCC with -Wunused-but-set-variable · 5f39f203
      Ken Brown authored
      * src/unexcw.c (read_exe_header):
      (fixup_executable):
      (unexec): Specify the "unused" attribute for variables that
      are used only in assertions.
      5f39f203
    • Thomas Fitzsimmons's avatar
      EUDC: Add more BBDB >= 3 support · decd9839
      Thomas Fitzsimmons authored
      * lisp/net/eudcb-bbdb.el Declare BBDB >= 3 functions.
      (eudc-bbdb-field): Add translation from company to
      organization.
      (eudc-bbdb-extract-phones, eudc-bbdb-extract-addresses)
      (eudc-bbdb-format-record-as-result): Call BBDB >= 3 functions.
      decd9839
    • Thomas Fitzsimmons's avatar
      EUDC: Remove XEmacs support · af991f15
      Thomas Fitzsimmons authored
      * lisp/net/eudc.el (eudc-mode, eudc-install-menu): Remove
      XEmacs support.
      * lisp/net/eudc-hotlist.el (eudc-hotlist-mode)
      (eudc-hotlist-emacs-menu): Likewise.
      * lisp/net/eudc-bob.el (eudc-bob-toggle-inline-display)
      (eudc-bob-popup-menu, eudc-bob-generic-keymap)
      (eudc-bob-sound-keymap, eudc-bob-url-keymap)
      (eudc-bob-mail-keymap): Likewise.
      * etc/NEWS (EUDC): Mention removal of XEmacs support.
      af991f15
    • Thomas Fitzsimmons's avatar
      EUDC: Shorten eudc-tools-menu autoload · 36d17ef4
      Thomas Fitzsimmons authored
      * lisp/net/eudc.el: Remove XEmacs support from eudc-tools-menu
      autoload.
      36d17ef4
    • Thomas Fitzsimmons's avatar
      EUDC: Add commentary to eudc-bob.el · 6b178acf
      Thomas Fitzsimmons authored
      * lisp/net/eudc-bob.el: Add commentary.
      6b178acf
  7. 15 Aug, 2018 1 commit
    • Eli Zaretskii's avatar
      Improve documentation of last change · bcdb2d97
      Eli Zaretskii authored
      * lisp/hi-lock.el (hi-lock-set-pattern, hi-lock-face-buffer):
      Improve the doc strings.  (Bug#32365)
      
      * etc/NEWS:
      * doc/emacs/display.texi (Highlight Interactively): Clarify
      wording.
      bcdb2d97
  8. 14 Aug, 2018 3 commits
    • Grégory Mounié's avatar
      Interactive Highlighting: prefix argument to select subexp · cc5a23d4
      Grégory Mounié authored
      * doc/emacs/display.texi (Highlight Interactively):
      * etc/NEWS: Document the change.
      * lisp/hi-lock.el (hi-lock-face-buffer, hi-lock-set-pattern): Use
      the prefix argument to highlight only the corresponding sub-expression
      of the regexp (Bug#32365).
      
      Copyright-paperwork-exempt: yes
      cc5a23d4
    • Paul Eggert's avatar
      Rename --without-mini-gmp to --with-libgmp · 1164d49b
      Paul Eggert authored
      * configure.ac (HAVE_GMP): Rename ‘configure’ option from
      --without-mini-gmp to --with-libgmp.  All uses changed.
      * doc/lispref/numbers.texi (Predicates on Numbers): Large
      integers are always available.  Clarify how eq works on them.
      1164d49b
    • Stephen Berman's avatar
      Fix last todo-edit-mode change · 6d24402d
      Stephen Berman authored
      * lisp/calendar/todo-mode.el (todo-edit-mode): For editing an item
      instead of the whole file, the current todo-file must be set from
      todo-global-current-todo-file.
      
      * test/lisp/calendar/todo-mode-tests.el (todo-test-current-file-in-edit-mode):
      New test.
      6d24402d