diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-02-26 21:40:08 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-02-26 21:40:08 (GMT) |
commit | f68692a3c2b006ef1ba5ed4cd3fc4cccb403f146 (patch) | |
tree | e2dd893b5ab88d69cb2f661e01e606da3e8077e2 /xlib | |
parent | 89d3bc66f278682038bcc292038874949f5bca90 (diff) | |
parent | 4e98790eef8c37e8e16734574cc9c2c9b564892b (diff) | |
download | tk-f68692a3c2b006ef1ba5ed4cd3fc4cccb403f146.zip tk-f68692a3c2b006ef1ba5ed4cd3fc4cccb403f146.tar.gz tk-f68692a3c2b006ef1ba5ed4cd3fc4cccb403f146.tar.bz2 |
Provide fallback for _strtoi64
Diffstat (limited to 'xlib')
-rw-r--r-- | xlib/xcolors.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/xlib/xcolors.c b/xlib/xcolors.c index 0f3085c..3a48faa 100644 --- a/xlib/xcolors.c +++ b/xlib/xcolors.c @@ -13,13 +13,6 @@ #include "tkInt.h" /* - * This value will be set to the number of colors in the color table - * the first time it is needed. - */ - -static int numXColors = 0; - -/* * Forward declarations for functions used only in this file. */ @@ -789,7 +782,6 @@ static const XColorEntry xColors[] = { { "yellow3", 205, 205, 0 }, { "yellow4", 139, 139, 0 }, { "YellowGreen", 154, 205, 50 }, - { NULL, 0, 0, 0 } }; /* @@ -818,23 +810,11 @@ FindColor( int l, u, r, i = 0; /* - * Count the number of elements in the color array if we haven't done so - * yet. - */ - - if (numXColors == 0) { - const XColorEntry *ePtr; - for (ePtr = xColors; ePtr->name != NULL; ePtr++) { - numXColors++; - } - } - - /* * Perform a binary search on the sorted array of colors. */ l = 0; - u = numXColors - 1; + u = sizeof(xColors)/sizeof(xColors[0]) - 1; while (l <= u) { i = (l + u) / 2; r = strcasecmp(name, xColors[i].name); @@ -871,6 +851,35 @@ FindColor( *---------------------------------------------------------------------- */ +#ifdef __WIN32__ +# ifdef NO_STRTOI64 +/* This version only handles hex-strings without 0x prefix */ +static __int64 +_strtoi64(const char *spec, char **p, int base) +{ + __int64 result = 0; + char c; + while ((c = *spec)) { + if ((c >= '0') && (c <= '9')) { + c -= '0'; + } else if ((c >= 'A') && (c <= 'F')) { + c += (10 - 'A'); + } else if ((c >= 'a') && (c <= 'f')) { + c += (10 - 'a'); + } else { + break; + } + result = (result << 4) + c; + ++spec; + } + *p = (char *) spec; + return result; +} +# endif +#else +# define _strtoi64 strtoll +#endif + Status XParseColor( Display *display, |