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 /admin/unidata | |
| 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 'admin/unidata')
| -rw-r--r-- | admin/unidata/unidata-gen.el | 10 | ||||
| -rw-r--r-- | admin/unidata/uvs.el | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el index 8cc1893adbb..e520d189090 100644 --- a/admin/unidata/unidata-gen.el +++ b/admin/unidata/unidata-gen.el | |||
| @@ -401,7 +401,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." | |||
| 401 | (if (consp range) | 401 | (if (consp range) |
| 402 | (if val | 402 | (if val |
| 403 | (set-char-table-range table range val)) | 403 | (set-char-table-range table range val)) |
| 404 | (let* ((start (lsh (lsh range -7) 7)) | 404 | (let* ((start (ash (ash range -7) 7)) |
| 405 | (limit (+ start 127)) | 405 | (limit (+ start 127)) |
| 406 | first-index last-index) | 406 | first-index last-index) |
| 407 | (fillarray vec 0) | 407 | (fillarray vec 0) |
| @@ -548,7 +548,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." | |||
| 548 | (if (< from (logand to #x1FFF80)) | 548 | (if (< from (logand to #x1FFF80)) |
| 549 | (setq from (logand to #x1FFF80))) | 549 | (setq from (logand to #x1FFF80))) |
| 550 | (setq prev-range-data (cons (cons from to) val-code))))) | 550 | (setq prev-range-data (cons (cons from to) val-code))))) |
| 551 | (let* ((start (lsh (lsh range -7) 7)) | 551 | (let* ((start (ash (ash range -7) 7)) |
| 552 | (limit (+ start 127)) | 552 | (limit (+ start 127)) |
| 553 | str count new-val from to vcode) | 553 | str count new-val from to vcode) |
| 554 | (fillarray vec (car default-value)) | 554 | (fillarray vec (car default-value)) |
| @@ -761,7 +761,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." | |||
| 761 | ((stringp val) | 761 | ((stringp val) |
| 762 | (if (> (aref val 0) 0) | 762 | (if (> (aref val 0) 0) |
| 763 | val | 763 | val |
| 764 | (let* ((first-char (lsh (lsh char -7) 7)) | 764 | (let* ((first-char (ash (ash char -7) 7)) |
| 765 | (word-table (aref (char-table-extra-slot table 4) 0)) | 765 | (word-table (aref (char-table-extra-slot table 4) 0)) |
| 766 | (i 1) | 766 | (i 1) |
| 767 | (len (length val)) | 767 | (len (length val)) |
| @@ -865,7 +865,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." | |||
| 865 | ((stringp val) | 865 | ((stringp val) |
| 866 | (if (> (aref val 0) 0) | 866 | (if (> (aref val 0) 0) |
| 867 | val | 867 | val |
| 868 | (let* ((first-char (lsh (lsh char -7) 7)) | 868 | (let* ((first-char (ash (ash char -7) 7)) |
| 869 | (word-table (char-table-extra-slot table 4)) | 869 | (word-table (char-table-extra-slot table 4)) |
| 870 | (i 1) | 870 | (i 1) |
| 871 | (len (length val)) | 871 | (len (length val)) |
| @@ -982,7 +982,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." | |||
| 982 | (if slot | 982 | (if slot |
| 983 | (nconc slot (list range)) | 983 | (nconc slot (list range)) |
| 984 | (push (list val range) block-list)))) | 984 | (push (list val range) block-list)))) |
| 985 | (let* ((start (lsh (lsh range -7) 7)) | 985 | (let* ((start (ash (ash range -7) 7)) |
| 986 | (limit (+ start 127)) | 986 | (limit (+ start 127)) |
| 987 | (first tail) | 987 | (first tail) |
| 988 | (vec (make-vector 128 nil)) | 988 | (vec (make-vector 128 nil)) |
diff --git a/admin/unidata/uvs.el b/admin/unidata/uvs.el index 6bb6a2ab763..31840fb1822 100644 --- a/admin/unidata/uvs.el +++ b/admin/unidata/uvs.el | |||
| @@ -107,7 +107,7 @@ The most significant byte comes first." | |||
| 107 | (let (result) | 107 | (let (result) |
| 108 | (dotimes (i size) | 108 | (dotimes (i size) |
| 109 | (push (logand value #xff) result) | 109 | (push (logand value #xff) result) |
| 110 | (setq value (lsh value -8))) | 110 | (setq value (ash value -8))) |
| 111 | result)) | 111 | result)) |
| 112 | 112 | ||
| 113 | (defun uvs-insert-fields-as-bytes (fields &rest values) | 113 | (defun uvs-insert-fields-as-bytes (fields &rest values) |