Commit 1d228a31 authored by Jay Belanger's avatar Jay Belanger
Browse files

(math-read-number, math-read-number-simple): Use `save-match-data'.

parent 28a90c44
2009-10-23 Jay Belanger <jay.p.belanger@gmail.com>
* calc/calc.el (math-read-number, math-read-number-simple): Use
`save-match-data'.
2009-10-22 Stefan Monnier <monnier@iro.umontreal.ca> 2009-10-22 Stefan Monnier <monnier@iro.umontreal.ca>
* simple.el (normal-erase-is-backspace-mode): Use input-decode-map * simple.el (normal-erase-is-backspace-mode): Use input-decode-map
......
...@@ -3526,6 +3526,7 @@ largest Emacs integer.") ...@@ -3526,6 +3526,7 @@ largest Emacs integer.")
(defun math-read-number (s &optional decimal) (defun math-read-number (s &optional decimal)
"Convert the string S into a Calc number." "Convert the string S into a Calc number."
(math-normalize (math-normalize
(save-match-data
(cond (cond
;; Integers (most common case) ;; Integers (most common case)
...@@ -3580,13 +3581,14 @@ largest Emacs integer.") ...@@ -3580,13 +3581,14 @@ largest Emacs integer.")
(list 'float (nth 1 mant) (+ (nth 2 mant) exp))))))) (list 'float (nth 1 mant) (+ (nth 2 mant) exp)))))))
;; Syntax error! ;; Syntax error!
(t nil)))) (t nil)))))
;;; Parse a very simple number, keeping all digits. ;;; Parse a very simple number, keeping all digits.
(defun math-read-number-simple (s) (defun math-read-number-simple (s)
"Convert the string S into a Calc number. "Convert the string S into a Calc number.
S is assumed to be a simple number (integer or float without an exponent) S is assumed to be a simple number (integer or float without an exponent)
and all digits are kept, regardless of Calc's current precision." and all digits are kept, regardless of Calc's current precision."
(save-match-data
(cond (cond
;; Integer ;; Integer
((string-match "^[0-9]+$" s) ((string-match "^[0-9]+$" s)
...@@ -3607,7 +3609,7 @@ and all digits are kept, regardless of Calc's current precision." ...@@ -3607,7 +3609,7 @@ and all digits are kept, regardless of Calc's current precision."
(list 'float (math-read-number-simple (concat int frac)) (list 'float (math-read-number-simple (concat int frac))
(- (length frac))))) (- (length frac)))))
;; Syntax error! ;; Syntax error!
(t nil))) (t nil))))
(defun math-match-substring (s n) (defun math-match-substring (s n)
(if (match-beginning n) (if (match-beginning n)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment