aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorPaul Eggert2015-10-20 18:16:47 -0700
committerPaul Eggert2015-10-20 18:22:48 -0700
commite9af822ac3ddf9644aa4a68e56b0580e133449b2 (patch)
tree55b2ae836adac54903d43ee77e2730a0e2ac86bd /lisp
parent513fe25a501b41f9f2aac67f73c8e8730aed81b0 (diff)
downloademacs-e9af822ac3ddf9644aa4a68e56b0580e133449b2.tar.gz
emacs-e9af822ac3ddf9644aa4a68e56b0580e133449b2.zip
(/ N) now returns the reciprocal of N
This is more compatible with Common Lisp and XEmacs (Bug#21690). See: http://lists.gnu.org/archive/html/emacs-devel/2015-10/msg01053.html * lisp/color.el (color-hue-to-rgb, color-hsl-to-rgb) (color-xyz-to-srgb, color-xyz-to-lab): * lisp/emacs-lisp/cl-extra.el (cl-float-limits): * lisp/net/shr-color.el (shr-color-hue-to-rgb) (shr-color-hsl-to-rgb-fractions): Exploit the change to simplify the code a bit. * lisp/emacs-lisp/bytecomp.el (byte-compile-quo): Don’t complain about single-argument calls to ‘/’. * src/data.c (arith_driver, float_arith_driver): Implement the change.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/color.el18
-rw-r--r--lisp/emacs-lisp/bytecomp.el4
-rw-r--r--lisp/emacs-lisp/cl-extra.el2
-rw-r--r--lisp/net/shr-color.el6
4 files changed, 15 insertions, 15 deletions
diff --git a/lisp/color.el b/lisp/color.el
index d572222021b..97656ca9e33 100644
--- a/lisp/color.el
+++ b/lisp/color.el
@@ -93,7 +93,7 @@ resulting list."
93 "Compute hue from V1 and V2 H. 93 "Compute hue from V1 and V2 H.
94Used internally by `color-hsl-to-rgb'." 94Used internally by `color-hsl-to-rgb'."
95 (cond 95 (cond
96 ((< h (/ 1.0 6)) (+ v1 (* (- v2 v1) h 6.0))) 96 ((< h (/ 6.0)) (+ v1 (* (- v2 v1) h 6.0)))
97 ((< h 0.5) v2) 97 ((< h 0.5) v2)
98 ((< h (/ 2.0 3)) (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0))) 98 ((< h (/ 2.0 3)) (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0)))
99 (t v1))) 99 (t v1)))
@@ -110,9 +110,9 @@ inclusive."
110 (- (+ L S) (* L S)))) 110 (- (+ L S) (* L S))))
111 (m1 (- (* 2.0 L) m2))) 111 (m1 (- (* 2.0 L) m2)))
112 (list 112 (list
113 (color-hue-to-rgb m1 m2 (mod (+ H (/ 1.0 3)) 1)) 113 (color-hue-to-rgb m1 m2 (mod (+ H (/ 3.0)) 1))
114 (color-hue-to-rgb m1 m2 H) 114 (color-hue-to-rgb m1 m2 H)
115 (color-hue-to-rgb m1 m2 (mod (- H (/ 1.0 3)) 1)))))) 115 (color-hue-to-rgb m1 m2 (mod (- H (/ 3.0)) 1))))))
116 116
117(defun color-complement-hex (color) 117(defun color-complement-hex (color)
118 "Return the color that is the complement of COLOR, in hexadecimal format." 118 "Return the color that is the complement of COLOR, in hexadecimal format."
@@ -199,13 +199,13 @@ RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive."
199 (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) 199 (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z))))
200 (list (if (<= r 0.0031308) 200 (list (if (<= r 0.0031308)
201 (* 12.92 r) 201 (* 12.92 r)
202 (- (* 1.055 (expt r (/ 1 2.4))) 0.055)) 202 (- (* 1.055 (expt r (/ 2.4))) 0.055))
203 (if (<= g 0.0031308) 203 (if (<= g 0.0031308)
204 (* 12.92 g) 204 (* 12.92 g)
205 (- (* 1.055 (expt g (/ 1 2.4))) 0.055)) 205 (- (* 1.055 (expt g (/ 2.4))) 0.055))
206 (if (<= b 0.0031308) 206 (if (<= b 0.0031308)
207 (* 12.92 b) 207 (* 12.92 b)
208 (- (* 1.055 (expt b (/ 1 2.4))) 0.055))))) 208 (- (* 1.055 (expt b (/ 2.4))) 0.055)))))
209 209
210(defconst color-d65-xyz '(0.950455 1.0 1.088753) 210(defconst color-d65-xyz '(0.950455 1.0 1.088753)
211 "D65 white point in CIE XYZ.") 211 "D65 white point in CIE XYZ.")
@@ -222,13 +222,13 @@ conversion. If omitted or nil, use `color-d65-xyz'."
222 (yr (/ Y Yr)) 222 (yr (/ Y Yr))
223 (zr (/ Z Zr)) 223 (zr (/ Z Zr))
224 (fx (if (> xr color-cie-ε) 224 (fx (if (> xr color-cie-ε)
225 (expt xr (/ 1 3.0)) 225 (expt xr (/ 3.0))
226 (/ (+ (* color-cie-κ xr) 16) 116.0))) 226 (/ (+ (* color-cie-κ xr) 16) 116.0)))
227 (fy (if (> yr color-cie-ε) 227 (fy (if (> yr color-cie-ε)
228 (expt yr (/ 1 3.0)) 228 (expt yr (/ 3.0))
229 (/ (+ (* color-cie-κ yr) 16) 116.0))) 229 (/ (+ (* color-cie-κ yr) 16) 116.0)))
230 (fz (if (> zr color-cie-ε) 230 (fz (if (> zr color-cie-ε)
231 (expt zr (/ 1 3.0)) 231 (expt zr (/ 3.0))
232 (/ (+ (* color-cie-κ zr) 16) 116.0)))) 232 (/ (+ (* color-cie-κ zr) 16) 116.0))))
233 (list 233 (list
234 (- (* 116 fy) 16) ; L 234 (- (* 116 fy) 16) ; L
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 6f7ba3353f6..d138effcd9d 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3617,8 +3617,8 @@ discarding."
3617 3617
3618(defun byte-compile-quo (form) 3618(defun byte-compile-quo (form)
3619 (let ((len (length form))) 3619 (let ((len (length form)))
3620 (cond ((<= len 2) 3620 (cond ((< len 2)
3621 (byte-compile-subr-wrong-args form "2 or more")) 3621 (byte-compile-subr-wrong-args form "1 or more"))
3622 ((= len 3) 3622 ((= len 3)
3623 (byte-compile-two-args form)) 3623 (byte-compile-two-args form))
3624 (t 3624 (t
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index dddfca7ae83..afa021dffc7 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -497,7 +497,7 @@ This sets the values of: `cl-most-positive-float', `cl-most-negative-float',
497 (setq cl-least-positive-normalized-float y 497 (setq cl-least-positive-normalized-float y
498 cl-least-negative-normalized-float (- y)) 498 cl-least-negative-normalized-float (- y))
499 ;; Divide down until value underflows to zero. 499 ;; Divide down until value underflows to zero.
500 (setq x (/ 1 z) y x) 500 (setq x (/ z) y x)
501 (while (condition-case _ (> (/ x 2) 0) (arith-error nil)) 501 (while (condition-case _ (> (/ x 2) 0) (arith-error nil))
502 (setq x (/ x 2))) 502 (setq x (/ x 2)))
503 (setq cl-least-positive-float x 503 (setq cl-least-positive-float x
diff --git a/lisp/net/shr-color.el b/lisp/net/shr-color.el
index 482f829707d..f8d358c27b3 100644
--- a/lisp/net/shr-color.el
+++ b/lisp/net/shr-color.el
@@ -211,7 +211,7 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
211 "Convert X Y H to RGB value." 211 "Convert X Y H to RGB value."
212 (when (< h 0) (incf h)) 212 (when (< h 0) (incf h))
213 (when (> h 1) (decf h)) 213 (when (> h 1) (decf h))
214 (cond ((< h (/ 1 6.0)) (+ x (* (- y x) h 6))) 214 (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6)))
215 ((< h 0.5) y) 215 ((< h 0.5) y)
216 ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6))) 216 ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6)))
217 (t x))) 217 (t x)))
@@ -223,9 +223,9 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
223 (setq m2 (* l (+ s 1))) 223 (setq m2 (* l (+ s 1)))
224 (setq m2 (- (+ l s) (* l s)))) 224 (setq m2 (- (+ l s) (* l s))))
225 (setq m1 (- (* l 2) m2)) 225 (setq m1 (- (* l 2) m2))
226 (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 1 3.0))) 226 (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 3.0)))
227 (shr-color-hue-to-rgb m1 m2 h) 227 (shr-color-hue-to-rgb m1 m2 h)
228 (shr-color-hue-to-rgb m1 m2 (- h (/ 1 3.0)))))) 228 (shr-color-hue-to-rgb m1 m2 (- h (/ 3.0))))))
229 229
230(defun shr-color->hexadecimal (color) 230(defun shr-color->hexadecimal (color)
231 "Convert any color format to hexadecimal representation. 231 "Convert any color format to hexadecimal representation.