summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-ext.el
diff options
context:
space:
mode:
authorJay Belanger <jay.p.belanger@gmail.com>2013-03-16 19:19:09 -0500
committerJay Belanger <jay.p.belanger@gmail.com>2013-03-16 19:19:09 -0500
commit327f1f6f6d934e58921179275547b2d09f219f32 (patch)
tree68c273ea70df6f17ba0572176d36e6bd4d3020b1 /lisp/calc/calc-ext.el
parent78be8b64657aeca0472d708450ea1ce2bc142606 (diff)
downloademacs-327f1f6f6d934e58921179275547b2d09f219f32.tar.gz
* lisp/calc/calc-ext.el (math-read-number-fancy): Check for an explicit
radix before checking for HMS forms.
Diffstat (limited to 'lisp/calc/calc-ext.el')
-rw-r--r--lisp/calc/calc-ext.el88
1 files changed, 44 insertions, 44 deletions
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index 57de072fdc7..2cb5bf450d5 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -2945,50 +2945,6 @@ If X is not an error form, return 1."
(and x sigma (math-scalarp x) (math-anglep sigma)
(list 'sdev x sigma))))
- ;; Hours (or degrees)
- ((or (string-match "^\\([^#^]+\\)[@oOhH]\\(.*\\)$" s)
- (string-match "^\\([^#^]+\\)[dD][eE]?[gG]?\\(.*\\)$" s))
- (let* ((hours (math-match-substring s 1))
- (minsec (math-match-substring s 2))
- (hours (math-read-number hours))
- (minsec (if (> (length minsec) 0) (math-read-number minsec) 0)))
- (and hours minsec
- (math-num-integerp hours)
- (not (math-negp hours)) (not (math-negp minsec))
- (cond ((math-num-integerp minsec)
- (and (Math-lessp minsec 60)
- (list 'hms hours minsec 0)))
- ((and (eq (car-safe minsec) 'hms)
- (math-zerop (nth 1 minsec)))
- (math-add (list 'hms hours 0 0) minsec))
- (t nil)))))
-
- ;; Minutes
- ((string-match "^\\([^'#^]+\\)[mM']\\(.*\\)$" s)
- (let* ((minutes (math-match-substring s 1))
- (seconds (math-match-substring s 2))
- (minutes (math-read-number minutes))
- (seconds (if (> (length seconds) 0) (math-read-number seconds) 0)))
- (and minutes seconds
- (math-num-integerp minutes)
- (not (math-negp minutes)) (not (math-negp seconds))
- (cond ((math-realp seconds)
- (and (Math-lessp minutes 60)
- (list 'hms 0 minutes seconds)))
- ((and (eq (car-safe seconds) 'hms)
- (math-zerop (nth 1 seconds))
- (math-zerop (nth 2 seconds)))
- (math-add (list 'hms 0 minutes 0) seconds))
- (t nil)))))
-
- ;; Seconds
- ((string-match "^\\([^\"#^]+\\)[sS\"]$" s)
- (let ((seconds (math-read-number (math-match-substring s 1))))
- (and seconds (math-realp seconds)
- (not (math-negp seconds))
- (Math-lessp seconds 60)
- (list 'hms 0 0 seconds))))
-
;; Integer+fraction with explicit radix
((string-match "^\\([0-9]+\\)\\(#\\|\\^\\^\\)\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]\\)$" s)
(let ((radix (string-to-number (math-match-substring s 1)))
@@ -3061,6 +3017,50 @@ If X is not an error form, return 1."
(let ((digs (math-match-substring s 1)))
(math-read-radix digs 16)))
+ ;; Hours (or degrees)
+ ((or (string-match "^\\([^#^]+\\)[@oOhH]\\(.*\\)$" s)
+ (string-match "^\\([^#^]+\\)[dD][eE]?[gG]?\\(.*\\)$" s))
+ (let* ((hours (math-match-substring s 1))
+ (minsec (math-match-substring s 2))
+ (hours (math-read-number hours))
+ (minsec (if (> (length minsec) 0) (math-read-number minsec) 0)))
+ (and hours minsec
+ (math-num-integerp hours)
+ (not (math-negp hours)) (not (math-negp minsec))
+ (cond ((math-num-integerp minsec)
+ (and (Math-lessp minsec 60)
+ (list 'hms hours minsec 0)))
+ ((and (eq (car-safe minsec) 'hms)
+ (math-zerop (nth 1 minsec)))
+ (math-add (list 'hms hours 0 0) minsec))
+ (t nil)))))
+
+ ;; Minutes
+ ((string-match "^\\([^'#^]+\\)[mM']\\(.*\\)$" s)
+ (let* ((minutes (math-match-substring s 1))
+ (seconds (math-match-substring s 2))
+ (minutes (math-read-number minutes))
+ (seconds (if (> (length seconds) 0) (math-read-number seconds) 0)))
+ (and minutes seconds
+ (math-num-integerp minutes)
+ (not (math-negp minutes)) (not (math-negp seconds))
+ (cond ((math-realp seconds)
+ (and (Math-lessp minutes 60)
+ (list 'hms 0 minutes seconds)))
+ ((and (eq (car-safe seconds) 'hms)
+ (math-zerop (nth 1 seconds))
+ (math-zerop (nth 2 seconds)))
+ (math-add (list 'hms 0 minutes 0) seconds))
+ (t nil)))))
+
+ ;; Seconds
+ ((string-match "^\\([^\"#^]+\\)[sS\"]$" s)
+ (let ((seconds (math-read-number (math-match-substring s 1))))
+ (and seconds (math-realp seconds)
+ (not (math-negp seconds))
+ (Math-lessp seconds 60)
+ (list 'hms 0 0 seconds))))
+
;; Fraction using "/" instead of ":"
((string-match "^\\([0-9]+\\)/\\([0-9/]+\\)$" s)
(math-read-number (concat (math-match-substring s 1) ":"