summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-07-31 10:12:37 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2015-07-31 10:13:38 -0700
commiteb0f65b4fbbea60100b53cb40a1d7138d47ad0d2 (patch)
treef2debb3a46b3e18217d8cd1736fc7d8add90e3bd /lisp/emacs-lisp
parent0f23e95b29a7a0a07bba0e9bc796cd7b7bc7232a (diff)
downloademacs-eb0f65b4fbbea60100b53cb40a1d7138d47ad0d2.tar.gz
Don't overflow if computing approximate percentage
* lisp/align.el (align-region): * lisp/cedet/semantic.el (semantic-repeat-parse-whole-stream): * lisp/cedet/semantic/wisent.el (wisent-parse-region): * lisp/cus-edit.el (custom-buffer-create-internal): * lisp/emacs-lisp/checkdoc.el (checkdoc-interactive-ispell-loop) (checkdoc-message-interactive-ispell-loop, checkdoc-next-error) (checkdoc-next-message-error): * lisp/emacs-lisp/eieio-opt.el (eieio-display-method-list): * lisp/epa.el (epa-progress-callback-function): * lisp/erc/erc-dcc.el (erc-dcc-do-LIST-command): * lisp/ffap.el (ffap-menu-rescan): * lisp/gnus/nnbabyl.el (nnbabyl-retrieve-headers): * lisp/gnus/nndiary.el (nndiary-retrieve-headers): * lisp/gnus/nneething.el (nneething-retrieve-headers): * lisp/gnus/nnmbox.el (nnmbox-retrieve-headers): * lisp/gnus/nnmh.el (nnmh-retrieve-headers): * lisp/gnus/nnml.el (nnml-retrieve-headers): * lisp/gnus/nnspool.el (nnspool-retrieve-headers): * lisp/gnus/nntp.el (nntp-retrieve-headers) (nntp-retrieve-articles): * lisp/imenu.el (imenu--relative-position): * lisp/international/ja-dic-cnv.el (skkdic-collect-okuri-nasi) (skkdic-convert-okuri-nasi): * lisp/net/ange-ftp.el (ange-ftp-process-handle-hash): * lisp/nxml/rng-valid.el (rng-compute-mode-line-string): * lisp/org/org-list.el (org-update-checkbox-count): * lisp/org/org.el (org-table-map-tables) (org-update-parent-todo-statistics): * lisp/play/decipher.el (decipher-insert-frequency-counts) (decipher-analyze-buffer): * lisp/profiler.el (profiler-format-percent): * lisp/progmodes/cc-cmds.el (c-progress-update): * lisp/progmodes/cpp.el (cpp-highlight-buffer): * lisp/progmodes/idlwave.el (idlwave-convert-xml-system-routine-info) (idlwave-list-load-path-shadows): * lisp/progmodes/opascal.el (opascal-step-progress): * lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info) (vhdl-scan-directory-contents): * lisp/textmodes/bibtex.el (bibtex-progress-message): * lisp/textmodes/flyspell.el (flyspell-small-region) (flyspell-external-point-words): * lisp/textmodes/table.el (table-recognize): Prefer (floor (* 100.0 NUMERATOR) DENOMINATOR) when calculating progress-report percentages and the like. This avoids problems if (* 100 NUMERATOR) would overflow. * lisp/gnus/gnus-registry.el (gnus-registry-import-eld): * lisp/gnus/registry.el (registry-reindex): Use (* 100.0 ...) rather than (* 100 ...) to avoid int overflow issues. * lisp/descr-text.el (describe-char): * lisp/org/org-colview.el (org-nofm-to-completion): * lisp/ps-print.el (ps-plot): * lisp/simple.el (what-cursor-position): Prefer (round (* 100.0 NUMERATOR) DENOMINATOR) to a more-complicated and less-accurate approximation.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/checkdoc.el8
-rw-r--r--lisp/emacs-lisp/eieio-opt.el4
2 files changed, 6 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 0b451ef6b2a..c22aff4cbca 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -747,7 +747,7 @@ buffer, otherwise searching starts at START-HERE."
;; Loop over docstrings.
(while (checkdoc-next-docstring)
(message "Searching for doc string spell error...%d%%"
- (/ (* 100 (point)) (point-max)))
+ (floor (* 100.0 (point)) (point-max)))
(if (looking-at "\"")
(checkdoc-ispell-docstring-engine
(save-excursion (forward-sexp 1) (point-marker)))))
@@ -767,7 +767,7 @@ buffer, otherwise searching starts at START-HERE."
;; Loop over message strings.
(while (checkdoc-message-text-next-string (point-max))
(message "Searching for message string spell error...%d%%"
- (/ (* 100 (point)) (point-max)))
+ (floor (* 100.0 (point)) (point-max)))
(if (looking-at "\"")
(checkdoc-ispell-docstring-engine
(save-excursion (forward-sexp 1) (point-marker)))))
@@ -791,7 +791,7 @@ perform the fix."
(condition-case nil
(while (and (not msg) (checkdoc-next-docstring))
(message "Searching for doc string error...%d%%"
- (/ (* 100 (point)) (point-max)))
+ (floor (* 100.0 (point)) (point-max)))
(if (setq msg (checkdoc-this-string-valid))
(setq msg (cons msg (point)))))
;; Quit.. restore position, Other errors, leave alone
@@ -813,7 +813,7 @@ assumes that the cursor is already positioned to perform the fix."
(setq type
(checkdoc-message-text-next-string (point-max))))
(message "Searching for message string error...%d%%"
- (/ (* 100 (point)) (point-max)))
+ (floor (* 100.0 (point)) (point-max)))
(if (setq msg (checkdoc-message-text-engine type))
(setq msg (cons msg (point)))))
;; Quit.. restore position, Other errors, leave alone
diff --git a/lisp/emacs-lisp/eieio-opt.el b/lisp/emacs-lisp/eieio-opt.el
index 9ecc59434e1..0b003360ed5 100644
--- a/lisp/emacs-lisp/eieio-opt.el
+++ b/lisp/emacs-lisp/eieio-opt.el
@@ -243,13 +243,13 @@ are not abstract."
(princ "Methods Primary Only: ")
(prin1 primaryonly)
(princ "\t")
- (princ (format "%d" (* (/ (float primaryonly) (float methidx)) 100)))
+ (princ (format "%d" (floor (* 100.0 primaryonly) methidx)))
(princ "% of total methods")
(terpri)
(princ "Only One Primary Impl: ")
(prin1 oneprimary)
(princ "\t")
- (princ (format "%d" (* (/ (float oneprimary) (float primaryonly)) 100)))
+ (princ (format "%d" (floor (* 100.0 oneprimary) primaryonly)))
(princ "% of total primary methods")
(terpri)
))