diff options
| author | Paul Eggert | 2018-08-21 13:44:03 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-08-21 13:44:32 -0700 |
| commit | f18af6cd5cb7dbbf7420ec2d3efed4e202c4f0dd (patch) | |
| tree | 5f42e48e12a0ec77bd5cd5f32255a534635e89bf /lisp/cedet | |
| parent | 81e7eef8224c8a99a207b7a7b9dae1d598392ef7 (diff) | |
| download | emacs-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 'lisp/cedet')
| -rw-r--r-- | lisp/cedet/semantic/wisent/comp.el | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lisp/cedet/semantic/wisent/comp.el b/lisp/cedet/semantic/wisent/comp.el index 837222ad4b1..74ca4f4a437 100644 --- a/lisp/cedet/semantic/wisent/comp.el +++ b/lisp/cedet/semantic/wisent/comp.el | |||
| @@ -142,8 +142,8 @@ If optional LEFT is non-nil insert spaces on left." | |||
| 142 | (defconst wisent-BITS-PER-WORD | 142 | (defconst wisent-BITS-PER-WORD |
| 143 | (let ((i 1) | 143 | (let ((i 1) |
| 144 | (do-shift (if (boundp 'most-positive-fixnum) | 144 | (do-shift (if (boundp 'most-positive-fixnum) |
| 145 | (lambda (i) (lsh most-positive-fixnum (- i))) | 145 | (lambda (i) (ash most-positive-fixnum (- i))) |
| 146 | (lambda (i) (lsh 1 i))))) | 146 | (lambda (i) (ash 1 i))))) |
| 147 | (while (not (zerop (funcall do-shift i))) | 147 | (while (not (zerop (funcall do-shift i))) |
| 148 | (setq i (1+ i))) | 148 | (setq i (1+ i))) |
| 149 | i)) | 149 | i)) |
| @@ -156,18 +156,18 @@ If optional LEFT is non-nil insert spaces on left." | |||
| 156 | "X[I/BITS-PER-WORD] |= 1 << (I % BITS-PER-WORD)." | 156 | "X[I/BITS-PER-WORD] |= 1 << (I % BITS-PER-WORD)." |
| 157 | (let ((k (/ i wisent-BITS-PER-WORD))) | 157 | (let ((k (/ i wisent-BITS-PER-WORD))) |
| 158 | (aset x k (logior (aref x k) | 158 | (aset x k (logior (aref x k) |
| 159 | (lsh 1 (% i wisent-BITS-PER-WORD)))))) | 159 | (ash 1 (% i wisent-BITS-PER-WORD)))))) |
| 160 | 160 | ||
| 161 | (defsubst wisent-RESETBIT (x i) | 161 | (defsubst wisent-RESETBIT (x i) |
| 162 | "X[I/BITS-PER-WORD] &= ~(1 << (I % BITS-PER-WORD))." | 162 | "X[I/BITS-PER-WORD] &= ~(1 << (I % BITS-PER-WORD))." |
| 163 | (let ((k (/ i wisent-BITS-PER-WORD))) | 163 | (let ((k (/ i wisent-BITS-PER-WORD))) |
| 164 | (aset x k (logand (aref x k) | 164 | (aset x k (logand (aref x k) |
| 165 | (lognot (lsh 1 (% i wisent-BITS-PER-WORD))))))) | 165 | (lognot (ash 1 (% i wisent-BITS-PER-WORD))))))) |
| 166 | 166 | ||
| 167 | (defsubst wisent-BITISSET (x i) | 167 | (defsubst wisent-BITISSET (x i) |
| 168 | "(X[I/BITS-PER-WORD] & (1 << (I % BITS-PER-WORD))) != 0." | 168 | "(X[I/BITS-PER-WORD] & (1 << (I % BITS-PER-WORD))) != 0." |
| 169 | (not (zerop (logand (aref x (/ i wisent-BITS-PER-WORD)) | 169 | (not (zerop (logand (aref x (/ i wisent-BITS-PER-WORD)) |
| 170 | (lsh 1 (% i wisent-BITS-PER-WORD)))))) | 170 | (ash 1 (% i wisent-BITS-PER-WORD)))))) |
| 171 | 171 | ||
| 172 | (defsubst wisent-noninteractive () | 172 | (defsubst wisent-noninteractive () |
| 173 | "Return non-nil if running without interactive terminal." | 173 | "Return non-nil if running without interactive terminal." |