diff options
| author | Paul Eggert | 2015-07-31 10:12:37 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-07-31 10:13:38 -0700 |
| commit | eb0f65b4fbbea60100b53cb40a1d7138d47ad0d2 (patch) | |
| tree | f2debb3a46b3e18217d8cd1736fc7d8add90e3bd /lisp/org | |
| parent | 0f23e95b29a7a0a07bba0e9bc796cd7b7bc7232a (diff) | |
| download | emacs-eb0f65b4fbbea60100b53cb40a1d7138d47ad0d2.tar.gz emacs-eb0f65b4fbbea60100b53cb40a1d7138d47ad0d2.zip | |
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/org')
| -rw-r--r-- | lisp/org/org-colview.el | 2 | ||||
| -rw-r--r-- | lisp/org/org-list.el | 4 | ||||
| -rw-r--r-- | lisp/org/org.el | 6 |
3 files changed, 7 insertions, 5 deletions
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el index e14849f68e4..e938ab4ae4b 100644 --- a/lisp/org/org-colview.el +++ b/lisp/org/org-colview.el | |||
| @@ -1086,7 +1086,7 @@ display, or in the #+COLUMNS line of the current buffer." | |||
| 1086 | (defun org-nofm-to-completion (n m &optional percent) | 1086 | (defun org-nofm-to-completion (n m &optional percent) |
| 1087 | (if (not percent) | 1087 | (if (not percent) |
| 1088 | (format "[%d/%d]" n m) | 1088 | (format "[%d/%d]" n m) |
| 1089 | (format "[%d%%]"(floor (+ 0.5 (* 100. (/ (* 1.0 n) m))))))) | 1089 | (format "[%d%%]" (round (* 100.0 n) m)))) |
| 1090 | 1090 | ||
| 1091 | 1091 | ||
| 1092 | (defun org-columns-string-to-number (s fmt) | 1092 | (defun org-columns-string-to-number (s fmt) |
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el index 73f24ce7bd8..432e4310fae 100644 --- a/lisp/org/org-list.el +++ b/lisp/org/org-list.el | |||
| @@ -2555,8 +2555,8 @@ With optional prefix argument ALL, do this for the whole buffer." | |||
| 2555 | (checked (car (nth 3 cookie))) | 2555 | (checked (car (nth 3 cookie))) |
| 2556 | (total (cdr (nth 3 cookie))) | 2556 | (total (cdr (nth 3 cookie))) |
| 2557 | (new (if percentp | 2557 | (new (if percentp |
| 2558 | (format "[%d%%]" (/ (* 100 checked) | 2558 | (format "[%d%%]" (floor (* 100.0 checked) |
| 2559 | (max 1 total))) | 2559 | (max 1 total))) |
| 2560 | (format "[%d/%d]" checked total)))) | 2560 | (format "[%d/%d]" checked total)))) |
| 2561 | (goto-char beg) | 2561 | (goto-char beg) |
| 2562 | (insert new) | 2562 | (insert new) |
diff --git a/lisp/org/org.el b/lisp/org/org.el index e9dae191b99..b545f9ee1cb 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el | |||
| @@ -4346,7 +4346,8 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables." | |||
| 4346 | (goto-char (point-min)) | 4346 | (goto-char (point-min)) |
| 4347 | (while (re-search-forward org-table-any-line-regexp nil t) | 4347 | (while (re-search-forward org-table-any-line-regexp nil t) |
| 4348 | (unless quietly | 4348 | (unless quietly |
| 4349 | (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size)))) | 4349 | (message "Mapping tables: %d%%" |
| 4350 | (floor (* 100.0 (point)) (buffer-size)))) | ||
| 4350 | (beginning-of-line 1) | 4351 | (beginning-of-line 1) |
| 4351 | (when (and (looking-at org-table-line-regexp) | 4352 | (when (and (looking-at org-table-line-regexp) |
| 4352 | ;; Exclude tables in src/example/verbatim/clocktable blocks | 4353 | ;; Exclude tables in src/example/verbatim/clocktable blocks |
| @@ -12679,7 +12680,8 @@ statistics everywhere." | |||
| 12679 | (outline-next-heading))) | 12680 | (outline-next-heading))) |
| 12680 | (setq new | 12681 | (setq new |
| 12681 | (if is-percent | 12682 | (if is-percent |
| 12682 | (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all))) | 12683 | (format "[%d%%]" (floor (* 100.0 cnt-done) |
| 12684 | (max 1 cnt-all))) | ||
| 12683 | (format "[%d/%d]" cnt-done cnt-all)) | 12685 | (format "[%d/%d]" cnt-done cnt-all)) |
| 12684 | ndel (- (match-end 0) checkbox-beg)) | 12686 | ndel (- (match-end 0) checkbox-beg)) |
| 12685 | ;; handle overlays when updating cookie from column view | 12687 | ;; handle overlays when updating cookie from column view |