commit 9905001e4b0c9dc0a90cefdd9530a90d07a17b99 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Mon Aug 17 17:54:44 2020 -0700 Fix glitch uncovered by gcc -fsanitize=undefined * src/ccl.c (ccl_driver): Defend against signed integer overflow (Bug#42660). Perhaps some of this is unnecessary, but it is safe and ccl.c is low-priority these days. diff --git a/src/ccl.c b/src/ccl.c index e85cfa6cdf..86debeef0e 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -1142,19 +1142,52 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ccl_expr_self: switch (op) { - case CCL_PLUS: reg[rrr] += i; break; - case CCL_MINUS: reg[rrr] -= i; break; - case CCL_MUL: reg[rrr] *= i; break; - case CCL_DIV: reg[rrr] /= i; break; + case CCL_PLUS: INT_ADD_WRAPV (reg[rrr], i, ®[rrr]); break; + case CCL_MINUS: INT_SUBTRACT_WRAPV (reg[rrr], i, ®[rrr]); break; + case CCL_MUL: INT_MULTIPLY_WRAPV (reg[rrr], i, ®[rrr]); break; + case CCL_DIV: + if (!i) + CCL_INVALID_CMD; + if (!INT_DIVIDE_OVERFLOW (reg[rrr], i)) + reg[rrr] /= i; + break; case CCL_MOD: reg[rrr] %= i; break; + if (!i) + CCL_INVALID_CMD; + reg[rrr] = i == -1 ? 0 : reg[rrr] % i; + break; case CCL_AND: reg[rrr] &= i; break; case CCL_OR: reg[rrr] |= i; break; case CCL_XOR: reg[rrr] ^= i; break; - case CCL_LSH: reg[rrr] <<= i; break; - case CCL_RSH: reg[rrr] >>= i; break; - case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break; + case CCL_LSH: + if (i < 0) + CCL_INVALID_CMD; + reg[rrr] = i < UINT_WIDTH ? (unsigned) reg[rrr] << i : 0; + break; + case CCL_RSH: + if (i < 0) + CCL_INVALID_CMD; + reg[rrr] = reg[rrr] >> min (i, INT_WIDTH - 1); + break; + case CCL_LSH8: + reg[rrr] = (unsigned) reg[rrr] << 8; + reg[rrr] |= i; + break; case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break; - case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break; + case CCL_DIVMOD: + if (!i) + CCL_INVALID_CMD; + if (i == -1) + { + reg[7] = 0; + INT_SUBTRACT_WRAPV (0, reg[rrr], ®[rrr]); + } + else + { + reg[7] = reg[rrr] % i; + reg[rrr] /= i; + } + break; case CCL_LS: reg[rrr] = reg[rrr] < i; break; case CCL_GT: reg[rrr] = reg[rrr] > i; break; case CCL_EQ: reg[rrr] = reg[rrr] == i; break; @@ -1204,19 +1237,52 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ccl_set_expr: switch (op) { - case CCL_PLUS: reg[rrr] = i + j; break; - case CCL_MINUS: reg[rrr] = i - j; break; - case CCL_MUL: reg[rrr] = i * j; break; - case CCL_DIV: reg[rrr] = i / j; break; - case CCL_MOD: reg[rrr] = i % j; break; + case CCL_PLUS: INT_ADD_WRAPV (i, j, ®[rrr]); break; + case CCL_MINUS: INT_SUBTRACT_WRAPV (i, j, ®[rrr]); break; + case CCL_MUL: INT_MULTIPLY_WRAPV (i, j, ®[rrr]); break; + case CCL_DIV: + if (!j) + CCL_INVALID_CMD; + if (!INT_DIVIDE_OVERFLOW (i, j)) + i /= j; + reg[rrr] = i; + break; + case CCL_MOD: + if (!j) + CCL_INVALID_CMD; + reg[rrr] = j == -1 ? 0 : i % j; + break; case CCL_AND: reg[rrr] = i & j; break; case CCL_OR: reg[rrr] = i | j; break; case CCL_XOR: reg[rrr] = i ^ j; break; - case CCL_LSH: reg[rrr] = i << j; break; - case CCL_RSH: reg[rrr] = i >> j; break; - case CCL_LSH8: reg[rrr] = (i << 8) | j; break; + case CCL_LSH: + if (j < 0) + CCL_INVALID_CMD; + reg[rrr] = j < UINT_WIDTH ? (unsigned) i << j : 0; + break; + case CCL_RSH: + if (j < 0) + CCL_INVALID_CMD; + reg[rrr] = i >> min (j, INT_WIDTH - 1); + break; + case CCL_LSH8: + reg[rrr] = ((unsigned) i << 8) | j; + break; case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break; - case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break; + case CCL_DIVMOD: + if (!j) + CCL_INVALID_CMD; + if (j == -1) + { + INT_SUBTRACT_WRAPV (0, reg[rrr], ®[rrr]); + reg[7] = 0; + } + else + { + reg[rrr] = i / j; + reg[7] = i % j; + } + break; case CCL_LS: reg[rrr] = i < j; break; case CCL_GT: reg[rrr] = i > j; break; case CCL_EQ: reg[rrr] = i == j; break; @@ -1225,7 +1291,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size case CCL_NE: reg[rrr] = i != j; break; case CCL_DECODE_SJIS: { - i = (i << 8) | j; + i = ((unsigned) i << 8) | j; SJIS_TO_JIS (i); reg[rrr] = i >> 8; reg[7] = i & 0xFF; @@ -1233,7 +1299,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size } case CCL_ENCODE_SJIS: { - i = (i << 8) | j; + i = ((unsigned) i << 8) | j; JIS_TO_SJIS (i); reg[rrr] = i >> 8; reg[7] = i & 0xFF; commit 352b7dede0b3a28024a41a3da1c340859b110665 Author: Paul Eggert Date: Mon Aug 17 15:05:05 2020 -0700 Update from Gnulib This incorporates: 2020-08-17 verify: avoid __built_assume on Clang 2020-08-17 libc-config: avoid Clang’s __diagnose_if__ * lib/cdefs.h, lib/verify.h: Copy from Gnulib. diff --git a/lib/cdefs.h b/lib/cdefs.h index 0cc27806a1..b1870fd0a9 100644 --- a/lib/cdefs.h +++ b/lib/cdefs.h @@ -148,7 +148,7 @@ # define __warnattr(msg) __attribute__((__warning__ (msg))) # define __errordecl(name, msg) \ extern void name (void) __attribute__((__error__ (msg))) -#elif __glibc_clang_has_attribute (__diagnose_if__) +#elif __glibc_clang_has_attribute (__diagnose_if__) && 0 /* fails on Fedora 31 with Clang 9. */ # define __warndecl(name, msg) \ extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning"))) # define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning"))) diff --git a/lib/verify.h b/lib/verify.h index 0ba8d57907..d485a0283a 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -246,13 +246,6 @@ template /* @assert.h omit start@ */ -#if defined __has_builtin -/* */ -# define _GL_HAS_BUILTIN_ASSUME __has_builtin (__builtin_assume) -#else -# define _GL_HAS_BUILTIN_ASSUME 0 -#endif - #if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) # define _GL_HAS_BUILTIN_TRAP 1 #elif defined __has_builtin @@ -312,11 +305,14 @@ template Although assuming R can help a compiler generate better code or diagnostics, performance can suffer if R uses hard-to-optimize - features such as function calls not inlined by the compiler. */ + features such as function calls not inlined by the compiler. + + Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can + generate a bogus diagnostic "the argument to '__builtin_assume' has + side effects that will be discarded" even when the argument has no + side effects. */ -#if _GL_HAS_BUILTIN_ASSUME -# define assume(R) __builtin_assume (R) -#elif _GL_HAS_BUILTIN_UNREACHABLE +#if _GL_HAS_BUILTIN_UNREACHABLE # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) #elif 1200 <= _MSC_VER # define assume(R) __assume (R) commit a1fe15a6ce7996504a2a422ac59f3494aa20819f Author: Eli Zaretskii Date: Mon Aug 17 19:43:29 2020 +0300 Don't use -Wsuggest-attribute=malloc by default * configure.ac: Move -Wsuggest-attribute=malloc to the set used only under --enable-gcc-warnings. diff --git a/configure.ac b/configure.ac index 745ff22d35..ace1085284 100644 --- a/configure.ac +++ b/configure.ac @@ -1026,7 +1026,10 @@ AS_IF([test $gl_gcc_warnings = no], [# Use -fanalyzer and related options only if --enable-gcc-warnings, # as they slow GCC considerably. nw="$nw -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak" - nw="$nw -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"]) + nw="$nw -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free" + # Use -Wsuggest-attribute=malloc only if --enable-gcc-warnings, + # as it doesn't flag code that is wrong in any way. + nw="$nw -Wsuggest-attribute=malloc"]) nw="$nw -Wcast-align=strict" # Emacs is tricky with pointers. nw="$nw -Wduplicated-branches" # Too many false alarms commit 3a17b9f265fd6d42e82f649533027b4531f9dabf Author: Eli Zaretskii Date: Mon Aug 17 09:30:02 2020 -0700 Fix assertion violation in pdumper.c * src/pdumper.c (pdumper_find_object_type_impl): When checking last_mark_bits, require the offset to be less than discardable_start, not cold_start. This fixes a typo introduced in 2020-08-14T21:33:21Z!eggert@cs.ucla.edu (Bug#42832). diff --git a/src/pdumper.c b/src/pdumper.c index 2d1b19283c..217ffa6783 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -4999,7 +4999,7 @@ pdumper_find_object_type_impl (const void *obj) if (offset % DUMP_ALIGNMENT != 0) return PDUMPER_NO_OBJECT; ptrdiff_t bitno = offset / DUMP_ALIGNMENT; - if (offset < dump_private.header.cold_start + if (offset < dump_private.header.discardable_start && !dump_bitset_bit_set_p (&dump_private.last_mark_bits, bitno)) return PDUMPER_NO_OBJECT; const struct dump_reloc *reloc = commit 12c9941a35eebd459d6311d01b0ec6df49c862bc Author: Eli Zaretskii Date: Mon Aug 17 19:11:35 2020 +0300 ; * etc/NEWS: Call out a recent change in 'count-words'. (Bug#41761) diff --git a/etc/NEWS b/etc/NEWS index 3f52d26c11..61b25d3a2e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1000,6 +1000,12 @@ have now been removed. ** The 'count-lines' function now takes an optional parameter to ignore invisible lines. +--- +** 'count-words' now crosses field boundaries. +Originally, 'count-words' would stop counting at the first field +boundary it encountered; now it keeps counting all the way to the +region's (or buffer's) end. + --- ** New function 'custom-add-choice'. This function can be used by modes to add elements to the commit e5d4fae6797330d91e901c7ecb1412551db12f6a Author: Stefan Kangas Date: Fri Aug 14 18:23:35 2020 +0200 Remove some obsolete items from PROBLEMS * etc/PROBLEMS: Remove some obsolete items. diff --git a/etc/PROBLEMS b/etc/PROBLEMS index 598a79f978..f68a183c5d 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -419,27 +419,6 @@ EMACSLOADPATH overrides which directories the function "load" will search. If you observe strange problems, check for this variable in your environment. -*** Using epop3.el package causes Emacs to signal an error. - -The error message might be something like this: - - "Lisp nesting exceeds max-lisp-eval-depth" - -This happens because epop3 redefines the function gethash, which is a -built-in primitive beginning with Emacs 21.1. We don't have a patch -for epop3 to fix it, but perhaps a newer version of epop3 corrects that. - -*** Buffers from 'with-output-to-temp-buffer' get set up in Help mode. - -Changes in Emacs 20.4 to the hooks used by that function cause -problems for some packages, specifically BBDB. See the function's -documentation for the hooks involved. BBDB 2.00.06 fixes the problem. - -*** The Hyperbole package causes *Help* buffers not to be displayed in -Help mode due to setting 'temp-buffer-show-hook' rather than using -'add-hook'. Using '(add-hook 'temp-buffer-show-hook 'help-mode-finish)' -after loading Hyperbole should fix this. - ** Keyboard problems *** Unable to enter the M-| key on some German keyboards. @@ -575,13 +554,6 @@ For example, simply moving through a file that contains hundreds of thousands of characters per line is slow, and consumes a lot of CPU. This is a known limitation of Emacs with no solution at this time. -*** Emacs uses 100% of CPU time - -This was a known problem with some old versions of the Semantic package. -The solution was to upgrade Semantic to version 2.0pre4 (distributed -with CEDET 1.0pre4) or later. Note that Emacs includes Semantic since -23.2, and this issue does not apply to the included version. - *** Display artifacts on GUI frames on X-based systems. This is known to be caused by using double-buffering (which is enabled @@ -1952,11 +1924,6 @@ A few versions of the Linux kernel have timer bugs that break CPU profiling; see Bug#34235. To fix the problem, upgrade to one of the kernel versions 4.14.97, 4.19.19, or 4.20.6, or later. -*** GNU/Linux: Process output is corrupted. - -There is a bug in Linux kernel 2.6.10 PTYs that can cause emacs to -read corrupted process output. - *** GNU/Linux: Remote access to CVS with SSH causes file corruption. If you access a remote CVS repository via SSH, files may be corrupted @@ -2740,11 +2707,6 @@ library on these systems. The solution is to reconfigure Emacs while disabling all the features that require libgio: rsvg, dbus, gconf, and imagemagick. -*** Building Emacs for Cygwin can fail with GCC 3 - -As of Emacs 22.1, there have been stability problems with Cygwin -builds of Emacs using GCC 3. Cygwin users are advised to use GCC 4. - *** Building Emacs 23.3 and later will fail under Cygwin 1.5.19 This is a consequence of a change to src/dired.c on 2010-07-27. The commit ddbfbeb0671d13fdd06e6eca4328af02d922c6a5 Author: Stefan Kangas Date: Sun Aug 16 21:40:28 2020 +0200 Remove more XEmacs compat code from viper * lisp/emulation/viper-util.el (viper-sit-for-short) (viper-last-command-char): Make obsolete. (viper-fast-keysequence-p): * lisp/emulation/viper-cmd.el (viper-escape-to-emacs) (viper-digit-argument, viper-command-argument, viper-undo) (viper-exit-minibuffer): * lisp/emulation/viper-mous.el (viper-multiclick-p): Adjust callers. diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 77f1b29104..b10a533a77 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -694,7 +694,7 @@ ARG is used as the prefix value for the executed command. If EVENTS is a list of events, which become the beginning of the command." (interactive "P") - (if (viper= (viper-last-command-char) ?\\) + (if (viper= last-command-event ?\\) (message "Switched to EMACS state for the next command...")) (viper-escape-to-state arg events 'emacs-state)) @@ -1149,7 +1149,7 @@ as a Meta key and any number of multiple escapes are allowed." "Begin numeric argument for the next command." (interactive "P") (viper-prefix-arg-value - (viper-last-command-char) (if (consp arg) (cdr arg) nil))) + last-command-event (if (consp arg) (cdr arg) nil))) (defun viper-command-argument (arg) "Accept a motion command as an argument." @@ -1157,7 +1157,7 @@ as a Meta key and any number of multiple escapes are allowed." (let ((viper-intermediate-command 'viper-command-argument)) (condition-case nil (viper-prefix-arg-com - (viper-last-command-char) + last-command-event (cond ((null arg) nil) ((consp arg) (car arg)) ((integerp arg) arg) @@ -1598,9 +1598,9 @@ invokes the command before that, etc." (pos-visible-in-window-p before-undo-pt)) (progn (push-mark (point-marker) t) - (viper-sit-for-short 300) + (sit-for 0.3) (goto-char undo-end-posn) - (viper-sit-for-short 300) + (sit-for 0.3) (if (pos-visible-in-window-p undo-beg-posn) (goto-char before-undo-pt) (goto-char undo-beg-posn))) @@ -1908,7 +1908,7 @@ Undo previous insertion and inserts new." "Exit minibuffer Viper way." (interactive) (let (command) - (setq command (local-key-binding (char-to-string (viper-last-command-char)))) + (setq command (local-key-binding (char-to-string last-command-event))) (run-hooks 'viper-minibuffer-exit-hook) (if command (command-execute command) diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el index 6ecfec548c..928a3ef00e 100644 --- a/lisp/emulation/viper-mous.el +++ b/lisp/emulation/viper-mous.el @@ -98,7 +98,7 @@ considered related." ;;; Code (defsubst viper-multiclick-p () - (not (viper-sit-for-short viper-multiclick-timeout t))) + (not (sit-for (/ viper-multiclick-timeout 1000.0) t))) ;; Returns window where click occurs (defun viper-mouse-click-window (click) diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index 1561204151..61bc26614e 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el @@ -808,9 +808,8 @@ Otherwise return the normal value." (define-obsolete-function-alias 'viper-abbreviate-file-name 'abbreviate-file-name "27.1") -;; Sit for VAL milliseconds. XEmacs doesn't support the millisecond arg -;; in sit-for, so this function smooths out the differences. (defsubst viper-sit-for-short (val &optional nodisp) + (declare (obsolete nil "28.1")) (sit-for (/ val 1000.0) nodisp)) ;; EVENT may be a single event of a sequence of events @@ -868,11 +867,10 @@ Otherwise return the normal value." ;; Uses different timeouts for ESC-sequences and others (defun viper-fast-keysequence-p () - (not (viper-sit-for-short - (if (viper-ESC-event-p last-input-event) - (viper-ESC-keyseq-timeout) - viper-fast-keyseq-timeout) - t))) + (not (sit-for (/ (if (viper-ESC-event-p last-input-event) + (viper-ESC-keyseq-timeout) + viper-fast-keyseq-timeout) 1000.0) + t))) (define-obsolete-function-alias 'viper-read-event-convert-to-char 'read-event "27.1") @@ -920,6 +918,7 @@ Otherwise return the normal value." basis))) (defun viper-last-command-char () + (declare (obsolete nil "28.1")) last-command-event) (defun viper-key-to-emacs-key (key) commit 2b6f52950dbc52f776e065a3716b8bd480d1b922 Author: Michael Albinus Date: Mon Aug 17 11:41:46 2020 +0200 ; * doc/lispref/tips.texi: Fix typo. diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi index 6292054d30..1826e8f7b4 100644 --- a/doc/lispref/tips.texi +++ b/doc/lispref/tips.texi @@ -956,7 +956,7 @@ multiple sub-sections. Even though that was the only recommended approach for a long time, many people have chosen to use multiple top-level code sections instead. You may chose either style. -Using multiple top-level code sections has the advanatage that it +Using multiple top-level code sections has the advantage that it avoids introducing an additional nesting level but it also means that the section named @samp{Code} does not contain all the code, which is awkward. To avoid that, you should put no code at all inside that