;; print with radix -- for binary, convert the octal number
(let* ((fmt (if (eq calculator-output-radix 'hex) "%x" "%o"))
(str (if calculator-2s-complement num (abs num)))
- (str (format fmt (calculator-truncate str)))
+ (str (format fmt (truncate str)))
(bins '((?0 "000") (?1 "001") (?2 "010") (?3 "011")
(?4 "100") (?5 "101") (?6 "110") (?7 "111")))
(str (if (not (eq calculator-output-radix 'bin)) str
(d2 ; prior days not in n2820 or n768
(mod d1 280506))
(n1 ; years not in n2820 or n768
- ;; Want:
- ;; (floor (+ (* 2820 d2) (* 2820 366)) 1029983))
- ;; but that causes overflow, so use the following.
- ;; Use 366 as the divisor because (2820*366 mod 1029983) is small.
- (let ((a (floor d2 366))
- (b (mod d2 366)))
- (+ 1 a (floor (+ (* 2137 a) (* 2820 b) 2137) 1029983))))
+ (floor (* 2820 (+ d2 366)) 1029983))
(year (+ (* 2820 n2820) ; complete 2820 year cycles
(* 768 n768) ; complete 768 year cycles
;; Remaining years.
(list (make-backup-file-name fn))
(cons (format "%s.~%d~" basic-name (1+ high-water-mark))
(if (and (> number-to-delete 0)
- ;; Delete nothing if there is overflow
- ;; in the number of versions to keep.
+ ;; Delete nothing if kept-new-versions and
+ ;; kept-old-versions combine to an outlandish value.
(>= (+ kept-new-versions kept-old-versions -1) 0))
(mapcar (lambda (n)
(format "%s.~%d~" basic-name n))
(defsubst gnus-agent-read-article-number ()
"Reads the article number at point. Returns nil when a valid article number can not be read."
- ;; It is unfortunate but the read function quietly overflows
- ;; integer. As a result, I have to use string operations to test
- ;; for overflow BEFORE calling read.
(when (looking-at "[0-9]+\t")
- (let ((len (- (match-end 0) (match-beginning 0))))
- (cond ((< len 9)
- (read (current-buffer)))
- ((= len 9)
- ;; Many 9 digit base-10 numbers can be represented in a 27-bit int
- ;; Back convert from int to string to ensure that this is one of them.
- (let* ((str1 (buffer-substring (match-beginning 0) (1- (match-end 0))))
- (num (read (current-buffer)))
- (str2 (int-to-string num)))
- (when (equal str1 str2)
- num)))))))
+ (read (current-buffer))))
(defsubst gnus-agent-copy-nov-line (article)
"Copy the indicated ARTICLE from the overview buffer to the nntp server buffer."
(setq ino-opened (file-attribute-inode-number attr)
nlink (file-attribute-link-number attr)
number-linked (+ number-opened nlink))
- (if (or (< nlink 1) (< number-linked nlink))
- (signal 'error '("Arithmetic overflow")))
(setq attr (file-attributes
(concat dir (number-to-string number-linked))))
(or attr (throw 'return (1- number-linked)))
(let* ((attr (file-attributes path-open))
(nlink (file-attribute-link-number attr)))
(setq ino-open (file-attribute-inode-number attr)
- number-link (+ number-open nlink))
- (if (or (< nlink 1) (< number-link nlink))
- (signal 'error '("Arithmetic overflow"))))
+ number-link (+ number-open nlink)))
(if (= number-link previous-number-link)
;; We've already tried this number, in the previous loop iteration,
;; and failed.
\(buffer-size)) is the position in the current buffer corresponding to
that scroll bar position."
;; We multiply before we divide to maintain precision.
- ;; We use floating point because the product of a large buffer size
- ;; with a large scroll bar portion can easily overflow a lisp int.
- (truncate (/ (* (float (car num-denom)) whole) (cdr num-denom))))
+ (truncate (* (car num-denom) whole) (cdr num-denom)))
(defun scroll-bar-columns (side)
"Return the width, measured in columns, of the vertical scrollbar on SIDE.
(push-mark))
(let ((size (- (point-max) (point-min))))
(goto-char (if (and arg (not (consp arg)))
- (+ (point-min)
- (if (> size 10000)
- ;; Avoid overflow for large buffer sizes!
- (* (prefix-numeric-value arg)
- (/ size 10))
- (/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
+ (+ (point-min) 1
+ (/ (* size (prefix-numeric-value arg)) 10))
(point-min))))
(if (and arg (not (consp arg))) (forward-line 1)))
(let ((size (- (point-max) (point-min))))
(goto-char (if (and arg (not (consp arg)))
(- (point-max)
- (if (> size 10000)
- ;; Avoid overflow for large buffer sizes!
- (* (prefix-numeric-value arg)
- (/ size 10))
- (/ (* size (prefix-numeric-value arg)) 10)))
+ (/ (* size (prefix-numeric-value arg)) 10))
(point-max))))
;; If we went to a place in the middle of the buffer,
;; adjust it to the beginning of a line.