aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorPaul Eggert2018-08-21 13:44:03 -0700
committerPaul Eggert2018-08-21 13:44:32 -0700
commitf18af6cd5cb7dbbf7420ec2d3efed4e202c4f0dd (patch)
tree5f42e48e12a0ec77bd5cd5f32255a534635e89bf /doc/misc
parent81e7eef8224c8a99a207b7a7b9dae1d598392ef7 (diff)
downloademacs-f18af6cd5cb7dbbf7420ec2d3efed4e202c4f0dd.tar.gz
emacs-f18af6cd5cb7dbbf7420ec2d3efed4e202c4f0dd.zip
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.
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/calc.texi6
-rw-r--r--doc/misc/cl.texi2
2 files changed, 4 insertions, 4 deletions
diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi
index b1b38620fff..98ef6daa2c1 100644
--- a/doc/misc/calc.texi
+++ b/doc/misc/calc.texi
@@ -32717,7 +32717,7 @@ create an intermediate set.
32717 (while (> n 0) 32717 (while (> n 0)
32718 (if (oddp n) 32718 (if (oddp n)
32719 (setq count (1+ count))) 32719 (setq count (1+ count)))
32720 (setq n (lsh n -1))) 32720 (setq n (ash n -1)))
32721 count)) 32721 count))
32722@end smallexample 32722@end smallexample
32723 32723
@@ -32761,7 +32761,7 @@ routines are especially fast when dividing by an integer less than
32761 (let ((count 0)) 32761 (let ((count 0))
32762 (while (> n 0) 32762 (while (> n 0)
32763 (setq count (+ count (logand n 1)) 32763 (setq count (+ count (logand n 1))
32764 n (lsh n -1))) 32764 n (ash n -1)))
32765 count)) 32765 count))
32766@end smallexample 32766@end smallexample
32767 32767
@@ -32774,7 +32774,7 @@ uses.
32774 32774
32775The @code{idivmod} function does an integer division, returning both 32775The @code{idivmod} function does an integer division, returning both
32776the quotient and the remainder at once. Again, note that while it 32776the quotient and the remainder at once. Again, note that while it
32777might seem that @samp{(logand n 511)} and @samp{(lsh n -9)} are 32777might seem that @samp{(logand n 511)} and @samp{(ash n -9)} are
32778more efficient ways to split off the bottom nine bits of @code{n}, 32778more efficient ways to split off the bottom nine bits of @code{n},
32779actually they are less efficient because each operation is really 32779actually they are less efficient because each operation is really
32780a division by 512 in disguise; @code{idivmod} allows us to do the 32780a division by 512 in disguise; @code{idivmod} allows us to do the
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 77105d3364e..6985f194213 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -784,7 +784,7 @@ default. Some examples:
784(cl-deftype null () '(satisfies null)) ; predefined 784(cl-deftype null () '(satisfies null)) ; predefined
785(cl-deftype list () '(or null cons)) ; predefined 785(cl-deftype list () '(or null cons)) ; predefined
786(cl-deftype unsigned-byte (&optional bits) 786(cl-deftype unsigned-byte (&optional bits)
787 (list 'integer 0 (if (eq bits '*) bits (1- (lsh 1 bits))))) 787 (list 'integer 0 (if (eq bits '*) bits (1- (ash 1 bits)))))
788(unsigned-byte 8) @equiv{} (integer 0 255) 788(unsigned-byte 8) @equiv{} (integer 0 255)
789(unsigned-byte) @equiv{} (integer 0 *) 789(unsigned-byte) @equiv{} (integer 0 *)
790unsigned-byte @equiv{} (integer 0 *) 790unsigned-byte @equiv{} (integer 0 *)