diff options
| author | Adrian Robert | 2008-11-25 04:39:29 +0000 |
|---|---|---|
| committer | Adrian Robert | 2008-11-25 04:39:29 +0000 |
| commit | f272d02fffaeb57d70d95c17d1ca22f88983c73a (patch) | |
| tree | 6aa34a496d792a9221f8ccbf2edc00045ac62d90 | |
| parent | 5da9413d6c34ecc43e679b8ccdb78b2462cb9ded (diff) | |
| download | emacs-f272d02fffaeb57d70d95c17d1ca22f88983c73a.tar.gz emacs-f272d02fffaeb57d70d95c17d1ca22f88983c73a.zip | |
* nsterm.m (ns_get_color): Handle long hex strings (fixes bug #1044).
| -rw-r--r-- | src/nsterm.m | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index a82937a6ccf..83cc18184ba 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1411,13 +1411,22 @@ ns_get_color (const char *name, NSColor **col) | |||
| 1411 | /* Direct colors (hex values) */ | 1411 | /* Direct colors (hex values) */ |
| 1412 | if (hex) | 1412 | if (hex) |
| 1413 | { | 1413 | { |
| 1414 | unsigned int color = 0; | 1414 | unsigned long color = 0; |
| 1415 | if (sscanf (hex, "%x", &color)) | 1415 | if (sscanf (hex, "%x", &color)) |
| 1416 | { | 1416 | { |
| 1417 | float f1 = ((color >> 24) & 0xff) / 255.0; | 1417 | float f1, f2, f3, f4; |
| 1418 | float f2 = ((color >> 16) & 0xff) / 255.0; | 1418 | /* Assume it's either 1 byte or 2 per channel... */ |
| 1419 | float f3 = ((color >> 8) & 0xff) / 255.0; | 1419 | if (strlen(hex) > 8) { |
| 1420 | float f4 = ((color ) & 0xff) / 255.0; | 1420 | f1 = ((color >> 48) & 0xffff) / 65535.0; |
| 1421 | f2 = ((color >> 32) & 0xffff) / 65535.0; | ||
| 1422 | f3 = ((color >> 16) & 0xffff) / 65535.0; | ||
| 1423 | f4 = ((color ) & 0xffff) / 65535.0; | ||
| 1424 | } else { | ||
| 1425 | f1 = ((color >> 24) & 0xff) / 255.0; | ||
| 1426 | f2 = ((color >> 16) & 0xff) / 255.0; | ||
| 1427 | f3 = ((color >> 8) & 0xff) / 255.0; | ||
| 1428 | f4 = ((color ) & 0xff) / 255.0; | ||
| 1429 | } | ||
| 1421 | 1430 | ||
| 1422 | switch (color_space) | 1431 | switch (color_space) |
| 1423 | { | 1432 | { |