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/international | |
| 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/international')
| -rw-r--r-- | lisp/international/ccl.el | 4 | ||||
| -rw-r--r-- | lisp/international/fontset.el | 4 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 10 | ||||
| -rw-r--r-- | lisp/international/mule.el | 2 |
4 files changed, 10 insertions, 10 deletions
diff --git a/lisp/international/ccl.el b/lisp/international/ccl.el index 58083f05d92..a80452f742f 100644 --- a/lisp/international/ccl.el +++ b/lisp/international/ccl.el | |||
| @@ -1152,9 +1152,9 @@ is a list of CCL-BLOCKs." | |||
| 1152 | (progn | 1152 | (progn |
| 1153 | (insert (logand code #xFFFFFF)) | 1153 | (insert (logand code #xFFFFFF)) |
| 1154 | (setq i (1+ i))) | 1154 | (setq i (1+ i))) |
| 1155 | (insert (format "%c" (lsh code -16))) | 1155 | (insert (format "%c" (ash code -16))) |
| 1156 | (if (< (1+ i) len) | 1156 | (if (< (1+ i) len) |
| 1157 | (insert (format "%c" (logand (lsh code -8) 255)))) | 1157 | (insert (format "%c" (logand (ash code -8) 255)))) |
| 1158 | (if (< (+ i 2) len) | 1158 | (if (< (+ i 2) len) |
| 1159 | (insert (format "%c" (logand code 255)))) | 1159 | (insert (format "%c" (logand code 255)))) |
| 1160 | (setq i (+ i 3))))) | 1160 | (setq i (+ i 3))))) |
diff --git a/lisp/international/fontset.el b/lisp/international/fontset.el index 9bd05ceb4a2..529262a1e7d 100644 --- a/lisp/international/fontset.el +++ b/lisp/international/fontset.el | |||
| @@ -487,7 +487,7 @@ | |||
| 487 | (data (list (vconcat (mapcar 'car cjk)))) | 487 | (data (list (vconcat (mapcar 'car cjk)))) |
| 488 | (i 0)) | 488 | (i 0)) |
| 489 | (dolist (elt cjk) | 489 | (dolist (elt cjk) |
| 490 | (let ((mask (lsh 1 i))) | 490 | (let ((mask (ash 1 i))) |
| 491 | (map-charset-chars | 491 | (map-charset-chars |
| 492 | #'(lambda (range _arg) | 492 | #'(lambda (range _arg) |
| 493 | (let ((from (car range)) (to (cdr range))) | 493 | (let ((from (car range)) (to (cdr range))) |
| @@ -867,7 +867,7 @@ | |||
| 867 | (spec (cdr target-spec))) | 867 | (spec (cdr target-spec))) |
| 868 | (if (integerp spec) | 868 | (if (integerp spec) |
| 869 | (dotimes (i (length registries)) | 869 | (dotimes (i (length registries)) |
| 870 | (if (> (logand spec (lsh 1 i)) 0) | 870 | (if (> (logand spec (ash 1 i)) 0) |
| 871 | (set-fontset-font "fontset-default" target | 871 | (set-fontset-font "fontset-default" target |
| 872 | (cons nil (aref registries i)) | 872 | (cons nil (aref registries i)) |
| 873 | nil 'append))) | 873 | nil 'append))) |
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 2bde83f4eab..817a26b1feb 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -451,8 +451,8 @@ non-nil, it is used to sort CODINGS instead." | |||
| 451 | ;; E: 1 if not XXX-with-esc | 451 | ;; E: 1 if not XXX-with-esc |
| 452 | ;; II: if iso-2022 based, 0..3, else 1. | 452 | ;; II: if iso-2022 based, 0..3, else 1. |
| 453 | (logior | 453 | (logior |
| 454 | (lsh (if (eq base most-preferred) 1 0) 7) | 454 | (ash (if (eq base most-preferred) 1 0) 7) |
| 455 | (lsh | 455 | (ash |
| 456 | (let ((mime (coding-system-get base :mime-charset))) | 456 | (let ((mime (coding-system-get base :mime-charset))) |
| 457 | ;; Prefer coding systems corresponding to a | 457 | ;; Prefer coding systems corresponding to a |
| 458 | ;; MIME charset. | 458 | ;; MIME charset. |
| @@ -468,9 +468,9 @@ non-nil, it is used to sort CODINGS instead." | |||
| 468 | (t 3)) | 468 | (t 3)) |
| 469 | 0)) | 469 | 0)) |
| 470 | 5) | 470 | 5) |
| 471 | (lsh (if (memq base lang-preferred) 1 0) 4) | 471 | (ash (if (memq base lang-preferred) 1 0) 4) |
| 472 | (lsh (if (memq base from-priority) 1 0) 3) | 472 | (ash (if (memq base from-priority) 1 0) 3) |
| 473 | (lsh (if (string-match-p "-with-esc\\'" | 473 | (ash (if (string-match-p "-with-esc\\'" |
| 474 | (symbol-name base)) | 474 | (symbol-name base)) |
| 475 | 0 1) 2) | 475 | 0 1) 2) |
| 476 | (if (eq (coding-system-type base) 'iso-2022) | 476 | (if (eq (coding-system-type base) 'iso-2022) |
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 0267b154409..a4f344192cd 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -911,7 +911,7 @@ non-ASCII files. This attribute is meaningful only when | |||
| 911 | (i 0)) | 911 | (i 0)) |
| 912 | (dolist (elt coding-system-iso-2022-flags) | 912 | (dolist (elt coding-system-iso-2022-flags) |
| 913 | (if (memq elt flags) | 913 | (if (memq elt flags) |
| 914 | (setq bits (logior bits (lsh 1 i)))) | 914 | (setq bits (logior bits (ash 1 i)))) |
| 915 | (setq i (1+ i))) | 915 | (setq i (1+ i))) |
| 916 | (setcdr (assq :flags spec-attrs) bits)))) | 916 | (setcdr (assq :flags spec-attrs) bits)))) |
| 917 | 917 | ||