diff options
| author | Simen Heggestøyl | 2018-01-28 13:03:05 +0100 |
|---|---|---|
| committer | Simen Heggestøyl | 2018-01-28 13:28:28 +0100 |
| commit | 97defdfc36d9a83a3081c5f76e249f908645f7ec (patch) | |
| tree | 8153be0281d8e52f9e3d32309347080242f65da4 | |
| parent | 9824885fabea53f8c4461d038f4c1edad1b8f591 (diff) | |
| download | emacs-97defdfc36d9a83a3081c5f76e249f908645f7ec.tar.gz emacs-97defdfc36d9a83a3081c5f76e249f908645f7ec.zip | |
Fix off-by-one error in 'css--hex-to-rgb'
* lisp/textmodes/css-mode.el (css--hex-to-rgb): Fix off-by-one error.
* test/lisp/textmodes/css-mode-tests.el (css-test-hex-to-rgb): Add
regression tests for the above fix.
| -rw-r--r-- | lisp/textmodes/css-mode.el | 2 | ||||
| -rw-r--r-- | test/lisp/textmodes/css-mode-tests.el | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 6bd08f59190..135c0d5f928 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el | |||
| @@ -1458,7 +1458,7 @@ should not be mixed with those in color.el." | |||
| 1458 | (if-let* ((alpha (css--hex-alpha hex)) | 1458 | (if-let* ((alpha (css--hex-alpha hex)) |
| 1459 | (a (css--format-rgba-alpha | 1459 | (a (css--format-rgba-alpha |
| 1460 | (/ (string-to-number alpha 16) | 1460 | (/ (string-to-number alpha 16) |
| 1461 | (float (expt 16 (length alpha))))))) | 1461 | (float (- (expt 16 (length alpha)) 1)))))) |
| 1462 | (format "rgba(%d, %d, %d, %s)" r g b a) | 1462 | (format "rgba(%d, %d, %d, %s)" r g b a) |
| 1463 | (format "rgb(%d, %d, %d)" r g b)) | 1463 | (format "rgb(%d, %d, %d)" r g b)) |
| 1464 | t)) | 1464 | t)) |
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 272d281217e..4883123843d 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el | |||
| @@ -281,7 +281,9 @@ | |||
| 281 | ("#fff" "rgb(255, 255, 255)") | 281 | ("#fff" "rgb(255, 255, 255)") |
| 282 | ("#ffffff" "rgb(255, 255, 255)") | 282 | ("#ffffff" "rgb(255, 255, 255)") |
| 283 | ("#ffffff80" "rgba(255, 255, 255, 0.5)") | 283 | ("#ffffff80" "rgba(255, 255, 255, 0.5)") |
| 284 | ("#fff8" "rgba(255, 255, 255, 0.5)"))) | 284 | ("#fff0" "rgba(255, 255, 255, 0)") |
| 285 | ("#fff8" "rgba(255, 255, 255, 0.53)") | ||
| 286 | ("#ffff" "rgba(255, 255, 255, 1)"))) | ||
| 285 | (with-temp-buffer | 287 | (with-temp-buffer |
| 286 | (css-mode) | 288 | (css-mode) |
| 287 | (insert (nth 0 item)) | 289 | (insert (nth 0 item)) |