From 327f1f6f6d934e58921179275547b2d09f219f32 Mon Sep 17 00:00:00 2001 From: Jay Belanger Date: Sat, 16 Mar 2013 19:19:09 -0500 Subject: [PATCH] * lisp/calc/calc-ext.el (math-read-number-fancy): Check for an explicit radix before checking for HMS forms. --- lisp/ChangeLog | 5 +++ lisp/calc/calc-ext.el | 88 +++++++++++++++++++++---------------------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6ac3515c480..6c0de85ccf8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-03-17 Jay Belanger + + * calc/calc-ext.el (math-read-number-fancy): Check for an explicit + radix before checking for HMS forms. + 2013-03-16 Leo Liu * progmodes/scheme.el: Add indentation and font-locking for λ. 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) ":" -- 2.39.2