summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-12-01 16:05:17 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-12-01 16:05:17 (GMT)
commit2156b8f27a1daba1ff6be50810e837283b9ec589 (patch)
treeac6c93ac33c779c84f5ea9fab7278394fdabb0e0 /unix
parent20c0cdf51c6a9cb24182ba805ea2f0f1e87e0a24 (diff)
downloadtk-2156b8f27a1daba1ff6be50810e837283b9ec589.zip
tk-2156b8f27a1daba1ff6be50810e837283b9ec589.tar.gz
tk-2156b8f27a1daba1ff6be50810e837283b9ec589.tar.bz2
In tkUnixFont, make sure that the utf-to-ucs2 encoder clamps at 0xFFFF. Use more uppercase hex-values where appropriate.
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixColor.c10
-rw-r--r--unix/tkUnixFont.c21
-rw-r--r--unix/tkUnixMenu.c2
-rw-r--r--unix/tkUnixRFont.c2
4 files changed, 19 insertions, 16 deletions
diff --git a/unix/tkUnixColor.c b/unix/tkUnixColor.c
index 512b20c..96e8937 100644
--- a/unix/tkUnixColor.c
+++ b/unix/tkUnixColor.c
@@ -136,17 +136,17 @@ TkpGetColor(
if (*name != '#') {
XColor screen;
- if (((*name - 'A') & 0xdf) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
- if (!((name[0] - 'G') & 0xdf) && !((name[1] - 'R') & 0xdf)
- && !((name[2] - 'A') & 0xdb) && !((name[3] - 'Y') & 0xdf)
+ if (((*name - 'A') & 0xDF) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
+ if (!((name[0] - 'G') & 0xDF) && !((name[1] - 'R') & 0xDF)
+ && !((name[2] - 'A') & 0xDB) && !((name[3] - 'Y') & 0xDF)
&& !name[4]) {
name = "#808080808080";
goto gotWebColor;
} else {
- const char *p = tkWebColors[((*name - 'A') & 0x1f)];
+ const char *p = tkWebColors[((*name - 'A') & 0x1F)];
if (p) {
const char *q = name;
- while (!((*p - *(++q)) & 0xdf)) {
+ while (!((*p - *(++q)) & 0xDF)) {
if (!*p++) {
name = p;
goto gotWebColor;
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 3893a0a..d95527b 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -415,15 +415,15 @@ ControlUtfProc(
dst += 2;
} else if ((size_t)ch < 256) {
dst[1] = 'x';
- dst[2] = hexChars[(ch >> 4) & 0xf];
- dst[3] = hexChars[ch & 0xf];
+ dst[2] = hexChars[(ch >> 4) & 0xF];
+ dst[3] = hexChars[ch & 0xF];
dst += 4;
} else if ((size_t)ch < 0x10000) {
dst[1] = 'u';
- dst[2] = hexChars[(ch >> 12) & 0xf];
- dst[3] = hexChars[(ch >> 8) & 0xf];
- dst[4] = hexChars[(ch >> 4) & 0xf];
- dst[5] = hexChars[ch & 0xf];
+ dst[2] = hexChars[(ch >> 12) & 0xF];
+ dst[3] = hexChars[(ch >> 8) & 0xF];
+ dst[4] = hexChars[(ch >> 4) & 0xF];
+ dst[5] = hexChars[ch & 0xF];
dst += 6;
} else {
/* TODO we can do better here */
@@ -610,13 +610,16 @@ UtfToUcs2beProc(
break;
}
src += TkUtfToUniChar(src, &ch);
+ if (ch > 0xFFFF) {
+ ch = 0xFFFD;
+ }
/*
* Ensure big-endianness (store big bits first).
*/
- *dst++ = (char)(ch >> 8);
- *dst++ = (char)ch;
+ *dst++ = (char)((ch >> 8) & 0xFF);
+ *dst++ = (char)(ch & 0xFF);
}
*srcReadPtr = src - srcStart;
*dstWrotePtr = dst - dstStart;
@@ -1977,7 +1980,7 @@ FindSubFontForChar(
Tcl_DString ds;
if (ch < 0 || ch > 0x30000) {
- ch = 0xfffd;
+ ch = 0xFFFD;
}
for (i = 0; i < fontPtr->numSubFonts; i++) {
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index 909276a..f7e1860 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -1111,7 +1111,7 @@ TkpComputeMenubarGeometry(
maxWindowWidth = Tk_Width(menuPtr->tkwin);
if (maxWindowWidth == 1) {
- maxWindowWidth = 0x7ffffff;
+ maxWindowWidth = 0x7FFFFFF;
}
currentRowHeight = 0;
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 31b28c5..f2bef2b 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -832,7 +832,7 @@ LookUpColor(Display *display, /* Display to lookup colors on */
fontPtr->colors[last].color.color.red = xcolor.red;
fontPtr->colors[last].color.color.green = xcolor.green;
fontPtr->colors[last].color.color.blue = xcolor.blue;
- fontPtr->colors[last].color.color.alpha = 0xffff;
+ fontPtr->colors[last].color.color.alpha = 0xFFFF;
fontPtr->colors[last].color.pixel = pixel;
/*