From: Jay Belanger Date: Fri, 22 Jun 2007 01:05:10 +0000 (+0000) Subject: (math-read-number-simple): New function. X-Git-Tag: emacs-pretest-23.0.90~12175 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1f26c38058f08b2af4188ca41ada1363e61f3be6;p=emacs.git (math-read-number-simple): New function. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 148374e0652..0725b9d3451 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2007-06-21 Jay Belanger + + * calc/calc.el (math-read-number-simple): New function. + 2007-06-21 Reto Zimmermann * vera-mode.el (vera-mode): Fix `commend-end-skip' setting. diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index 6f37568ece4..96f93e0467b 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -3423,6 +3423,24 @@ See calc-keypad for details." ;; Syntax error! (t nil)))) +;;; Parse a very simple number, keeping all digits. +(defun math-read-number-simple (s) + (cond + ;; Integer + ((string-match "^[0-9]+$" s) + (cons 'bigpos (math-read-bignum s))) + ;; Minus sign + ((string-match "^-[0-9]+$" s) + (cons 'bigneg (math-read-bignum (substring s 1)))) + ;; Decimal point + ((string-match "^\\(-?[0-9]*\\)\\.\\([0-9]*\\)$" s) + (let ((int (math-match-substring s 1)) + (frac (math-match-substring s 2))) + (list 'float (math-read-number-simple (concat int frac)) + (- (length frac))))) + ;; Syntax error! + (t nil))) + (defun math-match-substring (s n) (if (match-beginning n) (substring s (match-beginning n) (match-end n))