Mercurial > emacs
changeset 99925:349d60fcf4dc
* nsterm.m (ns_get_color): Handle long hex strings (fixes bug #1044).
author | Adrian Robert <Adrian.B.Robert@gmail.com> |
---|---|
date | Tue, 25 Nov 2008 04:39:29 +0000 |
parents | e149a7ce9e62 |
children | 5b589da725ea |
files | src/nsterm.m |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/nsterm.m Tue Nov 25 04:29:05 2008 +0000 +++ b/src/nsterm.m Tue Nov 25 04:39:29 2008 +0000 @@ -1411,13 +1411,22 @@ /* Direct colors (hex values) */ if (hex) { - unsigned int color = 0; + unsigned long color = 0; if (sscanf (hex, "%x", &color)) { - float f1 = ((color >> 24) & 0xff) / 255.0; - float f2 = ((color >> 16) & 0xff) / 255.0; - float f3 = ((color >> 8) & 0xff) / 255.0; - float f4 = ((color ) & 0xff) / 255.0; + float f1, f2, f3, f4; + /* Assume it's either 1 byte or 2 per channel... */ + if (strlen(hex) > 8) { + f1 = ((color >> 48) & 0xffff) / 65535.0; + f2 = ((color >> 32) & 0xffff) / 65535.0; + f3 = ((color >> 16) & 0xffff) / 65535.0; + f4 = ((color ) & 0xffff) / 65535.0; + } else { + f1 = ((color >> 24) & 0xff) / 255.0; + f2 = ((color >> 16) & 0xff) / 255.0; + f3 = ((color >> 8) & 0xff) / 255.0; + f4 = ((color ) & 0xff) / 255.0; + } switch (color_space) {