diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/cr-rgb.c | 48 | ||||
-rw-r--r-- | src/cr-tknzr.c | 11 |
3 files changed, 38 insertions, 26 deletions
@@ -1,5 +1,10 @@ 2004-02-29 Dodji Seketeli <dodji@gnome.org> + * src/cr-rgb.c,src/cr-tknzr.c: remove the usage of '...' in switch/case statements + as this is not portable across c89 compilers. + +2004-02-29 Dodji Seketeli <dodji@gnome.org> + * src/cr-rgb.c: (cr_rgb_set): fixed a stupid bug here. diff --git a/src/cr-rgb.c b/src/cr-rgb.c index 011c653..d3d0590 100644 --- a/src/cr-rgb.c +++ b/src/cr-rgb.c @@ -392,23 +392,23 @@ cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar * a_hex) { for (i = 0 ;i < 3 ; i++) { - switch (a_hex[i]) + if (a_hex[i] >= '0' && a_hex[i] <= '9') { - case '0' ... '9': colors[i] = a_hex[i] - '0'; colors[i] = (colors[i] << 4) | colors[i] ; - break ; - - case 'a' ... 'z': + } + else if (a_hex[i] >= 'a' && a_hex[i] <= 'z') + { colors[i] = 10 + a_hex[i] - 'a'; colors[i] = (colors[i] << 4) | colors[i] ; - break ; - - case 'A' ... 'Z': + } + else if (a_hex[i] >= 'A' && a_hex[i] <= 'Z') + { colors[i] = 10 + a_hex[i] - 'A'; colors[i] = (colors[i] << 4) | colors[i] ; - break ; - default: + } + else + { status = CR_UNKNOWN_TYPE_ERROR ; } } @@ -416,31 +416,29 @@ cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar * a_hex) else if (strlen (a_hex) == 6) { for (i = 0 ; i < 6 ; i++) - { - - switch (a_hex[i]) + { + if (a_hex[i] >='0' && a_hex[i] <= '9') { - case '0' ... '9': colors[i/2] <<= 4 ; colors[i/2] |= a_hex[i] - '0'; status = CR_OK ; - break ; - - case 'a' ... 'z': + } + else if (a_hex[i] >= 'a' && a_hex[i] <= 'z') + { colors[i/2] <<= 4 ; colors[i/2] |= 10 + a_hex[i] - 'a'; status = CR_OK ; - break ; - - case 'A' ... 'Z': + } + else if (a_hex[i] >= 'A' && a_hex[i] <= 'Z') + { colors[i/2] <<= 4 ; colors[i/2] |= 10 + a_hex[i] - 'A'; - status = CR_OK ; - break ; - - default: + status = CR_OK ; + } + else + { status = CR_UNKNOWN_TYPE_ERROR ; - } + } } } else diff --git a/src/cr-tknzr.c b/src/cr-tknzr.c index 830f35e..2b9e06f 100644 --- a/src/cr-tknzr.c +++ b/src/cr-tknzr.c @@ -2507,7 +2507,16 @@ cr_tknzr_get_next_token (CRTknzr *a_this, CRToken **a_tk) } break ; - case '0' ... '9': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': case '.': { CRNum *num = NULL ; |