summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-06-28 15:56:40 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-06-28 15:56:40 (GMT)
commitaaff6a472281e7010de68713b74d4c35a6d1db20 (patch)
treebfcf50f5547299491675e70a312c7f9ce12f68d9 /generic
parente8c84a297a502e5e9e366fe2dcaef0d81e66e6c2 (diff)
parent51e8e55cf0e7c6b845a26e90f1ec563a14b60ff6 (diff)
downloadtk-aaff6a472281e7010de68713b74d4c35a6d1db20.zip
tk-aaff6a472281e7010de68713b74d4c35a6d1db20.tar.gz
tk-aaff6a472281e7010de68713b74d4c35a6d1db20.tar.bz2
Merge trunk
Diffstat (limited to 'generic')
-rw-r--r--generic/tkBind.c68
-rw-r--r--generic/tkCanvPs.c2
-rw-r--r--generic/tkCanvas.c4
-rw-r--r--generic/tkEntry.c2
-rw-r--r--generic/tkFileFilter.h8
-rw-r--r--generic/tkFont.h8
-rw-r--r--generic/tkImgGIF.c13
-rw-r--r--generic/tkImgPNG.c30
-rw-r--r--generic/tkImgPhoto.c46
-rw-r--r--generic/tkInt.h8
-rw-r--r--generic/tkListbox.c4
-rw-r--r--generic/tkMain.c8
-rw-r--r--generic/tkMenu.c2
-rw-r--r--generic/tkText.c4
-rw-r--r--generic/tkTextDisp.c4
-rw-r--r--generic/tkWindow.c2
16 files changed, 158 insertions, 55 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c
index e8827b3..8ffcc1d 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -59,7 +59,9 @@
/*
* In old implementation (the one that used an event ring), <Double-1> and <1><1> were
- * equivalent sequences. However it is logical to give <Double-1> higher precedence.
+ * equivalent sequences. However it is logical to give <Double-1> higher precedence
+ * since it is more specific. Indeed <Double-1> includes time and space requirements,
+ * which is not the case for <1><1>.
* This is achieved by setting PREFER_MOST_SPECIALIZED_EVENT to 1.
*/
@@ -854,6 +856,20 @@ CountSpecialized(
return sndCount - fstCount;
}
+int
+IsKeyEventType(
+ unsigned eventType)
+{
+ return eventType == KeyPress || eventType == KeyRelease;
+}
+
+int
+IsButtonEventType(
+ unsigned eventType)
+{
+ return eventType == ButtonPress || eventType == ButtonRelease;
+}
+
static int
MatchEventNearby(
const XEvent *lhs, /* previous button event */
@@ -861,7 +877,7 @@ MatchEventNearby(
{
assert(lhs);
assert(rhs);
- assert(lhs->type == ButtonPress || lhs->type == ButtonRelease);
+ assert(IsButtonEventType(lhs->type));
assert(lhs->type == rhs->type);
/* assert: lhs->xbutton.time <= rhs->xbutton.time */
@@ -873,16 +889,16 @@ MatchEventNearby(
static int
MatchEventRepeat(
- const XEvent *lhs, /* previous key event */
- const XEvent *rhs) /* current key event */
+ const XKeyEvent *lhs, /* previous key event */
+ const XKeyEvent *rhs) /* current key event */
{
assert(lhs);
assert(rhs);
- assert(lhs->type == KeyPress || lhs->type == KeyRelease);
+ assert(IsKeyEventType(lhs->type));
assert(lhs->type == rhs->type);
- /* assert: lhs->xkey.time <= rhs->xkey.time */
- return TestNearbyTime(rhs->xkey.time, lhs->xkey.time);
+ /* assert: lhs->time <= rhs->time */
+ return lhs->keycode == rhs->keycode && TestNearbyTime(lhs->time, rhs->time);
}
static void
@@ -2213,7 +2229,7 @@ Tk_BindEvent(
* Ignore the event completely if it is an Enter, Leave, FocusIn, or
* FocusOut event with detail NotifyInferior. The reason for ignoring
* these events is that we don't want transitions between a window and its
- * children to visible to bindings on the parent: this would cause
+ * children to be visible to bindings on the parent: this would cause
* problems for mega-widgets, since the internal structure of a
* mega-widget isn't supposed to be visible to people watching the parent.
*
@@ -2297,7 +2313,7 @@ Tk_BindEvent(
switch (eventPtr->type) {
case KeyPress:
case KeyRelease:
- if (MatchEventRepeat(&curEvent->xev, eventPtr)) {
+ if (MatchEventRepeat(&curEvent->xev.xkey, &eventPtr->xkey)) {
if (curEvent->xev.xkey.keycode == eventPtr->xkey.keycode) {
++curEvent->countDetailed;
} else {
@@ -2521,13 +2537,13 @@ Tk_BindEvent(
switch (patPtr->eventType) {
case ButtonPress:
case ButtonRelease:
- if (curEvent->xev.type == KeyPress || curEvent->xev.type == KeyRelease) {
+ if (IsKeyEventType(curEvent->xev.type)) {
RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
}
break;
case KeyPress:
case KeyRelease:
- if (curEvent->xev.type == ButtonPress || curEvent->xev.type == ButtonRelease) {
+ if (IsButtonEventType(curEvent->xev.type)) {
RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
}
break;
@@ -2786,6 +2802,7 @@ MatchPatterns(
PatSeq *bestPhysPtr;
ModMask bestModMask;
const PSModMaskArr *bestModMaskArr = NULL;
+ int i, isModKeyOnly = 0;
assert(dispPtr);
assert(bindPtr);
@@ -2800,6 +2817,26 @@ MatchPatterns(
bestPhysPtr = NULL;
window = curEvent->xev.xany.window;
+ /*
+ * Modifier key events interlaced between patterns parts of a
+ * sequence shall not prevent a sequence from ultimately
+ * matching. Example: when trying to trigger <a><Control-c>
+ * from the keyboard, the sequence of events actually seen is
+ * <a> then <Control_L> (possibly repeating if the key is hold
+ * down), and finally <Control-c>. At the time <Control_L> is
+ * seen, we shall keep the <a><Control-c> pattern sequence in
+ * the promotion list, otherwise it is impossible to trigger
+ * it from the keyboard. See bug [16ef161925].
+ */
+ if (IsKeyEventType(curEvent->xev.type)) {
+ for (i = 0; i < dispPtr->numModKeyCodes; ++i) {
+ if (dispPtr->modKeyCodes[i] == curEvent->xev.xkey.keycode) {
+ isModKeyOnly = 1;
+ break;
+ }
+ }
+ }
+
for (psEntry = PSList_First(psList); psEntry; psEntry = PSList_Next(psEntry)) {
if (patIndex == 0 || psEntry->window == window) {
PatSeq* psPtr = psEntry->psPtr;
@@ -2814,6 +2851,12 @@ MatchPatterns(
: VirtPatIsBound(bindPtr, psPtr, object, physPtrPtr)) {
TkPattern *patPtr = psPtr->pats + patIndex;
+ /* ignore modifier key events, and KeyRelease events if the current event
+ * is of a different type (e.g. a Button event)
+ */
+ psEntry->keepIt = isModKeyOnly || \
+ ((patPtr->eventType != (unsigned) curEvent->xev.type) && curEvent->xev.type == KeyRelease);
+
if (patPtr->eventType == (unsigned) curEvent->xev.type
&& (curEvent->xev.type != CreateNotify
|| curEvent->xev.xcreatewindow.parent == window)
@@ -2828,8 +2871,9 @@ MatchPatterns(
ModMask curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask);
psEntry->expired = 1; /* remove it from promotion list */
+ psEntry->keepIt = 0; /* don't keep matching patterns */
- if ((modMask & ~curModMask) == 0) {
+ if (IsSubsetOf(modMask, curModMask)) {
unsigned count = patPtr->info ? curEvent->countDetailed : curEvent->countAny;
if (patIndex < PSModMaskArr_Size(psEntry->lastModMaskArr)) {
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index 7b51122..2d075e0 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -192,7 +192,7 @@ TkCanvPostscriptCmd(
* such.
*/
- result = Tcl_EvalEx(interp, "::tk::ensure_psenc_is_loaded", -1, 0);
+ result = Tcl_EvalEx(interp, "::tk::ensure_psenc_is_loaded", -1, TCL_EVAL_GLOBAL);
if (result != TCL_OK) {
return result;
}
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 89e7f3f..193d877 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -5881,7 +5881,7 @@ CanvasUpdateScrollbars(
Tcl_DStringAppend(&buf, xScrollCmd, -1);
Tcl_DStringAppend(&buf, " ", -1);
Tcl_DStringAppend(&buf, Tcl_GetString(fractions), -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
@@ -5899,7 +5899,7 @@ CanvasUpdateScrollbars(
Tcl_DStringAppend(&buf, yScrollCmd, -1);
Tcl_DStringAppend(&buf, " ", -1);
Tcl_DStringAppend(&buf, Tcl_GetString(fractions), -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index a6e7a32..5f39b89 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -3098,7 +3098,7 @@ EntryUpdateScrollbar(
Tcl_DStringAppend(&buf, firstStr, TCL_INDEX_NONE);
Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
Tcl_DStringAppend(&buf, lastStr, TCL_INDEX_NONE);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, 0);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
diff --git a/generic/tkFileFilter.h b/generic/tkFileFilter.h
index 131e423..22db9e8 100644
--- a/generic/tkFileFilter.h
+++ b/generic/tkFileFilter.h
@@ -13,6 +13,10 @@
#ifndef _TK_FILE_FILTER
#define _TK_FILE_FILTER
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define OSType long
typedef struct GlobPattern {
@@ -75,4 +79,8 @@ MODULE_SCOPE int TkGetFileFilters(Tcl_Interp *interp,
FileFilterList *flistPtr, Tcl_Obj *valuePtr,
int isWindows);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _TK_FILE_FILTER */
diff --git a/generic/tkFont.h b/generic/tkFont.h
index 50f79d2..ceabee3 100644
--- a/generic/tkFont.h
+++ b/generic/tkFont.h
@@ -14,6 +14,10 @@
#ifndef _TKFONT
#define _TKFONT
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* The following structure keeps track of the attributes of a font. It can be
* used to keep track of either the desired attributes or the actual
@@ -221,4 +225,8 @@ MODULE_SCOPE void TkpGetFontFamilies(Tcl_Interp *interp,
Tk_Window tkwin);
MODULE_SCOPE TkFont * TkpGetNativeFont(Tk_Window tkwin, const char *name);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _TKFONT */
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 93a891e..79e778b 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -358,13 +358,13 @@ static int
FileMatchGIF(
TCL_UNUSED(Tcl_Interp *), /* not used */
Tcl_Channel chan, /* The image file, open for reading. */
- TCL_UNUSED(const char *), /* The name of the image file. */
- TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */
+ TCL_UNUSED(const char *), /* The name of the image file. */
+ TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */
TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
* here if the file is a valid raw GIF file. */
- TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
+ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
{
GIFImageConfig gifConf;
@@ -844,7 +844,7 @@ static int
StringMatchGIF(
TCL_UNUSED(Tcl_Interp *), /* not used */
Tcl_Obj *dataObj, /* the object containing the image data */
- TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */
+ TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */
TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
int *widthPtr, /* where to put the string width */
int *heightPtr, /* where to put the string height */
@@ -1181,7 +1181,8 @@ ReadImage(
Tcl_Channel chan,
int len, int rows,
unsigned char cmap[MAXCOLORMAPSIZE][4],
- TCL_UNUSED(int), TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
int interlace,
int transparent)
{
@@ -1859,7 +1860,7 @@ CommonWriteGIF(
Tcl_Interp *interp,
ClientData handle,
WriteBytesFunc *writeProc,
- TCL_UNUSED(Tcl_Obj *),
+ TCL_UNUSED(Tcl_Obj *),
Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c
index 1476de4..316e58b 100644
--- a/generic/tkImgPNG.c
+++ b/generic/tkImgPNG.c
@@ -2818,7 +2818,7 @@ FileMatchPNG(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
Tcl_Channel chan, /* The image file, open for reading. */
TCL_UNUSED(const char *), /* The name of the image file. */
- TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */
+ TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */
TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
@@ -2864,16 +2864,18 @@ static int
FileReadPNG(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
Tcl_Channel chan, /* The image file, open for reading. */
- TCL_UNUSED(const char *), /* The name of the image file. */
+ TCL_UNUSED(const char *), /* The name of the image file. */
Tcl_Obj *fmtObj, /* User-specified format object, or NULL. */
- TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
Tk_PhotoHandle imageHandle, /* The photo image to write into. */
int destX, int destY, /* Coordinates of top-left pixel in photo
* image to be written to. */
- TCL_UNUSED(int), TCL_UNUSED(int), /* Dimensions of block of photo image to be
+ TCL_UNUSED(int), /* Dimensions of block of photo image to be
* written to. */
- TCL_UNUSED(int), TCL_UNUSED(int), /* Coordinates of top-left pixel to be used in
+ TCL_UNUSED(int),
+ TCL_UNUSED(int), /* Coordinates of top-left pixel to be used in
* image being read. */
+ TCL_UNUSED(int),
Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */
{
PNGImage png;
@@ -2923,11 +2925,11 @@ static int
StringMatchPNG(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
Tcl_Obj *pObjData, /* the object containing the image data */
- TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */
- TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
+ TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
int *widthPtr, /* where to put the string width */
int *heightPtr, /* where to put the string height */
- TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
+ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
{
PNGImage png;
int match = 0;
@@ -2969,11 +2971,13 @@ StringReadPNG(
Tcl_Interp *interp, /* interpreter for reporting errors in */
Tcl_Obj *pObjData, /* object containing the image */
Tcl_Obj *fmtObj, /* format object, or NULL */
- TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
Tk_PhotoHandle imageHandle, /* the image to write this data into */
int destX, int destY, /* The rectangular region of the */
- TCL_UNUSED(int), TCL_UNUSED(int), /* image to copy */
- TCL_UNUSED(int), TCL_UNUSED(int),
+ TCL_UNUSED(int), /* image to copy */
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */
{
PNGImage png;
@@ -3729,7 +3733,7 @@ static int
FileWritePNG(
Tcl_Interp *interp,
const char *filename,
- TCL_UNUSED(Tcl_Obj *),
+ TCL_UNUSED(Tcl_Obj *),
Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
@@ -3800,7 +3804,7 @@ FileWritePNG(
static int
StringWritePNG(
Tcl_Interp *interp,
- TCL_UNUSED(Tcl_Obj *),
+ TCL_UNUSED(Tcl_Obj *),
Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 91b7ec1..8a73fed 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -389,7 +389,7 @@ ImgPhotoCreate(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects for options (doesn't
* include image name or type). */
- TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */
+ TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */
Tk_ImageMaster master, /* Token for image, to be used by us in later
* callbacks. */
ClientData *clientDataPtr) /* Store manager's token for image here; it
@@ -3258,8 +3258,21 @@ Tk_PhotoPutBlock(
if (sourceBlock.pixelPtr >= masterPtr->pix32
&& sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
* masterPtr->height * 4) {
- sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(sourceBlock.height
- * sourceBlock.pitch);
+ /*
+ * Fix 5c51be6411: avoid reading
+ *
+ * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize)
+ *
+ * bytes past the end of masterPtr->pix32[] when
+ *
+ * blockPtr->pixelPtr > (masterPtr->pix32 +
+ * 4 * masterPtr->width * masterPtr->height -
+ * sourceBlock.height * sourceBlock.pitch)
+ */
+ unsigned int cpyLen = (sourceBlock.height - 1) * sourceBlock.pitch +
+ sourceBlock.width * sourceBlock.pixelSize;
+
+ sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(cpyLen);
if (sourceBlock.pixelPtr == NULL) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -3269,8 +3282,7 @@ Tk_PhotoPutBlock(
return TCL_ERROR;
}
memToFree = sourceBlock.pixelPtr;
- memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
- * sourceBlock.pitch);
+ memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, cpyLen);
}
@@ -3692,8 +3704,21 @@ Tk_PhotoPutZoomedBlock(
if (sourceBlock.pixelPtr >= masterPtr->pix32
&& sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
* masterPtr->height * 4) {
- sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(sourceBlock.height
- * sourceBlock.pitch);
+ /*
+ * Fix 5c51be6411: avoid reading
+ *
+ * (sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize)
+ *
+ * bytes past the end of masterPtr->pix32[] when
+ *
+ * blockPtr->pixelPtr > (masterPtr->pix32 +
+ * 4 * masterPtr->width * masterPtr->height -
+ * sourceBlock.height * sourceBlock.pitch)
+ */
+ unsigned int cpyLen = (sourceBlock.height - 1) * sourceBlock.pitch +
+ sourceBlock.width * sourceBlock.pixelSize;
+
+ sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(cpyLen);
if (sourceBlock.pixelPtr == NULL) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -3703,8 +3728,7 @@ Tk_PhotoPutZoomedBlock(
return TCL_ERROR;
}
memToFree = sourceBlock.pixelPtr;
- memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
- * sourceBlock.pitch);
+ memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, cpyLen);
}
xEnd = x + width;
@@ -4487,11 +4511,11 @@ static int
ImgPhotoPostscript(
ClientData clientData, /* Handle for the photo image. */
Tcl_Interp *interp, /* Interpreter. */
- TCL_UNUSED(Tk_Window), /* (unused) */
+ TCL_UNUSED(Tk_Window), /* (unused) */
Tk_PostscriptInfo psInfo, /* Postscript info. */
int x, int y, /* First pixel to output. */
int width, int height, /* Width and height of area. */
- TCL_UNUSED(int)) /* (unused) */
+ TCL_UNUSED(int)) /* (unused) */
{
Tk_PhotoImageBlock block;
diff --git a/generic/tkInt.h b/generic/tkInt.h
index c3fe72f..c9bfe3d 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1111,6 +1111,10 @@ void Tcl_Panic(const char *, ...) __attribute__((analyzer_noreturn));
#include "tkIntDecls.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Themed widget set init function:
*/
@@ -1440,6 +1444,10 @@ MODULE_SCOPE int TkOldTestInit(Tcl_Interp *interp);
MODULE_SCOPE int TkplatformtestInit(Tcl_Interp *interp);
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _TKINT */
/*
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index 99a5be3..e738155 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -3335,7 +3335,7 @@ ListboxUpdateVScrollbar(
Tcl_DStringAppend(&buf, firstStr, -1);
Tcl_DStringAppend(&buf, " ", -1);
Tcl_DStringAppend(&buf, lastStr, -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -3407,7 +3407,7 @@ ListboxUpdateHScrollbar(
Tcl_DStringAppend(&buf, firstStr, -1);
Tcl_DStringAppend(&buf, " ", -1);
Tcl_DStringAppend(&buf, lastStr, -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
diff --git a/generic/tkMain.c b/generic/tkMain.c
index 879a7c0..b2fa845 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -32,6 +32,9 @@ static const char DEFAULT_PRIMARY_PROMPT[] = "% ";
* to strcmp here.
*/
#ifdef _WIN32
+#ifdef __cplusplus
+extern "C" {
+#endif
/* Little hack to eliminate the need for "tclInt.h" here:
Just copy a small portion of TclIntPlatStubs, just
enough to make it work. See [600b72bfbc] */
@@ -41,7 +44,10 @@ typedef struct TclIntPlatStubs {
void (*dummy[16]) (void); /* dummy entries 0-15, not used */
int (*tclpIsAtty) (int fd); /* 16 */
} TclIntPlatStubs;
-const TclIntPlatStubs *tclIntPlatStubsPtr;
+extern const TclIntPlatStubs *tclIntPlatStubsPtr;
+#ifdef __cplusplus
+}
+#endif
# include "tkWinInt.h"
#else
# define TCHAR char
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 3b50daa..776c7e8 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -1027,7 +1027,7 @@ TkInvokeMenu(
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, "tk::TearOffMenu ", -1);
Tcl_DStringAppend(&ds, Tk_PathName(menuPtr->tkwin), -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&ds), -1, 0);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&ds), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&ds);
} else if ((mePtr->type == CHECK_BUTTON_ENTRY)
&& (mePtr->namePtr != NULL)) {
diff --git a/generic/tkText.c b/generic/tkText.c
index 39be0b7..119f229 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -5084,7 +5084,7 @@ DumpSegment(
Tcl_DStringAppend(&buf, Tcl_GetString(command), -1);
Tcl_DStringAppend(&buf, " ", -1);
Tcl_DStringAppend(&buf, Tcl_GetString(tuple), -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -6787,7 +6787,7 @@ GetLineStartEnd(
(void)dummy;
(void)tkwin;
- if ((internalOffset == TCL_INDEX_NONE) || (recordPtr == NULL)) {
+ if (linePtr == NULL) {
return Tcl_NewObj();
}
return Tcl_NewWideIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 61b0df0..3aa83ee 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -6528,7 +6528,7 @@ GetXView(
Tcl_DStringAppend(&buf, textPtr->xScrollCmd, -1);
Tcl_DStringAppend(&buf, buf1, -1);
Tcl_DStringAppend(&buf, buf2, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -6813,7 +6813,7 @@ GetYView(
Tcl_DStringAppend(&buf, textPtr->yScrollCmd, -1);
Tcl_DStringAppend(&buf, buf1, -1);
Tcl_DStringAppend(&buf, buf2, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index aaa4a06..900a267 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -3339,7 +3339,7 @@ Initialize(
tcl_findLibrary tk $tk_version $tk_patchLevel tk.tcl TK_LIBRARY tk_library\n\
}\n\
}\n\
-tkInit", -1, 0);
+tkInit", -1, TCL_EVAL_GLOBAL);
}
if (code == TCL_OK) {
/*