diff options
| author | Jay Belanger | 2013-03-16 19:19:09 -0500 |
|---|---|---|
| committer | Jay Belanger | 2013-03-16 19:19:09 -0500 |
| commit | 327f1f6f6d934e58921179275547b2d09f219f32 (patch) | |
| tree | 68c273ea70df6f17ba0572176d36e6bd4d3020b1 | |
| parent | 78be8b64657aeca0472d708450ea1ce2bc142606 (diff) | |
| download | emacs-327f1f6f6d934e58921179275547b2d09f219f32.tar.gz emacs-327f1f6f6d934e58921179275547b2d09f219f32.zip | |
* lisp/calc/calc-ext.el (math-read-number-fancy): Check for an explicit
radix before checking for HMS forms.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2013-03-17 Jay Belanger <jay.p.belanger@gmail.com> | ||
| 2 | |||
| 3 | * calc/calc-ext.el (math-read-number-fancy): Check for an explicit | ||
| 4 | radix before checking for HMS forms. | ||
| 5 | |||
| 1 | 2013-03-16 Leo Liu <sdl.web@gmail.com> | 6 | 2013-03-16 Leo Liu <sdl.web@gmail.com> |
| 2 | 7 | ||
| 3 | * progmodes/scheme.el: Add indentation and font-locking for λ. | 8 | * 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." | |||
| 2945 | (and x sigma (math-scalarp x) (math-anglep sigma) | 2945 | (and x sigma (math-scalarp x) (math-anglep sigma) |
| 2946 | (list 'sdev x sigma)))) | 2946 | (list 'sdev x sigma)))) |
| 2947 | 2947 | ||
| 2948 | ;; Hours (or degrees) | ||
| 2949 | ((or (string-match "^\\([^#^]+\\)[@oOhH]\\(.*\\)$" s) | ||
| 2950 | (string-match "^\\([^#^]+\\)[dD][eE]?[gG]?\\(.*\\)$" s)) | ||
| 2951 | (let* ((hours (math-match-substring s 1)) | ||
| 2952 | (minsec (math-match-substring s 2)) | ||
| 2953 | (hours (math-read-number hours)) | ||
| 2954 | (minsec (if (> (length minsec) 0) (math-read-number minsec) 0))) | ||
| 2955 | (and hours minsec | ||
| 2956 | (math-num-integerp hours) | ||
| 2957 | (not (math-negp hours)) (not (math-negp minsec)) | ||
| 2958 | (cond ((math-num-integerp minsec) | ||
| 2959 | (and (Math-lessp minsec 60) | ||
| 2960 | (list 'hms hours minsec 0))) | ||
| 2961 | ((and (eq (car-safe minsec) 'hms) | ||
| 2962 | (math-zerop (nth 1 minsec))) | ||
| 2963 | (math-add (list 'hms hours 0 0) minsec)) | ||
| 2964 | (t nil))))) | ||
| 2965 | |||
| 2966 | ;; Minutes | ||
| 2967 | ((string-match "^\\([^'#^]+\\)[mM']\\(.*\\)$" s) | ||
| 2968 | (let* ((minutes (math-match-substring s 1)) | ||
| 2969 | (seconds (math-match-substring s 2)) | ||
| 2970 | (minutes (math-read-number minutes)) | ||
| 2971 | (seconds (if (> (length seconds) 0) (math-read-number seconds) 0))) | ||
| 2972 | (and minutes seconds | ||
| 2973 | (math-num-integerp minutes) | ||
| 2974 | (not (math-negp minutes)) (not (math-negp seconds)) | ||
| 2975 | (cond ((math-realp seconds) | ||
| 2976 | (and (Math-lessp minutes 60) | ||
| 2977 | (list 'hms 0 minutes seconds))) | ||
| 2978 | ((and (eq (car-safe seconds) 'hms) | ||
| 2979 | (math-zerop (nth 1 seconds)) | ||
| 2980 | (math-zerop (nth 2 seconds))) | ||
| 2981 | (math-add (list 'hms 0 minutes 0) seconds)) | ||
| 2982 | (t nil))))) | ||
| 2983 | |||
| 2984 | ;; Seconds | ||
| 2985 | ((string-match "^\\([^\"#^]+\\)[sS\"]$" s) | ||
| 2986 | (let ((seconds (math-read-number (math-match-substring s 1)))) | ||
| 2987 | (and seconds (math-realp seconds) | ||
| 2988 | (not (math-negp seconds)) | ||
| 2989 | (Math-lessp seconds 60) | ||
| 2990 | (list 'hms 0 0 seconds)))) | ||
| 2991 | |||
| 2992 | ;; Integer+fraction with explicit radix | 2948 | ;; Integer+fraction with explicit radix |
| 2993 | ((string-match "^\\([0-9]+\\)\\(#\\|\\^\\^\\)\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]\\)$" s) | 2949 | ((string-match "^\\([0-9]+\\)\\(#\\|\\^\\^\\)\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]\\)$" s) |
| 2994 | (let ((radix (string-to-number (math-match-substring s 1))) | 2950 | (let ((radix (string-to-number (math-match-substring s 1))) |
| @@ -3061,6 +3017,50 @@ If X is not an error form, return 1." | |||
| 3061 | (let ((digs (math-match-substring s 1))) | 3017 | (let ((digs (math-match-substring s 1))) |
| 3062 | (math-read-radix digs 16))) | 3018 | (math-read-radix digs 16))) |
| 3063 | 3019 | ||
| 3020 | ;; Hours (or degrees) | ||
| 3021 | ((or (string-match "^\\([^#^]+\\)[@oOhH]\\(.*\\)$" s) | ||
| 3022 | (string-match "^\\([^#^]+\\)[dD][eE]?[gG]?\\(.*\\)$" s)) | ||
| 3023 | (let* ((hours (math-match-substring s 1)) | ||
| 3024 | (minsec (math-match-substring s 2)) | ||
| 3025 | (hours (math-read-number hours)) | ||
| 3026 | (minsec (if (> (length minsec) 0) (math-read-number minsec) 0))) | ||
| 3027 | (and hours minsec | ||
| 3028 | (math-num-integerp hours) | ||
| 3029 | (not (math-negp hours)) (not (math-negp minsec)) | ||
| 3030 | (cond ((math-num-integerp minsec) | ||
| 3031 | (and (Math-lessp minsec 60) | ||
| 3032 | (list 'hms hours minsec 0))) | ||
| 3033 | ((and (eq (car-safe minsec) 'hms) | ||
| 3034 | (math-zerop (nth 1 minsec))) | ||
| 3035 | (math-add (list 'hms hours 0 0) minsec)) | ||
| 3036 | (t nil))))) | ||
| 3037 | |||
| 3038 | ;; Minutes | ||
| 3039 | ((string-match "^\\([^'#^]+\\)[mM']\\(.*\\)$" s) | ||
| 3040 | (let* ((minutes (math-match-substring s 1)) | ||
| 3041 | (seconds (math-match-substring s 2)) | ||
| 3042 | (minutes (math-read-number minutes)) | ||
| 3043 | (seconds (if (> (length seconds) 0) (math-read-number seconds) 0))) | ||
| 3044 | (and minutes seconds | ||
| 3045 | (math-num-integerp minutes) | ||
| 3046 | (not (math-negp minutes)) (not (math-negp seconds)) | ||
| 3047 | (cond ((math-realp seconds) | ||
| 3048 | (and (Math-lessp minutes 60) | ||
| 3049 | (list 'hms 0 minutes seconds))) | ||
| 3050 | ((and (eq (car-safe seconds) 'hms) | ||
| 3051 | (math-zerop (nth 1 seconds)) | ||
| 3052 | (math-zerop (nth 2 seconds))) | ||
| 3053 | (math-add (list 'hms 0 minutes 0) seconds)) | ||
| 3054 | (t nil))))) | ||
| 3055 | |||
| 3056 | ;; Seconds | ||
| 3057 | ((string-match "^\\([^\"#^]+\\)[sS\"]$" s) | ||
| 3058 | (let ((seconds (math-read-number (math-match-substring s 1)))) | ||
| 3059 | (and seconds (math-realp seconds) | ||
| 3060 | (not (math-negp seconds)) | ||
| 3061 | (Math-lessp seconds 60) | ||
| 3062 | (list 'hms 0 0 seconds)))) | ||
| 3063 | |||
| 3064 | ;; Fraction using "/" instead of ":" | 3064 | ;; Fraction using "/" instead of ":" |
| 3065 | ((string-match "^\\([0-9]+\\)/\\([0-9/]+\\)$" s) | 3065 | ((string-match "^\\([0-9]+\\)/\\([0-9/]+\\)$" s) |
| 3066 | (math-read-number (concat (math-match-substring s 1) ":" | 3066 | (math-read-number (concat (math-match-substring s 1) ":" |