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.
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.
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.
* 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.
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.
* 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.
* 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.
* 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>.
* 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.
* 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>.
* 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)
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.
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.
* 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
* 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.
* 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.
* lisp/calendar/todo-mode.el (todo-edit-file): Make the warning
also suitable for Todo Archive mode, and add more space to it.
(todo-edit-quit): On quitting editing an archive file, return to
the Todo Archive mode buffer editing was invoked in.
(todo-check-format): Display a warning instead of a message when
the categories sexp isn't as expected.
(todo-mode-external-set): Remove.
(todo-edit-mode): Set buffer local values of
todo-current-todo-file and todo-categories from the todo or
archive file being edited.
(todo-categories-mode): Set buffer local values of
todo-current-todo-file and todo-categories as before but directly
instead of using superfluous todo-mode-external-set function.
* test/lisp/calendar/todo-mode-tests.el (todo-test-edit-quit): New test.
Remove misc-objects-consed and the misc component of
memory-use-count, since misc objects no longer exist.
* doc/lispref/internals.texi, etc/NEWS: Mention this,
and adjust better to recent removal of misc objects.
* src/alloc.c (MEM_TYPE_MISC): Remove; no longer used.
(Fmemory_use_counts): Omit misc count, since miscs
no longer exist.
(misc-objects-consed): Remove.
34e75c1 Add comment about floating point test
e73e683 Ibuffer: Add toggle ibuffer-do-toggle-lock
12f7116 Ibuffer: Detect correctly the buffers running a process
614cc65 ; * lisp/simple.el (line-move-visual): Fix typo.
d2ad4ba Do not consider external packages to be removable (Bug#27822)
ec0995c * src/alloc.c: Remove obsolete comments.
ec6f588 Better support utf-8-with-signature and utf-8-hfs in HTML
eb026a8 Don't use -Wabi compiler option
* src/lisp.h (make_pointer_integer_unsafe): New function.
(make_pointer_integer): Use it.
* src/gfilenotify.c (dir_monitor_callback): Omit redundant eassert.
(Fgfile_add_watch): Signal an error instead of failing an
assertion if the pointer does not work.
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00380.html
* src/data.c (arithcompare): Work around incompatibility
between gcc -fexcess-precision=fast and the C standard on x86,
by capturing the results of floating-point comparisons before
the excess precision spontaneously decays. Although this fix
might not work in general, it does work here and is probably
good enough for the platforms we care about.
(cherry picked from commit a84cef9095)
* test/src/data-tests.el (data-tests--float-greater-than-fixnums):
New constant.
(data-tests-=, data-tests-<, data-tests->, data-tests-<=)
(data-tests->=, data-tests-min): Use it.
Toggle the locked status in marked buffers or the buffer
at point (Bug#32421).
* lisp/ibuffer.el (ibuffer-do-toggle-lock): New command.
(ibuffer-mode-map): Bind it to 'L'.
(ibuffer-mode-operate-map): Add entries for
`ibuffer-do-toggle-read-only' and `ibuffer-do-toggle-lock'.
* etc/NEWS (Changes in Specialized Modes and Packages in Emacs 26.2):
Announce the change.
* lisp/ibuffer.el (filename-and-process): Store the process buffer
as a text property; check for such property to detect a buffer
with a process (Bug#32420).
This addresses the -Og uninitialized variable warnings I ran
into on Fedora 28, which uses 8.1.1 20180712 (Red Hat 8.1.1-5).
It also changes some explicit initializations to UNINIT
when the variable does not actually need to be initialized.
* src/process.c (connect_network_socket):
* src/sysdep.c (system_process_attributes):
* src/xfns.c (x_real_pos_and_offsets):
* src/xterm.c (get_current_wm_state) [USE_XCB]:
Add UNINIT.
* src/editfns.c (tzlookup):
* src/fns.c (Fnconc):
* src/font.c (font_parse_fcname):
* src/frame.c (x_set_frame_parameters):
Prefer UNINIT to explicit initialization.