From 5ed654ef4056be90d28ec16b7539f8f14b084503 Mon Sep 17 00:00:00 2001 From: "peterl%netscape.com" Date: Wed, 28 Apr 1999 01:41:23 +0000 Subject: [PATCH] allow letter O to be treated as zero in color hex values, egads --- gfx/src/nsColor.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gfx/src/nsColor.cpp b/gfx/src/nsColor.cpp index fac816b91b61..25666afd3f1f 100644 --- a/gfx/src/nsColor.cpp +++ b/gfx/src/nsColor.cpp @@ -27,7 +27,10 @@ static int ComponentValue(const char* aColorSpec, int aLen, int color, int dpc) aColorSpec += (color * dpc); while (--dpc >= 0) { char ch = *aColorSpec++; - if ((ch >= '0') && (ch <= '9')) { + if ((ch == 'o') || (ch == 'O')) { // letter O == zero + component = component*16; + } + else if ((ch >= '0') && (ch <= '9')) { component = component*16 + (ch - '0'); } else { // "ch&7" handles lower and uppercase hex alphabetics @@ -61,7 +64,9 @@ static PRBool HexToRGB(const char* aColorSpec, PRBool aStrict, nscolor* aResult) char ch = aColorSpec[i]; if (((ch >= '0') && (ch <= '9')) || ((ch >= 'a') && (ch <= 'f')) || - ((ch >= 'A') && (ch <= 'F'))) { + ((ch >= 'A') && (ch <= 'F')) || + ((! aStrict) && + ((ch == 'o') || (ch == 'O')))) { // Nav let Oh's == zeros, egads // Legal character continue; }