]> git.eshelyaron.com Git - emacs.git/log
emacs.git
6 years agoSimplify bignum->intmax conversion
Paul Eggert [Wed, 5 Sep 2018 02:14:01 +0000 (19:14 -0700)]
Simplify bignum->intmax conversion

* src/lisp.h (integer_to_intmax, integer_to_uintmax): New functions.
* src/data.c (cons_to_unsigned, cons_to_signed)
(arith_driver):
* src/dbusbind.c (xd_extract_signed, xd_extract_unsigned):
* src/dispnew.c (sit_for):
* src/editfns.c (styled_format):
* src/emacs-module.c (module_extract_integer):
* src/fileio.c (file_offset):
* src/font.c (font_unparse_xlfd, Fopen_font):
* src/xdisp.c (calc_line_height_property):
* src/process.c (handle_child_signal):

6 years agoAdd variable vc-git-grep-template
Federico Tedin [Sat, 1 Sep 2018 21:46:16 +0000 (18:46 -0300)]
Add variable vc-git-grep-template

* lisp/vc/vc-git.el (vc-git-grep-template): New variable, allows
changing the default arguments passed to git-grep when using
'vc-git-grep'.
* etc/NEWS: Mention 'vc-git-grep-template'.  (Bug#32549)

6 years agoHandle non-error signals in emacsclient --eval (Bug#10989)
Noam Postavsky [Sun, 2 Sep 2018 22:56:38 +0000 (18:56 -0400)]
Handle non-error signals in emacsclient --eval (Bug#10989)

* lisp/server.el (server-process-filter): Handle any signal, not just
errors.

6 years agoAllow t as a catch-all condition-case handler (Bug#24618)
Noam Postavsky [Fri, 10 Aug 2018 01:26:30 +0000 (21:26 -0400)]
Allow t as a catch-all condition-case handler (Bug#24618)

* src/eval.c (find_handler_clause): Accept a handler of t as always
matching.
(Fcondition_case):
* doc/lispref/control.texi (Handling Errors): Document this.
* etc/NEWS: Announce it.

6 years agoFix (round FLOAT BIGNUM) bug
Paul Eggert [Tue, 4 Sep 2018 18:49:41 +0000 (11:49 -0700)]
Fix (round FLOAT BIGNUM) bug

* src/floatfns.c (rounding_driver): Fix bug when one
argument is a float and the other is a bignum.
* test/src/floatfns-tests.el (bignum-round): Test for the bug.

6 years agoTweak nthcdr for bignum efficiency
Paul Eggert [Tue, 4 Sep 2018 17:24:51 +0000 (10:24 -0700)]
Tweak nthcdr for bignum efficiency

* src/fns.c (Fnthcdr): Use mpz_tdiv_ui and mpz_tdiv_r
instead of mpz_mod_ui and mpz_mod, as they are more efficient.
Suggested by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00073.html

6 years agoFix bignum initialization
Paul Eggert [Tue, 4 Sep 2018 16:30:57 +0000 (09:30 -0700)]
Fix bignum initialization

Problem reported by Andy Moreton in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00072.html
and crystal-ball diagnosis by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00075.html
* src/alloc.c (xrealloc_for_gmp, xfree_for_gmp): Move to bignum.c.
(init_alloc): Move bignum initialization to init_bignum.
* src/bignum.c (init_bignum): Rename from init_bignum_once.
All users changed.
* src/emacs.c (main): Call init_bignum after init_alloc,
instead of calling init_bignum_once after init_bignum.

6 years agoSpeed up (+ 2 2) by a factor of 10
Paul Eggert [Tue, 4 Sep 2018 01:37:40 +0000 (18:37 -0700)]
Speed up (+ 2 2) by a factor of 10

Improve arithmetic performance by avoiding bignums until needed.
Also, simplify bignum memory management, fixing some unlikely leaks.
This patch improved the performance of (+ 2 2) by a factor of ten
on a simple microbenchmark computing (+ x 2), byte-compiled,
with x a local variable initialized to 2 via means the byte
compiler could not predict: performance improved from 135 to 13 ns.
The platform was Fedora 28 x86-64, AMD Phenom II X4 910e.
Performance also improved 0.6% on ‘make compile-always’.
* src/bignum.c (init_bignum_once): New function.
* src/emacs.c (main): Use it.
* src/bignum.c (mpz): New global var.
(make_integer_mpz): Rename from make_integer.  All uses changed.
* src/bignum.c (double_to_bignum, make_bignum_bits)
(make_bignum, make_bigint, make_biguint, make_integer_mpz):
* src/data.c (bignum_arith_driver, Frem, Flogcount, Fash)
(expt_integer, Fadd1, Fsub1, Flognot):
* src/floatfns.c (Fabs, rounding_driver, rounddiv_q):
* src/fns.c (Fnthcdr):
Use mpz rather than mpz_initting and mpz_clearing private
temporaries.
* src/bignum.h (bignum_integer): New function.
* src/data.c (Frem, Fmod, Fash, expt_integer):
* src/floatfns.c (rounding_driver):
Use it to simplify code.
* src/data.c (FIXNUMS_FIT_IN_LONG, free_mpz_value):
Remove.  All uses removed.
(floating_point_op): New function.
(floatop_arith_driver): New function, with much of the guts
of the old float_arith_driver.
(float_arith_driver): Use it.
(floatop_arith_driver, arith_driver):
Simplify by assuming NARGS is at least 2.
All callers changed.
(float_arith_driver):
New arg, containing the partly converted value of the next arg.
Reorder args for consistency.  All uses changed.
(bignum_arith_driver): New function.
(arith_driver): Use it.  Do fixnum-only integer calculations
in intmax_t instead of mpz_t, when they fit.
Break out mpz_t calculations into bignum_arith_driver.
(Fquo): Use floatop_arith_driver instead of float_arith_driver,
since the op is known to be valid.
(Flogcount, Fash): Simplify by coalescing bignum and fixnum code.
(Fadd1, Fsub1): Simplify by using make_int.

6 years agoMake todo-show work when adding and deleting a new todo file
Stephen Berman [Mon, 3 Sep 2018 20:40:24 +0000 (22:40 +0200)]
Make todo-show work when adding and deleting a new todo file

* lisp/calendar/todo-mode.el (todo-add-file): Since
todo-current-todo-file must be set before calling todo-show, but
the buffer is not yet in todo-mode, which makes it buffer local,
explicitly set it buffer locally (bug#32627).

* test/lisp/calendar/todo-mode-tests.el (todo-test--add-file)
(todo-test--delete-file): New functions.
(todo-test-add-and-delete-file): New test.

6 years ago* src/lisp.h: Add explanation in a comment
Stefan Monnier [Sat, 1 Sep 2018 22:51:26 +0000 (18:51 -0400)]
* src/lisp.h: Add explanation in a comment

6 years ago; Auto-commit of loaddefs files.
Glenn Morris [Sat, 1 Sep 2018 11:22:46 +0000 (07:22 -0400)]
; Auto-commit of loaddefs files.

6 years ago* src/process.c (send_process): Fix typo in commentary.
Charles A. Roelli [Sat, 1 Sep 2018 11:00:28 +0000 (13:00 +0200)]
* src/process.c (send_process): Fix typo in commentary.

6 years agoRename Emacs-specific INFINITY constants
Paul Eggert [Fri, 31 Aug 2018 16:13:31 +0000 (09:13 -0700)]
Rename Emacs-specific INFINITY constants

Although these constants were not erroneous, as they were
used only in modules that did not include <math.h>, it's
less confusing to names that cannot be confused with
the now-standard INFINITY macro.
* src/dispextern.h (SCROLL_INFINITY): New constant.
* src/dispnew.c, src/scroll.c (INFINITY):
Remove.  All uses replaced with SCROLL_INFINITY.
* src/process.c (wait_reading_process_output):
Rename private constant.

6 years agoPort better to non-IEEE platforms
Paul Eggert [Fri, 31 Aug 2018 15:50:45 +0000 (08:50 -0700)]
Port better to non-IEEE platforms

* src/lread.c (string_to_number) [!IEEE_FLOATING_POINT]:
Do not use the INFINITY macro, since the C standard requires
it to provoke a compile-time error on platforms that do not
support infinities.

6 years agoMark thread-alive-p as obsolete
Michael Albinus [Fri, 31 Aug 2018 09:45:37 +0000 (11:45 +0200)]
Mark thread-alive-p as obsolete

* etc/NEWS (thread-alive-p):
* lisp/emacs-lisp/thread.el (thread-alive-p): Mark it as obsolete.

* test/src/thread-tests.el (threads-join-error)
(threads-signal-main-thread): Use `thread-live-p'.

6 years agoMerge from origin/emacs-26
Michael Albinus [Fri, 31 Aug 2018 09:15:48 +0000 (11:15 +0200)]
Merge from origin/emacs-26

ac7936cb8f Rename thread-alive-p to thread-live-p
3d09d533d1 rcirc: Document /reconnect as a built-in command (Bug#29656)
a1e615618d * test/lisp/calc/calc-tests.el (calc-imaginary-i): New test.

6 years agoRename thread-alive-p to thread-live-p
Michael Albinus [Fri, 31 Aug 2018 08:47:03 +0000 (10:47 +0200)]
Rename thread-alive-p to thread-live-p

* doc/lispref/threads.texi (Basic Thread Functions): Use thread-live-p.

* etc/NEWS: 'thread-alive-p' has been renamed to 'thread-live-p'.

* src/thread.c (thread_live_p): Rename from thread_alive_p.  Adapt
all callees.
(Fthread_live_p): Rename from Fthread_alive_p.
(syms_of_threads): Make thread-alive-p an alias of thread-live-p.

* test/src/thread-tests.el (all): Replace `thread-alive-p' by
`thread-live-p'.
(threads-live): Rename from `threads-alive'.

6 years agoSeveral fixes for formatting bignums
Paul Eggert [Fri, 31 Aug 2018 07:25:07 +0000 (00:25 -0700)]
Several fixes for formatting bignums

* src/bignum.c: Include stdlib.h, for abs.
(bignum_bufsize, bignum_to_c_string): New functions.
* src/bignum.c (bignum_to_string):
* src/print.c (print_vectorlike): Use them.
* src/editfns.c (styled_format): Instead of having a separate
buffer for sprintf (which does not work for bignums), just append
to the main buffer.  When formatting bignums, add support for the
standard integer flags -, #, 0, + and space.  Fix some comments.
Capitalize properly when formatting bignums with %X.  Use
functions like c_isdigit rather than reinventing the wheel.
Simplify computation of excess precision.
* src/print.c: Do not include bignum.h; no longer needed.
(print_vectorlike): Avoid recalculating string length.
* test/src/editfns-tests.el (format-bignum):
Test some of the above fixes.

6 years ago* src/alloc.c (sweep_vectors): Simplify.
Paul Eggert [Fri, 31 Aug 2018 07:22:15 +0000 (00:22 -0700)]
* src/alloc.c (sweep_vectors): Simplify.

6 years agoConstruct a thread_event only if THREADS_ENABLED
Michael Albinus [Fri, 31 Aug 2018 07:04:13 +0000 (09:04 +0200)]
Construct a thread_event only if THREADS_ENABLED

* src/thread.c (Fthread_signal): Construct a thread_event only if
THREADS_ENABLED.

6 years agoFix bignum FIXME in emacs-module.c
Paul Eggert [Fri, 31 Aug 2018 01:10:18 +0000 (18:10 -0700)]
Fix bignum FIXME in emacs-module.c

* 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.

6 years ago* lisp/vc/vc.el (vc-log-internal-common): Reuse the buffer object.
Juri Linkov [Thu, 30 Aug 2018 22:20:14 +0000 (01:20 +0300)]
* lisp/vc/vc.el (vc-log-internal-common): Reuse the buffer object.

(Bug#32475)

6 years ago* lisp/gnus/mm-view.el (mm-display-inline-fontify): Carry diff-mode overlays
Juri Linkov [Thu, 30 Aug 2018 22:15:56 +0000 (01:15 +0300)]
* lisp/gnus/mm-view.el (mm-display-inline-fontify): Carry diff-mode overlays

to inline MIME attachments from the temp buffer along with text properties.
(Bug#32474)

6 years agoFix off-by-1 typo in recent bignum changes
Paul Eggert [Thu, 30 Aug 2018 21:28:19 +0000 (14:28 -0700)]
Fix off-by-1 typo in recent bignum changes

Problem reported by Yuri D’Elia in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00977.html
and crucial clue provided by Michael Heerdegen in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg01043.html
* src/font.c (font_unparse_xlfd): Fix off-by-1 typo.

6 years agoHandle thread-signal towards the main thread (Bug#32502)
Michael Albinus [Thu, 30 Aug 2018 19:29:04 +0000 (21:29 +0200)]
Handle thread-signal towards the main thread  (Bug#32502)

* doc/lispref/threads.texi (Basic Thread Functions):
* etc/NEWS: Document thread-signal towards the main thread.

* lisp/emacs-lisp/thread.el: New package.

* src/keyboard.c (read_char): Check for Qthread_event.
(kbd_buffer_get_event, make_lispy_event): Handle THREAD_EVENT.
(syms_of_keyboard): Declare Qthread_event.
(keys_of_keyboard): Add thread-handle-event to special-event-map.

* src/termhooks.h (enum event_kind): Add THREAD_EVENT.

* src/thread.c: Include "keyboard.h".
(poll_suppress_count) Don't declare extern.
(Fthread_signal): Raise event if THREAD is the main thread.  (Bug#32502)

* test/src/thread-tests.el (thread): Require it.
(threads-signal-main-thread): New test.

6 years ago* configure.ac: Fix goofs in my recent ImageMagick change.
Glenn Morris [Thu, 30 Aug 2018 17:56:08 +0000 (13:56 -0400)]
* configure.ac: Fix goofs in my recent ImageMagick change.

6 years agoPacify -Wdouble-promotion in ImageMagick code
Paul Eggert [Thu, 30 Aug 2018 17:03:43 +0000 (10:03 -0700)]
Pacify -Wdouble-promotion in ImageMagick code

* src/image.c (imagemagick_load_image): Use double division, and
eliminate a cast.  This avoids a -Wdouble-promotion warning with
GCC 7.3 on Ubuntu 18.04.

6 years agorcirc: Document /reconnect as a built-in command (Bug#29656)
Miciah Masters [Mon, 11 Dec 2017 00:56:48 +0000 (19:56 -0500)]
rcirc: Document /reconnect as a built-in command (Bug#29656)

The change "New command rcirc-cmd-reconnect" from 2014-04-09 (shipped
in Emacs 25.1) added a /reconnect command to rcirc but did not
document it and did not delete the example /reconnect command
definition in the manual.
* doc/misc/rcirc.texi (rcirc commands): Document the built-in /reconnect
command.
(Hacking and Tweaking): Delete example reconnect command.

Copyright-paperwork-exempt: yes

6 years ago* test/lisp/calc/calc-tests.el (calc-imaginary-i): New test.
Noam Postavsky [Thu, 30 Aug 2018 02:47:00 +0000 (22:47 -0400)]
* test/lisp/calc/calc-tests.el (calc-imaginary-i): New test.

6 years agoMerge from origin/emacs-26
Glenn Morris [Wed, 29 Aug 2018 15:24:03 +0000 (08:24 -0700)]
Merge from origin/emacs-26

2670cbf (origin/emacs-26) ; * configure.ac: Remove outdated comment (...
3b71bef admin.el: respect environment settings for makeinfo etc
3764ab4 * etc/PROBLEMS: New entry about GTK+ 3 crash with some X serv...
9d61344 Index profiler commands in elisp manual
f088817 Fix math-imaginary-i check
fca935e ; Let pre-commit git hook check merged in changes (Bug#29197)
fe06fcc Avoid infinite hscrolling loops when line numbers are displayed
63e59c8 Avoid crashes in malformed defvar
785682c * configure.ac (emacs_config_features): Add GLIB, XDBE, XIM.
2695b7e * configure.ac: Doc fixes related to --with-xim.
d0d162c Small checkdoc quoting fix (bug#32546)

Conflicts:
configure.ac

6 years ago* src/keymap.c: Make better use of access_keymap's functionality
Stefan Monnier [Wed, 29 Aug 2018 14:43:41 +0000 (10:43 -0400)]
* src/keymap.c: Make better use of access_keymap's functionality

(Flookup_key): Allow `keymap' to be a list of keymaps.
(Fcommand_remapping, Fkey_binding): Simplify accordingly.
(shadow_lookup, describe_map_tree): Simplify.

6 years agoImprove tramp-convert-file-attributes backward compatibility
Michael Albinus [Wed, 29 Aug 2018 08:05:34 +0000 (10:05 +0200)]
Improve tramp-convert-file-attributes backward compatibility

* lisp/net/tramp-sh.el (tramp-convert-file-attributes):
Use `seconds-to-time' for {access, modification, status change}
time.  Simplify check for inode.

* test/lisp/net/tramp-tests.el (tramp-test22-file-times):
Use `seconds-to-time'.

6 years ago* lisp/mail/emacsbug.el (report-emacs-bug--os-description): Add BSD.
Glenn Morris [Wed, 29 Aug 2018 01:22:37 +0000 (21:22 -0400)]
* lisp/mail/emacsbug.el (report-emacs-bug--os-description): Add BSD.

6 years ago; * configure.ac: Remove outdated comment (it was about CRT_DIR).
Glenn Morris [Wed, 29 Aug 2018 01:03:12 +0000 (21:03 -0400)]
; * configure.ac: Remove outdated comment (it was about CRT_DIR).

6 years ago* lisp/mail/emacsbug.el (report-emacs-bug--os-description):
Glenn Morris [Wed, 29 Aug 2018 00:35:09 +0000 (20:35 -0400)]
* lisp/mail/emacsbug.el (report-emacs-bug--os-description):
Add MS Windows.

6 years agoadmin.el: respect environment settings for makeinfo etc
Glenn Morris [Tue, 28 Aug 2018 20:34:25 +0000 (16:34 -0400)]
admin.el: respect environment settings for makeinfo etc

* admin/admin.el (manual-makeinfo, manual-texi2pdf, manual-texi2dvi):
New variables.
(manual-html-mono, manual-html-node, manual-pdf, manual-ps): Use them.

6 years ago* etc/PROBLEMS: New entry about GTK+ 3 crash with some X servers.
Glenn Morris [Tue, 28 Aug 2018 20:05:04 +0000 (16:05 -0400)]
* etc/PROBLEMS: New entry about GTK+ 3 crash with some X servers.

6 years agoImprove (format "%g" bignum) precision
Paul Eggert [Tue, 28 Aug 2018 18:59:21 +0000 (11:59 -0700)]
Improve (format "%g" bignum) precision

* src/editfns.c (styled_format): When formatting bignums with
floating-point conversions like %g, use long double if that
would lose less information than double, which is what the
code was already doing for fixnums.  On Fedora 28 x86-64, for
example, (format "%.100g" (1- (ash 1 64))) now yields
"18446744073709551615" instead of the numerically incorrect
"18446744073709549568".  Also, fix a stray INTEGERP that
can just be FIXNUMP, since bignums are not possible there.

6 years agoFix Fnatnump typos
Paul Eggert [Tue, 28 Aug 2018 16:51:49 +0000 (09:51 -0700)]
Fix Fnatnump typos

Problem reported by Glenn Morris in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00946.html
* src/floatfns.c (Fexpt):
* src/xselect.c (cons_to_x_long):
Don't assume Lisp_Object values are scalars.

6 years agoFix a recent change
Eli Zaretskii [Tue, 28 Aug 2018 16:36:02 +0000 (19:36 +0300)]
Fix a recent change

* src/dispnew.c (sit_for): Don;t treat nil as zero.  Reported
by Glenn Morris <rgm@gnu.org>.

6 years agoAdd bignum support in Tramp
Michael Albinus [Tue, 28 Aug 2018 14:27:02 +0000 (16:27 +0200)]
Add bignum support in Tramp

* lisp/net/tramp-adb.el (tramp-adb-handle-file-system-info):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-system-info):
* lisp/net/tramp-sh.el (tramp-do-file-attributes-with-stat)
(tramp-do-directory-files-and-attributes-with-stat)
(tramp-sh-handle-file-system-info):
* lisp/net/tramp-smb.el (tramp-smb-handle-file-system-info): Do
not add "e0" to integers.

* lisp/net/tramp-sh.el (tramp-perl-file-attributes)
(tramp-convert-file-attributes): Do not use a consp for the inode
if there is bignum support.

6 years agoIndex profiler commands in elisp manual
Noam Postavsky [Tue, 28 Aug 2018 11:49:49 +0000 (07:49 -0400)]
Index profiler commands in elisp manual

* doc/lispref/debugging.texi (Profiling): Add index entries for
profiler-start, profiler-report, profiler-stop.

6 years agoFix math-imaginary-i check
Noam Postavsky [Wed, 15 Aug 2018 03:26:50 +0000 (23:26 -0400)]
Fix math-imaginary-i check

Reported by Bastian Erdnüß at
<https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00300.html>.
* lisp/calc/calc-cplx.el (math-imaginary-i): Check for a value
of (polar 1 <quarter-circle>).

6 years ago; Let pre-commit git hook check merged in changes (Bug#29197)
Noam Postavsky [Thu, 15 Feb 2018 00:58:07 +0000 (19:58 -0500)]
; Let pre-commit git hook check merged in changes (Bug#29197)

* build-aux/git-hooks/pre-commit: If GIT_MERGE_CHECK_OTHER is 'true',
check changes against the merge target, rather than the current
branch.  Include file name when giving error message about
non-standard characters.

6 years agoAvoid infinite hscrolling loops when line numbers are displayed
Eli Zaretskii [Tue, 28 Aug 2018 11:11:12 +0000 (14:11 +0300)]
Avoid infinite hscrolling loops when line numbers are displayed

* src/xdisp.c (maybe_produce_line_number): Don't produce line
numbers if we don't have enough screen estate.  (Bug#32351)

6 years agoAvoid crashes in malformed defvar
Eli Zaretskii [Tue, 28 Aug 2018 07:20:46 +0000 (10:20 +0300)]
Avoid crashes in malformed defvar

* src/eval.c (Fdefvar): Don't call XSYMBOL on something that
might not be a symbol.  This avoids crashes due to malformed
'defvar' forms.  (Bug#32552)

6 years agoImprove bignum support for system types
Paul Eggert [Tue, 28 Aug 2018 04:27:50 +0000 (21:27 -0700)]
Improve bignum support for system types

Use bignums when Emacs converts to and from system types like
off_t for file sizes whose values can exceed fixnum range.
Formerly, Emacs sometimes generted floats and sometimes ad-hoc
conses of integers.  Emacs still accepts floats and conses for
these system types, in case some stray Lisp code is generating
them, though this usage is obsolescent.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/hash.texi (Defining Hash):
* doc/lispref/nonascii.texi (Character Sets):
* doc/lispref/os.texi (User Identification):
* doc/lispref/processes.texi (System Processes):
* etc/NEWS:
Document changes.
* src/bignum.c (mpz_set_uintmax, make_biguint)
(mpz_set_uintmax_slow, bignum_to_intmax, bignum_to_uintmax):
New functions.
(mpz_set_intmax_slow): Implement via mpz_limbs_write,
to avoid the need for an extra pass through a negative number.
* src/charset.c (Fencode_char):
* src/composite.h (LGLYPH_SET_CODE):
* src/dired.c (file_attributes):
* src/dosfns.c, src/w32.c (list_system_processes)
(system_process_attributes):
* src/editfns.c (init_editfns, Fuser_uid, Fuser_real_uid)
(Fgroup_gid, Fgroup_real_gid, Femacs_pid):
* src/emacs-module.c (check_vec_index):
* src/fns.c (Fsafe_length):
* src/process.c (record_deleted_pid, Fprocess_id):
* src/sysdep.c (list_system_processes, system_process_attributes):
* src/xselect.c (x_own_selection, selection_data_to_lisp_data):
* src/xterm.c (set_wm_state):
* src/inotify.c (inotifyevent_to_event, add_watch)
(inotify_callback):
If an integer is out of fixnum range, use a bignum
instead of converting it to a float or a cons of integers.
* src/coding.c (Fdefine_coding_system_internal):
* src/frame.c (frame_windows_min_size)
(x_set_frame_parameters):
* src/fringe.c (Fdefine_fringe_bitmap):
* src/nsterm.m (mouseDown:):
* src/syntax.c (find_defun_start):
* src/w32fns.c (x_set_undecorated, w32_createwindow)
(w32_wnd_proc, Fx_create_frame, Fx_show_tip)
(w32_console_toggle_lock_key):
* src/w32inevt.c (key_event):
* src/w32proc.c (Fw32_get_locale_info):
Do not mishandle floats by treating their addresses as their
values.
* src/data.c (store_symval_forwarding):
* src/gnutls.c (Fgnutls_error_fatalp, Fgnutls_error_string):
* src/keyboard.c (command_loop_1, make_lispy_event):
* src/lread.c (read_filtered_event, read1)
(substitute_object_recurse):
* src/window.c (Fcoordinates_in_window_p, Fwindow_at)
(window_resize_apply, Fset_window_vscroll):
* src/xdisp.c (handle_single_display_spec, try_scrolling)
(redisplay_window, calc_pixel_width_or_height)
(calc_line_height_property, on_hot_spot_p):
* src/xfaces.c (check_lface_attrs):
* src/xselect.c (x_get_local_selection, cons_to_x_long)
(lisp_data_to_selection_data, clean_local_selection_data)
(x_check_property_data, x_fill_property_data):
(x_send_client_event):
Do not reject bignums.
* src/data.c (INTBIG_TO_LISP, intbig_to_lisp)
(uintbig_to_lisp):
Remove.  All uses removed.
* src/data.c (cons_to_unsigned, cons_to_signed):
* src/dbusbind.c (xd_signature, xd_extract_signed)
(xd_extract_unsigned):
* src/dispnew.c (sit_for):
* src/dosfns.c, src/w32.c (system_process_attributes):
* src/editfns.c (Fuser_full_name):
* src/fileio.c (file_offset):
* src/fileio.c (write_region):
* src/font.c (font_unparse_xlfd, font_open_for_lface, Fopen_font):
* src/frame.c (x_set_screen_gamma):
* src/frame.h (NUMVAL, FRAME_PIXEL_X_FROM_CANON_X)
(FRAME_PIXEL_Y_FROM_CANON_Y):
* src/image.c (parse_image_spec, x_edge_detection)
(compute_image_size):
* src/json.c (json_to_lisp):
* src/lcms.c (PARSE_LAB_LIST_FIELD, Flcms_cie_de2000)
(PARSE_XYZ_LIST_FIELD, PARSE_JCH_LIST_FIELD)
(PARSE_JAB_LIST_FIELD, PARSE_VIEW_CONDITION_FLOAT)
(Flcms_temp_to_white_point):
* src/nsimage.m (ns_load_image, setSizeFromSpec):
* src/process.c (Fsignal_process, handle_child_signal):
* src/sysdep.c (system_process_attributes):
* src/xdisp.c (calc_line_height_property):
Handle bignums.
* src/data.c (Fnumber_to_string): Use proper predicate name in
signal if the argument is not a number.
* src/lisp.h (make_uint): New function.
(INT_TO_INTEGER): New macro.
(FIXED_OR_FLOATP, CHECK_FIXNUM_OR_FLOAT)
(CHECK_FIXNUM_OR_FLOAT_COERCE_MARKER, INTEGER_TO_CONS)
(make_fixnum_or_float): Remove; no longer used.
* src/nsfns.m, src/w32fns.c, src/xfns.c (Fx_create_frame):
Reject floating-point min-width or min-height.
* src/process.c (handle_child_signal): Do not worry
about floating-point pids, as they are no longer generated.

6 years agoModularize bignums better
Paul Eggert [Tue, 28 Aug 2018 04:27:50 +0000 (21:27 -0700)]
Modularize bignums better

* src/bignum.c, src/bignum.h: New files.  Only modules that
need to know how bignums are implemented should include
bignum.h.  Currently these are alloc.c, bignum.c (of course),
data.c, emacs.c, emacs-module.c, floatfns.c, fns.c, print.c.
* src/Makefile.in (base_obj): Add bignum.o.
* src/alloc.c (make_bignum_str): Move to bignum.c.
(make_number): Remove; replaced by bignum.c’s make_integer.
All callers changed.
* src/conf_post.h (ARG_NONNULL): New macro.
* src/json.c (json_to_lisp): Use it.
* src/data.c (Fnatnump):
Move NATNUMP’s implementation here from lisp.h.
* src/data.c (Fnumber_to_string):
* src/editfns.c (styled_format):
Move conversion of string to bignum to bignum_to_string, and
call it here.
* src/emacs-module.c (module_make_integer):
* src/floatfns.c (Fabs):
Simplify by using make_int.
* src/emacs.c: Include bignum.h, to expand its inline fns.
* src/floatfns.c (Ffloat): Simplify by using XFLOATINT.
(rounding_driver): Simplify by using double_to_bignum.
(rounddiv_q): Clarify use of temporaries.
* src/lisp.h: Move decls that need to know bignum internals to
bignum.h.  Do not include gmp.h or mini-gmp.h; that is now
bignum.h’s job.
(GMP_NUM_BITS, struct Lisp_Bignum, XBIGNUM, mpz_set_intmax):
Move to bignum.h.
(make_int): New function.
(NATNUMP): Remove; all callers changed to use Fnatnump.
(XFLOATINT): If arg is a bignum, use bignum_to_double, so that
bignum internals are not exposed here.
* src/print.c (print_vectorlike): Use SAFE_ALLOCA to avoid the
need for a record_unwind_protect_ptr.

6 years ago* configure.ac, src/image.c: Tweak previous ImageMagick change.
Glenn Morris [Tue, 28 Aug 2018 02:03:25 +0000 (22:03 -0400)]
* configure.ac, src/image.c: Tweak previous ImageMagick change.

6 years agoSupport ImageMagick version 7 (bug#25967)
Karl Otness [Tue, 28 Aug 2018 01:57:44 +0000 (21:57 -0400)]
Support ImageMagick version 7 (bug#25967)

* configure.ac, src/image.c: Add support for ImageMagick version 7.

Copyright-paperwork-exempt: yes

6 years agoUpdate from Gnulib
Paul Eggert [Tue, 28 Aug 2018 01:59:46 +0000 (18:59 -0700)]
Update from Gnulib

* build-aux/config.sub, lib/intprops.h, lib/regex_internal.c:
* lib/regex_internal.h, lib/unistd.in.h, m4/limits-h.m4:
* m4/stdint.m4, m4/unistd_h.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.

6 years ago* configure.ac (emacs_config_features): Add GLIB, XDBE, XIM.
Glenn Morris [Tue, 28 Aug 2018 01:46:14 +0000 (21:46 -0400)]
* configure.ac (emacs_config_features): Add GLIB, XDBE, XIM.

6 years ago* configure.ac: Doc fixes related to --with-xim.
Glenn Morris [Tue, 28 Aug 2018 01:44:29 +0000 (21:44 -0400)]
* configure.ac: Doc fixes related to --with-xim.

6 years agoNew commands bibtex-next/previous-entry (Bug#32378)
Alex Branham [Tue, 21 Aug 2018 15:21:39 +0000 (10:21 -0500)]
New commands bibtex-next/previous-entry (Bug#32378)

* lisp/textmodes/bibtex.el (bibtex-next-entry)
(bibtex-previous-entry): New commands.
(bibtex-mode-map): Bind to to forward-paragraph and
backward-paragraph.  Add to menu under "Moving inside an Entry".

6 years agoshr: Allow skipping tags with aria-hidden (Bug#32348)
Noam Postavsky [Wed, 8 Aug 2018 00:40:56 +0000 (20:40 -0400)]
shr: Allow skipping tags with aria-hidden (Bug#32348)

* lisp/net/shr.el (shr-discard-aria-hidden): New option.
(shr-descend): Suppress aria-hidden=true tags if it's set.
* doc/misc/eww.texi (Advanced): Document shr-discard-aria-hidden.
* etc/NEWS: Announce it.

6 years agoAllow setf of buffer-modified-p without argument (Bug#21201)
Noam Postavsky [Tue, 17 Jul 2018 02:14:32 +0000 (22:14 -0400)]
Allow setf of buffer-modified-p without argument (Bug#21201)

* lisp/emacs-lisp/cl-lib.el (setf buffer-modified-p): Take current
buffer if optional argument BUF is not passed.

6 years agoSmall checkdoc quoting fix (bug#32546)
Glenn Morris [Mon, 27 Aug 2018 22:27:01 +0000 (18:27 -0400)]
Small checkdoc quoting fix (bug#32546)

* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
Fix quoting thinko.

6 years agoCC Mode: Fix syntactic context of BOD sometimes being 'topmost-intro-cont
Alan Mackenzie [Mon, 27 Aug 2018 20:37:49 +0000 (20:37 +0000)]
CC Mode: Fix syntactic context of BOD sometimes being 'topmost-intro-cont

This happened when the type of the previous function was a struct, etc.,
declaration.

* lisp/progmodes/cc-mode (c-guess-basic-syntax CASE 5N): Check here (for
'topmost-intro-cont) that the first opening brace after BOD is the opening
brace preceding the starting point.

6 years agoc-where-wrt-brace-construct: deal with point following a struct's semicolon.
Alan Mackenzie [Mon, 27 Aug 2018 19:49:25 +0000 (19:49 +0000)]
c-where-wrt-brace-construct: deal with point following a struct's semicolon.

More precisely, when point is right after the terminating semicolon of a
construct like "struct foo { .... } bar;", the function must return
'at-function-end.

* lisp/progmodes/cc-cmds.el (c-where-wrt-brace-construct): Surround an
existing test for 'at-function-end with an `or' form, the other arm testing
for being after the semicolon above.

6 years agoFix links in backtraces to work on advised built-ins (Bug#25393)
Gemini Lasswell [Wed, 8 Aug 2018 02:39:06 +0000 (19:39 -0700)]
Fix links in backtraces to work on advised built-ins (Bug#25393)

* lisp/emacs-lisp/backtrace.el (backtrace--print-func-and-args): Make
links to the original definition of advised functions.  Handle the
case when the function slot of the backtrace frame contains the
definition of a built-in function.

6 years agoBump Tramp version to 2.4.1-pre
Michael Albinus [Mon, 27 Aug 2018 14:45:50 +0000 (16:45 +0200)]
Bump Tramp version to 2.4.1-pre

* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.4.1-pre".

* lisp/net/tramp.el: Add "Package-Requires" header.

6 years agoMerge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Michael Albinus [Mon, 27 Aug 2018 10:51:44 +0000 (12:51 +0200)]
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs

6 years agoMerge from origin/emacs-26
Glenn Morris [Sun, 26 Aug 2018 22:10:50 +0000 (15:10 -0700)]
Merge from origin/emacs-26

54fb383 (origin/emacs-26) Fix detection of freed emacs_values (Bug#32...
769d0cd ; Fix out-of-tree build for mod-test.so
9a1329e Avoid crashes with very wide TTY frames on MS-Windows
9a613d3 Prevent `modify-file-local-variable-prop-line' from adding ex...
624e7dc Update GNOME bugtracker URLs
51ef6d5 Clarify in the Emacs manual that ChangeLog files are not used
6e08019 Recognize codepage 65001 as a valid encoding
1a350d7 ; * etc/NEWS: Fix format of first lines of some entries.
22d1f53 Avoid compilation warning in nt/addpm.c
7bc9ce7 Fix duplicate custom group names in bibtex.el
a9cf938 Fix outdated text in the Calc manual

Conflicts:
etc/NEWS
etc/PROBLEMS
src/emacs-module.c
src/gtkutil.c
src/image.c
src/xterm.c
test/Makefile.in

6 years agoFix a typo in alloc.c
Eli Zaretskii [Sun, 26 Aug 2018 14:53:05 +0000 (17:53 +0300)]
Fix a typo in alloc.c

* src/alloc.c (Fmemory_use_counts): The list we return now has
only 7 elements, not 8.  (Bug#32531)

6 years agoCC Mode: make c-display-defun-name work with a pointer return type.
Alan Mackenzie [Sun, 26 Aug 2018 11:05:22 +0000 (11:05 +0000)]
CC Mode: make c-display-defun-name work with a pointer return type.

Fixes bug #32403.

* lisp/progmodes/cc-cmds.el (c-in-function-trailer-p): No longer insist on
c-beginning-of-decl-1 returning 'same.
(c-where-wrt-brace-construct): Tighten up the test for looking at a symbol by
excluding keywords.  When point is after a }, do not return 'at-function-end
for a struct/union/class/...
(c-defun-name-1): Considerably simplify, by amalgamating the two cond arms
which find structs etc., and by using functions like c-forward-declarator
rather than the faulty analysis of the source by hand.

6 years ago* lisp/net/tramp.el: Add "Version" header.
Stefan Monnier [Sun, 26 Aug 2018 08:33:09 +0000 (10:33 +0200)]
* lisp/net/tramp.el: Add "Version" header.

6 years agoImprove format-seconds accuracy
Paul Eggert [Sun, 26 Aug 2018 02:03:26 +0000 (19:03 -0700)]
Improve format-seconds accuracy

* doc/lispref/os.texi (Time Parsing): It works with bignums.
* lisp/calendar/time-date.el (format-seconds):
Take the floor so that the resulting arithmetic is exact.

6 years agoFix detection of freed emacs_values (Bug#32479)
Sergey Vinokurov [Sun, 19 Aug 2018 20:31:01 +0000 (21:31 +0100)]
Fix detection of freed emacs_values (Bug#32479)

* src/emacs-module.c (module_free_global_ref): Compare a value to be
freed with all entries of the list.

* test/data/emacs-module/mod-test.c (Fmod_test_globref_free): New
function.
(emacs_module_init): Make it accessible from Lisp.
* test/src/emacs-module-tests.el (mod-test-globref-free-test): New
test which uses it.

6 years ago; Fix out-of-tree build for mod-test.so
Noam Postavsky [Sat, 25 Aug 2018 22:55:11 +0000 (18:55 -0400)]
; Fix out-of-tree build for mod-test.so

* test/Makefile.in: Don't look for emacs-module.h in $(srcdir), since
it is generated.

6 years agoPrefer CONSP etc. to XTYPE
Paul Eggert [Sat, 25 Aug 2018 21:20:02 +0000 (14:20 -0700)]
Prefer CONSP etc. to XTYPE

* src/nsmenu.m (process_dialog:):
(initFromContents:isQuestion:):
Prefer CONSP (x) to XTYPE (x) == Lisp_Cons,
and similarly for STRINGP (x).

6 years agoImprove performance of CONSP, FIXNUMP, etc.
Paul Eggert [Sat, 25 Aug 2018 20:39:18 +0000 (13:39 -0700)]
Improve performance of CONSP, FIXNUMP, etc.

Optimization opportunity noted by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00828.html
On my platform (Fedora 28 x86-64, AMD Phenom II X4 910e,
user+system time), this improved ‘make compile-always’
performance by 0.4% and shrank text size by a similar amount.
* src/lisp.h (TAGGEDP, lisp_h_TAGGEDP): New macros and function.
(lisp_h_CONSP, lisp_h_FLOATP, lisp_h_SYMBOLP)
(lisp_h_VECTORLIKEP, make_lisp_ptr, STRINGP): Use them.
(lisp_h_FIXNUMP): Use the same idea that lisp_h_TAGGEDP uses.

6 years agoAvoid crashes with very wide TTY frames on MS-Windows
Eli Zaretskii [Sat, 25 Aug 2018 12:26:41 +0000 (15:26 +0300)]
Avoid crashes with very wide TTY frames on MS-Windows

* src/w32console.c <glyph_base>: Reduce the number of elements
to 80.
<glyphs, glyphs_len>: New static variables.
(w32con_clear_end_of_line): If the line is wider than the
current size of the "empty row" in 'glyphs', reallocate
'glyphs' to support the full width of the frame.  This
avoids segfaults when the frame is wider than 256 columns.
(Bug#32445)

6 years agoPrevent `modify-file-local-variable-prop-line' from adding extra ';'
Wenjamin Petrenko [Tue, 14 Aug 2018 08:44:18 +0000 (11:44 +0300)]
Prevent `modify-file-local-variable-prop-line' from adding extra ';'

* lisp/files-x.el (modify-file-local-variable-prop-line): Handle
whitespace when checking if there's already a ';' before the
variable (Bug#23294).

Copyright-paperwork-exempt: yes

6 years agoUpdate GNOME bugtracker URLs
Glenn Morris [Fri, 24 Aug 2018 17:13:08 +0000 (13:13 -0400)]
Update GNOME bugtracker URLs

* configure.ac, admin/notes/multi-tty, etc/PROBLEMS:
* src/emacs.c (main):
* src/xterm.c (x_connection_closed): Update GNOME bugtracker URLs.
; * src/gtkutil.c (xg_display_close):
; * src/image.c (svg_load_image): Update URLs in comments.

6 years agoDetect Chinese sudo password prompts (Bug#31075)
Noam Postavsky [Mon, 25 Jun 2018 23:11:41 +0000 (19:11 -0400)]
Detect Chinese sudo password prompts (Bug#31075)

* lisp/comint.el (comint-password-prompt-regexp): Allow text between
the prompt prefix and password equivalent.
* lisp/eshell/esh-mode.el (eshell-password-prompt-regexp): Accept some
unicode alternatives to ":".
* test/lisp/comint-tests.el (comint-testsuite-password-strings): Add
test case.

6 years agoFix comint-password-prompt-regexp
Noam Postavsky [Fri, 17 Aug 2018 10:29:35 +0000 (06:29 -0400)]
Fix comint-password-prompt-regexp

The change from 2017-12-22 "Support French password prompts in shell"
tried to allow nonbreaking space in addition to whitespace syntax
characters around the colon, but used square brackets which cause "\s"
to be interpreted literally rather than as a backslash construct.
* lisp/comint.el (comint-password-prompt-regexp): Use [[:blank:]]
instead, which also has the benefit of not relying on the major mode's
whitespace syntax setting.
* test/lisp/comint-tests.el (comint-testsuite-password-strings):
Update French localized entry to have a space before the colon, as
reported in Bug#29729.

6 years agoReplace 2 checks in rmailsum.el with 'pos-visible-in-window-p'
Charles A. Roelli [Thu, 23 Aug 2018 20:10:08 +0000 (22:10 +0200)]
Replace 2 checks in rmailsum.el with 'pos-visible-in-window-p'

* lisp/mail/rmailsum.el (rmail-summary-scroll-msg-up)
(rmail-summary-scroll-msg-down): Use 'pos-visible-in-window-p'
instead of checking the condition by hand.

6 years agoClarify in the Emacs manual that ChangeLog files are not used
Eli Zaretskii [Thu, 23 Aug 2018 17:02:27 +0000 (20:02 +0300)]
Clarify in the Emacs manual that ChangeLog files are not used

* doc/emacs/trouble.texi (Sending Patches): Use "commit log"
instead of "change log", to avoid the interpretation that we
are talking about literal ChangeLog files.  (Bug#32359)

6 years agoFix binding error in nnfolder-read-folder
Lars Ingebrigtsen [Thu, 23 Aug 2018 14:55:35 +0000 (16:55 +0200)]
Fix binding error in nnfolder-read-folder

* lisp/gnus/nnfolder.el (nnfolder-read-folder): Fix previous
checkin that left `active' unbound before using it.

6 years agoPrune most-positive-fixnum from Lisp source
Paul Eggert [Thu, 23 Aug 2018 03:45:47 +0000 (20:45 -0700)]
Prune most-positive-fixnum from Lisp source

I looked through all instances of most-negative-fixnum
and most-positive-fixnum in the Lisp source code, and
when it was easy I removed assumptions that integers
fit in fixnums.  The remaining instances are either
nontrivial to fix, or are inherent to the algorithm.
* lisp/arc-mode.el (archive-l-e): Do not convert to float,
since we have bignums now.  All uses changed.
* lisp/calc/calc.el (math-bignum):
Don’t special-case most-negative-fixnum.
* lisp/calendar/parse-time.el (parse-time-string):
* lisp/emacs-lisp/edebug.el (edebug-read-special):
* lisp/emacs-lisp/package.el (package--remove-hidden):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/international/mule-util.el (filepos-to-bufferpos--dos):
* lisp/menu-bar.el (menu-bar-update-buffers):
* lisp/net/rcirc.el (rcirc-handler-317):
* lisp/org/org-agenda.el (org-cmp-ts):
* lisp/window.el (window--resize-child-windows):
Avoid arbitrary limit to most-positive-fixnum or to
most-negative-fixnum.
* lisp/calendar/time-date.el (days-to-time):
* lisp/erc/erc-dcc.el (erc-unpack-int):
Don’t worry about integer overflow.
* lisp/cedet/semantic/wisent/comp.el (wisent-BITS-PER-WORD):
* lisp/gnus/message.el (message-unique-id):
* lisp/org/org-footnote.el (org-footnote-new):
Simplify.
* lisp/erc/erc-dcc.el (erc-most-positive-int-bytes)
(erc-most-positive-int-msb): Remove; no longer needed.
* lisp/net/imap.el (imap-string-to-integer): Remove; unused.
* lisp/org/org-element.el (org-element--cache-generate-key):
Document fixnum limitation.

6 years agoFix bugs when rounding to bignums
Paul Eggert [Thu, 23 Aug 2018 02:30:24 +0000 (19:30 -0700)]
Fix bugs when rounding to bignums

Also, since Emacs historically reported a range error when
rounding operations overflowed, do that consistently for all
bignum overflows.
* doc/lispref/errors.texi (Standard Errors):
* doc/lispref/numbers.texi (Integer Basics): Document range errors.
* src/alloc.c (range_error): Rename from integer_overflow.
All uses changed.
* src/floatfns.c (rounding_driver): When the result of a floating
point rounding operation does not fit into a fixnum, put it
into a bignum instead of always signaling an range error.
* test/src/floatfns-tests.el (divide-extreme-sign):
These tests now return the mathematically-correct answer
instead of signaling an error.
(bignum-round): Check that integers round to themselves.

6 years agoUndo part of previous change
Paul Eggert [Wed, 22 Aug 2018 21:11:25 +0000 (14:11 -0700)]
Undo part of previous change

Issue spotted by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00758.html
* lisp/vc/vc-hg.el (vc-hg--raw-dirstate-search):
Go back to using eq on flen, since it must be a fixnum.

6 years agoMake vc-hg safe for bignums
Paul Eggert [Wed, 22 Aug 2018 17:18:34 +0000 (10:18 -0700)]
Make vc-hg safe for bignums

* lisp/vc/vc-hg.el (vc-hg--raw-dirstate-search):
Use eql, not eq, on integers that could be bignums.
(vc-hg--time-to-integer): Rename from vc-hg--time-to-fixnum.
All uses changed.
(vc-hg-state-fast): Remove test that 32-bit unsigned values
must be fixnums.

6 years ago* src/buffer.h (DECODE_POSITION): Remove; unused.
Paul Eggert [Wed, 22 Aug 2018 05:02:47 +0000 (22:02 -0700)]
* src/buffer.h (DECODE_POSITION): Remove; unused.

6 years agoAdd bignum support to floor, ceiling, etc.
Paul Eggert [Wed, 22 Aug 2018 02:23:45 +0000 (19:23 -0700)]
Add bignum support to floor, ceiling, etc.

Problem reported by Andy Moreton (Bug#32463#35 (d)).
* src/floatfns.c (rounding_driver): Change the signature
of the integer rounder to use mpz_t rather than EMACS_INT.
All uses changed.  Support bignums.
(ceiling2, floor2, truncate2, round2): Remove.
All uses changed to rounddiv_q or to a GMP library function.
(rounddiv_q): New function.
* test/src/floatfns-tests.el (bignum-round): New test.

6 years agoMove bignump, fixnump from C to Lisp
Paul Eggert [Tue, 21 Aug 2018 23:06:58 +0000 (16:06 -0700)]
Move bignump, fixnump from C to Lisp

* doc/lispref/objects.texi (Integer Type): Mention
most-negative-fixnum and most-positive-fixnum as alternatives
to fixnump and bignump.
* lisp/subr.el (fixnump, bignump): Now written in Lisp.
* src/data.c (Ffixnump, Fbignump): No longer written in C,
as these new functions are not crucial for performance.

6 years agoFix assertion failure when reading 'BIGNUM.'
Paul Eggert [Tue, 21 Aug 2018 22:49:01 +0000 (15:49 -0700)]
Fix assertion failure when reading 'BIGNUM.'

Problem reported by Stefan Monnier (Bug#32476).
* src/lread.c (string_to_number): Don't pass leading "+"
or trailing "." or junk to make_bignum_str.
* test/src/lread-tests.el (lread-string-to-number-trailing-dot):
New test.

6 years agoAudit use of lsh and fix glitches
Paul Eggert [Tue, 21 Aug 2018 20:44:03 +0000 (13:44 -0700)]
Audit use of lsh and fix glitches

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.

6 years agoFix bignum bugs with nth, elt, =
Paul Eggert [Tue, 21 Aug 2018 18:40:23 +0000 (11:40 -0700)]
Fix bignum bugs with nth, elt, =

* 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.

6 years agoRestore compatibility with Texinfo < 6
Glenn Morris [Tue, 21 Aug 2018 17:05:31 +0000 (13:05 -0400)]
Restore compatibility with Texinfo < 6

* doc/lispref/numbers.texi (Integer Basics, Bitwise Operations):
Don't use Texinfo 6.0's "@sup" command.

6 years agoRecognize codepage 65001 as a valid encoding
Eli Zaretskii [Tue, 21 Aug 2018 16:35:31 +0000 (19:35 +0300)]
Recognize codepage 65001 as a valid encoding

* lisp/international/mule-conf.el (cp65001): Define it as an
alias for UTF-8.

6 years ago; * etc/NEWS: Fix format of the first lines of some entries.
Eli Zaretskii [Tue, 21 Aug 2018 16:07:53 +0000 (19:07 +0300)]
; * etc/NEWS: Fix format of the first lines of some entries.

6 years ago; * etc/NEWS: Fix format of first lines of some entries.
Eli Zaretskii [Tue, 21 Aug 2018 15:58:15 +0000 (18:58 +0300)]
; * etc/NEWS: Fix format of first lines of some entries.

6 years agoImprove documentation of 'integer-width'
Eli Zaretskii [Tue, 21 Aug 2018 14:56:47 +0000 (17:56 +0300)]
Improve documentation of 'integer-width'

* etc/NEWS: Minor rewording of the recent addition.

* doc/lispref/numbers.texi (Bitwise Operations): Use @dots{}
for ellipsis.  Improve indexing.

6 years agoAvoid libgmp aborts by imposing limits
Paul Eggert [Tue, 21 Aug 2018 09:16:50 +0000 (02:16 -0700)]
Avoid libgmp aborts by imposing limits

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.

6 years agoFix glitches introduced by nthcdr changes
Paul Eggert [Tue, 21 Aug 2018 09:05:07 +0000 (02:05 -0700)]
Fix glitches introduced by nthcdr changes

* 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.

6 years agoSpeed up (nthcdr N L) when L is circular
Paul Eggert [Mon, 20 Aug 2018 22:52:29 +0000 (15:52 -0700)]
Speed up (nthcdr N L) when L is circular

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.

6 years agoDefine get_proc_addr in Cygwin-w32 build
Andy Moreton [Mon, 20 Aug 2018 21:00:27 +0000 (17:00 -0400)]
Define get_proc_addr in Cygwin-w32 build

* 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.

6 years agonthcdr now works with bignums
Paul Eggert [Mon, 20 Aug 2018 17:24:19 +0000 (10:24 -0700)]
nthcdr now works with bignums

Problem reported by Karl Fogel in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00671.html
* src/fns.c (Fnthcdr): Support bignum counts.

6 years agoFix expt signedness bug --without-wide-int
Paul Eggert [Sun, 19 Aug 2018 17:05:41 +0000 (10:05 -0700)]
Fix expt signedness bug --without-wide-int

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.