Tk Source Code

Check-in [19eec190]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Provide fallback for _strtoi64
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-5-branch
Files: files | file ages | folders
SHA1: 19eec190b83f777c2d2b57aa96d2cbd1cb4f6a7f
User & Date: jan.nijtmans 2012-02-26 21:35:52
Context
2012-02-28
13:46
[Bug 3495198]: Corrected types of canvas bitmap options. check-in: 1b7382b2 user: dkf tags: core-8-5-branch
2012-02-26
21:40
Provide fallback for _strtoi64 check-in: e9ffec09 user: jan.nijtmans tags: trunk
21:35
Provide fallback for _strtoi64 check-in: 19eec190 user: jan.nijtmans tags: core-8-5-branch
21:23
Provide fallback for _strtoi64 check-in: 2f32e4e8 user: jan.nijtmans tags: core-8-4-branch
2012-02-21
05:41
_Xconst -> CONST check-in: 52840c0c user: jan.nijtmans tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.







1
2
3
4
5
6
7






2012-02-15  Jan Nijtmans  <[email protected]>

	* xlib/xcolors.c: [Bug 3486474]: Inconsistent color scaling
	* generic/tkColor.c: new internal function TkParseColor
	* generic/tkInt.h:
	* generic/tk*.c:   Change XParseColor() to TkParseColor() everywhere.

>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2012-02-26  Jan Nijtmans  <[email protected]>

	* xlib/xcolors.c: Provide fallback for _strtoi64
	* win/configure.in: Detect whether _strtoi64 is available
	* win/configure: (regenerated)

2012-02-15  Jan Nijtmans  <[email protected]>

	* xlib/xcolors.c: [Bug 3486474]: Inconsistent color scaling
	* generic/tkColor.c: new internal function TkParseColor
	* generic/tkInt.h:
	* generic/tk*.c:   Change XParseColor() to TkParseColor() everywhere.

Changes to win/configure.

4023
4024
4025
4026
4027
4028
4029



































































4030
4031
4032
4033
4034
4035
4036
  :
else
  MAN2TCLFLAGS="-DNO_ERRNO_H"
fi







































































#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

echo "$as_me:$LINENO: checking for uxtheme.h" >&5
echo $ECHO_N "checking for uxtheme.h... $ECHO_C" >&6







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
  :
else
  MAN2TCLFLAGS="-DNO_ERRNO_H"
fi




#-------------------------------------------
#     Check for _strtoi64
#-------------------------------------------

echo "$as_me:$LINENO: checking availability of _strtoi64" >&5
echo $ECHO_N "checking availability of _strtoi64... $ECHO_C" >&6
if test "${tcl_have_strtoi64+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

    cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h.  */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h.  */
#include <stdlib.h>
int
main ()
{
_strtoi64(0,0,0)
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
  (eval $ac_link) 2>conftest.er1
  ac_status=$?
  grep -v '^ *+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); } &&
	 { ac_try='test -z "$ac_c_werror_flag"
			 || test ! -s conftest.err'
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); }; } &&
	 { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  tcl_have_strtoi64=yes
else
  echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

tcl_have_strtoi64=no
fi
rm -f conftest.err conftest.$ac_objext \
      conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $tcl_have_strtoi64" >&5
echo "${ECHO_T}$tcl_have_strtoi64" >&6
if test $tcl_have_strtoi64 = no; then

cat >>confdefs.h <<\_ACEOF
#define NO_STRTOI64 1
_ACEOF

fi

#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

echo "$as_me:$LINENO: checking for uxtheme.h" >&5
echo $ECHO_N "checking for uxtheme.h... $ECHO_C" >&6

Changes to win/configure.in.

110
111
112
113
114
115
116












117
118
119
120
121
122
123

#--------------------------------------------------------------------
# man2tcl needs this so that it can use errno.h
#--------------------------------------------------------------------

AC_CHECK_HEADER(errno.h, , MAN2TCLFLAGS="-DNO_ERRNO_H")
AC_SUBST(MAN2TCLFLAGS)













#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

AC_CHECK_HEADER([uxtheme.h], [AC_DEFINE(HAVE_UXTHEME_H)],
	[AC_MSG_NOTICE([xpnative theme will be unavailable])],







>
>
>
>
>
>
>
>
>
>
>
>







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

#--------------------------------------------------------------------
# man2tcl needs this so that it can use errno.h
#--------------------------------------------------------------------

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

#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

AC_CHECK_HEADER([uxtheme.h], [AC_DEFINE(HAVE_UXTHEME_H)],
	[AC_MSG_NOTICE([xpnative theme will be unavailable])],

Changes to xlib/xcolors.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * xcolors.c --
 *
 *	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.
 */

#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.
 */

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.
 */

typedef struct {
    char *name;
    unsigned char red, green, blue;
} XColorEntry;

static XColorEntry xColors[] = {
     { "alice blue", 240, 248, 255 },
     { "AliceBlue", 240, 248, 255 },
     { "antique white", 250, 235, 215 },
     { "AntiqueWhite", 250, 235, 215 },
     { "AntiqueWhite1", 255, 239, 219 },
     { "AntiqueWhite2", 238, 223, 204 },
     { "AntiqueWhite3", 205, 192, 176 },












|
<
<
<
<
<
<
<














|



|







1
2
3
4
5
6
7
8
9
10
11
12
13







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * xcolors.c --
 *
 *	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.
 */

#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.
 */

typedef struct {
    const char *name;
    unsigned char red, green, blue;
} XColorEntry;

static const XColorEntry xColors[] = {
     { "alice blue", 240, 248, 255 },
     { "AliceBlue", 240, 248, 255 },
     { "antique white", 250, 235, 215 },
     { "AntiqueWhite", 250, 235, 215 },
     { "AntiqueWhite1", 255, 239, 219 },
     { "AntiqueWhite2", 238, 223, 204 },
     { "AntiqueWhite3", 205, 192, 176 },
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
     { "yellow", 255, 255, 0 },
     { "yellow green", 154, 205, 50 },
     { "yellow1", 255, 255, 0 },
     { "yellow2", 238, 238, 0 },
     { "yellow3", 205, 205, 0 },
     { "yellow4", 139, 139, 0 },
     { "YellowGreen", 154, 205, 50 },
     { NULL, 0, 0, 0 }
};

/*
 *----------------------------------------------------------------------
 *
 * FindColor --
 *







<







778
779
780
781
782
783
784

785
786
787
788
789
790
791
     { "yellow", 255, 255, 0 },
     { "yellow green", 154, 205, 50 },
     { "yellow1", 255, 255, 0 },
     { "yellow2", 238, 238, 0 },
     { "yellow3", 205, 205, 0 },
     { "yellow4", 139, 139, 0 },
     { "YellowGreen", 154, 205, 50 },

};

/*
 *----------------------------------------------------------------------
 *
 * FindColor --
 *
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
static int
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;
    while (l <= u) {
	i = (l + u) / 2;
	r = strcasecmp(name, xColors[i].name);
	if (r == 0) {
	    break;
	} else if (r < 0) {
	    u = i-1;







<
<
<
<
<
<
<
<
<
<
<
<





|







805
806
807
808
809
810
811












812
813
814
815
816
817
818
819
820
821
822
823
824
static int
FindColor(
    const char *name,
    XColor *colorPtr)
{
    int l, u, r, i = 0;













    /*
     * Perform a binary search on the sorted array of colors.
     */

    l = 0;
    u = sizeof(xColors)/sizeof(xColors[0]) - 1;
    while (l <= u) {
	i = (l + u) / 2;
	r = strcasecmp(name, xColors[i].name);
	if (r == 0) {
	    break;
	} else if (r < 0) {
	    u = i-1;
866
867
868
869
870
871
872





























873
874
875
876
877
878
879
 *	Returns non-zero on success.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */






























Status
XParseColor(
    Display *display,
    Colormap map,
    const char *spec,
    XColor *colorPtr)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
 *	Returns non-zero on success.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

#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,
    Colormap map,
    const char *spec,
    XColor *colorPtr)