summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rwxr-xr-xwin/configure54
-rw-r--r--win/configure.in14
-rw-r--r--xlib/xcolors.c120
4 files changed, 132 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index b0e8ecc..3a10b58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-02-26 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * xlib/xcolors.c: Provide fallback for _strtoi64
+ * win/configure.in: Detect whether _strtoi64 is available
+ * win/configure: (regenerated)
+
2012-02-15 Jan Nijtmans <nijtmans@users.sf.net>
* xlib/xcolors.c: [Bug 3486474]: Inconsistent color scaling
diff --git a/win/configure b/win/configure
index 211b35c..2dc6186 100755
--- a/win/configure
+++ b/win/configure
@@ -1748,15 +1748,53 @@ fi
+#-------------------------------------------
+# Check for _strtoi64
+#-------------------------------------------
+
+echo $ac_n "checking availability of _strtoi64""... $ac_c" 1>&6
+echo "configure:1757: checking availability of _strtoi64" >&5
+if eval "test \"`echo '$''{'tcl_have_strtoi64'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ cat > conftest.$ac_ext <<EOF
+#line 1763 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+int main() {
+_strtoi64(0,0,0)
+; return 0; }
+EOF
+if { (eval echo configure:1770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ tcl_have_strtoi64=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ tcl_have_strtoi64=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$tcl_have_strtoi64" 1>&6
+if test $tcl_have_strtoi64 = no; then
+ cat >> confdefs.h <<\EOF
+#define NO_STRTOI64 1
+EOF
+
+fi
+
#--------------------------------------------------------------------
-# Set the default compiler switches based on the --enable-symbols
+# Set the default compiler switches based on the --enable-symbols
# option. This macro depends on C flags, and should be called
# after SC_CONFIG_CFLAGS macro is called.
#--------------------------------------------------------------------
echo $ac_n "checking for build with symbols""... $ac_c" 1>&6
-echo "configure:1760: checking for build with symbols" >&5
+echo "configure:1798: checking for build with symbols" >&5
# Check whether --enable-symbols or --disable-symbols was given.
if test "${enable_symbols+set}" = set; then
enableval="$enable_symbols"
@@ -1817,7 +1855,7 @@ TK_DBGX=${DBGX}
echo $ac_n "checking whether to embed manifest""... $ac_c" 1>&6
-echo "configure:1821: checking whether to embed manifest" >&5
+echo "configure:1859: checking whether to embed manifest" >&5
# Check whether --enable-embedded-manifest or --disable-embedded-manifest was given.
if test "${enable_embedded_manifest+set}" = set; then
enableval="$enable_embedded_manifest"
@@ -1834,7 +1872,7 @@ fi
-a "$GCC" != "yes" ; then
# Add the magic to embed the manifest into the dll/exe
cat > conftest.$ac_ext <<EOF
-#line 1838 "configure"
+#line 1876 "configure"
#include "confdefs.h"
#if defined(_MSC_VER) && _MSC_VER >= 1400
@@ -1871,7 +1909,7 @@ rm -f conftest*
echo $ac_n "checking the location of tclConfig.sh""... $ac_c" 1>&6
-echo "configure:1875: checking the location of tclConfig.sh" >&5
+echo "configure:1913: checking the location of tclConfig.sh" >&5
if test -d ../../tcl8.4$TK_PATCH_LEVEL/win; then
TCL_BIN_DIR_DEFAULT=../../tcl8.4$TK_PATCH_LEVEL/win
@@ -1899,7 +1937,7 @@ fi
echo $ac_n "checking for existence of $TCL_BIN_DIR/tclConfig.sh""... $ac_c" 1>&6
-echo "configure:1903: checking for existence of $TCL_BIN_DIR/tclConfig.sh" >&5
+echo "configure:1941: checking for existence of $TCL_BIN_DIR/tclConfig.sh" >&5
if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
echo "$ac_t""loading" 1>&6
@@ -1952,14 +1990,14 @@ echo "configure:1903: checking for existence of $TCL_BIN_DIR/tclConfig.sh" >&5
echo $ac_n "checking for tclsh in Tcl build directory""... $ac_c" 1>&6
-echo "configure:1956: checking for tclsh in Tcl build directory" >&5
+echo "configure:1994: checking for tclsh in Tcl build directory" >&5
BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}
echo "$ac_t""$BUILD_TCLSH" 1>&6
echo $ac_n "checking for tclsh""... $ac_c" 1>&6
-echo "configure:1963: checking for tclsh" >&5
+echo "configure:2001: checking for tclsh" >&5
if eval "test \"`echo '$''{'ac_cv_path_tclsh'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
diff --git a/win/configure.in b/win/configure.in
index f7b0f33..f6f71ca 100644
--- a/win/configure.in
+++ b/win/configure.in
@@ -110,8 +110,20 @@ SC_CONFIG_CFLAGS
AC_CHECK_HEADER(errno.h, , MAN2TCLFLAGS="-DNO_ERRNO_H")
AC_SUBST(MAN2TCLFLAGS)
+#-------------------------------------------
+# Check for _strtoi64
+#-------------------------------------------
+
+AC_CACHE_CHECK([availability of _strtoi64], tcl_have_strtoi64, [
+ AC_TRY_LINK([#include <stdlib.h>],
+ [_strtoi64(0,0,0)],
+ tcl_have_strtoi64=yes, tcl_have_strtoi64=no)])
+if test $tcl_have_strtoi64 = no; then
+ AC_DEFINE(NO_STRTOI64, 1, [Is _strtoi64 function available?])
+fi
+
#--------------------------------------------------------------------
-# Set the default compiler switches based on the --enable-symbols
+# Set the default compiler switches based on the --enable-symbols
# option. This macro depends on C flags, and should be called
# after SC_CONFIG_CFLAGS macro is called.
#--------------------------------------------------------------------
diff --git a/xlib/xcolors.c b/xlib/xcolors.c
index 7e88b2a..3a48faa 100644
--- a/xlib/xcolors.c
+++ b/xlib/xcolors.c
@@ -1,31 +1,35 @@
-/*
+/*
* xcolors.c --
*
- * This file contains the routines used to map from X color
- * names to RGB and pixel values.
+ * This file contains the routines used to map from X color names to RGB
+ * and pixel values.
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include <tkInt.h>
+#include "tkInt.h"
/*
+ * Forward declarations for functions used only in this file.
+ */
+
+static int FindColor(const char *name, XColor *colorPtr);
+
+/*
* Define an array that defines the mapping from color names to RGB values.
- * Note that this array must be kept sorted alphabetically so that the
- * binary search used in XParseColor will succeed.
+ * Note that this array must be kept sorted alphabetically so that the binary
+ * search used in XParseColor will succeed.
*/
typedef struct {
- char *name;
- unsigned char red;
- unsigned char green;
- unsigned char blue;
+ const char *name;
+ unsigned char red, green, blue;
} XColorEntry;
-static XColorEntry xColors[] = {
+static const XColorEntry xColors[] = {
{ "alice blue", 240, 248, 255 },
{ "AliceBlue", 240, 248, 255 },
{ "antique white", 250, 235, 215 },
@@ -778,34 +782,19 @@ static XColorEntry xColors[] = {
{ "yellow3", 205, 205, 0 },
{ "yellow4", 139, 139, 0 },
{ "YellowGreen", 154, 205, 50 },
- { NULL, 0, 0, 0 }
};
-
-
-/*
- * 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.
- */
-
-static int FindColor _ANSI_ARGS_((const char *name, XColor *colorPtr));
/*
*----------------------------------------------------------------------
*
* FindColor --
*
- * This routine finds the color entry that corresponds to the
- * specified color.
+ * This routine finds the color entry that corresponds to the specified
+ * color.
*
* Results:
- * Returns non-zero on success. The RGB values of the XColor
- * will be initialized to the proper values on success.
+ * Returns non-zero on success. The RGB values of the XColor will be
+ * initialized to the proper values on success.
*
* Side effects:
* None.
@@ -814,30 +803,18 @@ static int FindColor _ANSI_ARGS_((const char *name, XColor *colorPtr));
*/
static int
-FindColor(name, colorPtr)
- const char *name;
- XColor *colorPtr;
+FindColor(
+ const char *name,
+ XColor *colorPtr)
{
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) {
- 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);
@@ -874,12 +851,41 @@ FindColor(name, colorPtr)
*----------------------------------------------------------------------
*/
+#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, map, spec, colorPtr)
- Display *display;
- Colormap map;
- const char* spec;
- XColor *colorPtr;
+XParseColor(
+ Display *display,
+ Colormap map,
+ const char *spec,
+ XColor *colorPtr)
{
if (spec[0] == '#') {
char *p;
@@ -919,3 +925,11 @@ XParseColor(display, map, spec, colorPtr)
colorPtr->pad = 0;
return 1;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */