From e9fc9ea2605337871420f15bb402842cf075e530 Mon Sep 17 00:00:00 2001 From: oehhar Date: Fri, 14 Jun 2024 10:38:21 +0000 Subject: Ticket [865af0148c] GIF errornously accepted if colormap segment is truncated --- generic/tkImgGIF.c | 8 +++++++- tests/corruptTruncatedColormap.gif | Bin 0 -> 10 bytes tests/imgPhoto.test | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/corruptTruncatedColormap.gif diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 3467bd5..62fc935 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -466,7 +466,13 @@ FileReadGIF( */ if (Fread(gifConfPtr, buf, 1, 3, chan) != 3) { - return TCL_OK; + /* + * Bug [865af0148c]: 3 bytes should be there, but data ended before + */ + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "GIF file truncated", -1)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "TRUNCATED", NULL); + return TCL_ERROR; } bitPixel = 2 << (buf[0] & 0x07); diff --git a/tests/corruptTruncatedColormap.gif b/tests/corruptTruncatedColormap.gif new file mode 100644 index 0000000..21d4add Binary files /dev/null and b/tests/corruptTruncatedColormap.gif differ diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index 1d3b6e5..ae1f473 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -1349,6 +1349,23 @@ test imgPhoto-18.6 {Reject truncated GIF (file)} -setup { } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map} +test imgPhoto-18.6.1 {Reject truncated GIF in Colormap - ticket 865af0148c - file} -setup { + set fileName [file join [file dirname [info script]] corruptTruncatedColormap.gif] +} -body { + image create photo gif1 -file $fileName +} -cleanup { + catch {image delete gif1} +} -returnCodes error -result {GIF file truncated} +test imgPhoto-28.6.2 {Reject truncated GIF in Colormap - ticket 865af0148c - data} -setup { + set fileName [file join [file dirname [info script]] corruptTruncatedColormap.gif] + set h [open $fileName rb] + set d [read $h] + close $h +} -body { + image create photo gif1 -data $d +} -cleanup { + catch {image delete gif1} +} -returnCodes error -result {GIF file truncated} test imgPhoto-18.7 {Reject corrupted GIF (> 4Gb) (binary string)} -constraints { nonPortable } -setup { -- cgit v0.12 From 5c3cbffb42a4122814d4636be170b8ea8eb59467 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 14 Jun 2024 18:26:57 +0000 Subject: Fix test number and indentation. --- tests/imgPhoto.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index a7046ca..34107cc 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -1311,11 +1311,11 @@ test imgPhoto-18.6.1 {Reject truncated GIF in Colormap - ticket 865af0148c - fil } -cleanup { catch {image delete gif1} } -returnCodes error -result {GIF file truncated} -test imgPhoto-28.6.2 {Reject truncated GIF in Colormap - ticket 865af0148c - data} -setup { +test imgPhoto-18.6.2 {Reject truncated GIF in Colormap - ticket 865af0148c - data} -setup { set fileName [file join [file dirname [info script]] corruptTruncatedColormap.gif] - set h [open $fileName rb] - set d [read $h] - close $h + set h [open $fileName rb] + set d [read $h] + close $h } -body { image create photo gif1 -data $d } -cleanup { -- cgit v0.12 From 3951487aa1587e2fedee41985f6b60f0e9bb1e77 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 16 Jun 2024 12:05:36 +0000 Subject: Remove TK_OPTION_NULL_OK usage in tkPlace.c, doesn't belong there. Some indenting and varname consistancy --- generic/tkPack.c | 8 ++--- generic/tkPanedWindow.c | 14 ++++---- generic/tkPlace.c | 92 ++++++++++++++++++++++++------------------------- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/generic/tkPack.c b/generic/tkPack.c index 8dc6284..a7ed8b2 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -1451,7 +1451,7 @@ PackStructureProc( Tcl_DoWhenIdle(ArrangePacking, packPtr); } if ((packPtr->containerPtr != NULL) - && (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width)) { + && (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width)) { if (!(packPtr->containerPtr->flags & REQUESTED_REPACK)) { packPtr->doubleBw = 2*Tk_Changes(packPtr->tkwin)->border_width; packPtr->containerPtr->flags |= REQUESTED_REPACK; @@ -1476,7 +1476,7 @@ PackStructureProc( if (packPtr->tkwin != NULL) { TkDisplay *dispPtr = ((TkWindow *) packPtr->tkwin)->dispPtr; - Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable, + Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable, packPtr->tkwin)); } @@ -1828,8 +1828,8 @@ ConfigureContent( container = (TkWindow *)TkGetContainer(container)) { if (container == (TkWindow *)content) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't put \"%s\" inside \"%s\": would cause management loop", - Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); + "can't put \"%s\" inside \"%s\": would cause management loop", + Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); return TCL_ERROR; } diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index d7f2d45..25f87bc 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -86,7 +86,7 @@ typedef struct Pane { * the x dimension. */ int pady; /* Additional padding requested for pane, in * the y dimension. */ - Tcl_Obj *widthPtr, *heightPtr; + Tcl_Obj *widthObj, *heightObj; /* Tcl_Obj rep's of pane width/height, to * allow for null values. */ int width; /* Pane width. */ @@ -125,8 +125,8 @@ typedef struct PanedWindow { Tk_3DBorder background; /* Background color. */ int borderWidth; /* Value of -borderwidth option. */ int relief; /* 3D border effect (TK_RELIEF_RAISED, etc) */ - Tcl_Obj *widthPtr; /* Tcl_Obj rep for width. */ - Tcl_Obj *heightPtr; /* Tcl_Obj rep for height. */ + Tcl_Obj *widthObj; /* Tcl_Obj rep for width. */ + Tcl_Obj *heightObj; /* Tcl_Obj rep for height. */ int width, height; /* Width and height of the widget. */ enum orient orient; /* Orientation of the widget. */ Tk_Cursor cursor; /* Current cursor for window, or None. */ @@ -291,7 +291,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr), offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-height", "height", "Height", - DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightPtr), + DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightObj), offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY}, {TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize", DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE, @@ -326,7 +326,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle), 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-width", "width", "Width", - DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthPtr), + DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthObj), offsetof(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; @@ -339,7 +339,7 @@ static const Tk_OptionSpec paneOptionSpecs[] = { DEF_PANEDWINDOW_PANE_BEFORE, TCL_INDEX_NONE, offsetof(Pane, before), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-height", NULL, NULL, - DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Pane, heightPtr), + DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Pane, heightObj), offsetof(Pane, height), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY}, @@ -356,7 +356,7 @@ static const Tk_OptionSpec paneOptionSpecs[] = { DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch), TK_OPTION_ENUM_VAR, stretchStrings, 0}, {TK_OPTION_PIXELS, "-width", NULL, NULL, - DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Pane, widthPtr), + DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Pane, widthObj), offsetof(Pane, width), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 774ad79..f60861a 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -54,19 +54,19 @@ typedef struct Content { */ int x, y; /* X and Y pixel coordinates for tkwin. */ - Tcl_Obj *xPtr, *yPtr; /* Tcl_Obj rep's of x, y coords, to keep pixel + Tcl_Obj *xObj, *yObj; /* Tcl_Obj rep's of x, y coords, to keep pixel * spec. information. */ double relX, relY; /* X and Y coordinates relative to size of * container. */ int width, height; /* Absolute dimensions for tkwin. */ - Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel + Tcl_Obj *widthObj; /* Tcl_Obj rep of width, to keep pixel * spec. */ - Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel + Tcl_Obj *heightObj; /* Tcl_Obj rep of height, to keep pixel * spec. */ double relWidth, relHeight; /* Dimensions for tkwin relative to size of * container. */ - Tcl_Obj *relWidthPtr; - Tcl_Obj *relHeightPtr; + Tcl_Obj *relWidthObj; + Tcl_Obj *relHeightObj; Tk_Anchor anchor; /* Which point on tkwin is placed at the given * position. */ BorderMode borderMode; /* How to treat borders of container window. */ @@ -80,29 +80,29 @@ typedef struct Content { static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", TCL_INDEX_NONE, - offsetof(Content, anchor), TK_OPTION_ENUM_VAR, 0, 0}, + offsetof(Content, anchor), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", TCL_INDEX_NONE, - offsetof(Content, borderMode), TK_OPTION_ENUM_VAR, borderModeStrings, 0}, - {TK_OPTION_PIXELS, "-height", NULL, NULL, "", offsetof(Content, heightPtr), - offsetof(Content, height), TK_OPTION_NULL_OK, 0, 0}, + offsetof(Content, borderMode), TK_OPTION_ENUM_VAR, borderModeStrings, 0}, + {TK_OPTION_PIXELS, "-height", NULL, NULL, NULL, offsetof(Content, heightObj), + offsetof(Content, height), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_WINDOW, "-in", NULL, NULL, "", TCL_INDEX_NONE, offsetof(Content, inTkwin), - 0, 0, IN_MASK}, - {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, "", - offsetof(Content, relHeightPtr), offsetof(Content, relHeight), - TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, "", - offsetof(Content, relWidthPtr), offsetof(Content, relWidth), - TK_OPTION_NULL_OK, 0, 0}, + 0, 0, IN_MASK}, + {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, NULL, + offsetof(Content, relHeightObj), offsetof(Content, relHeight), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, NULL, + offsetof(Content, relWidthObj), offsetof(Content, relWidth), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0.0", TCL_INDEX_NONE, - offsetof(Content, relX), 0, 0, 0}, + offsetof(Content, relX), 0, 0, 0}, {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0.0", TCL_INDEX_NONE, - offsetof(Content, relY), 0, 0, 0}, - {TK_OPTION_PIXELS, "-width", NULL, NULL, "", offsetof(Content, widthPtr), - offsetof(Content, width), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Content, xPtr), - offsetof(Content, x), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Content, yPtr), - offsetof(Content, y), TK_OPTION_NULL_OK, 0, 0}, + offsetof(Content, relY), 0, 0, 0}, + {TK_OPTION_PIXELS, "-width", NULL, NULL, NULL, offsetof(Content, widthObj), + offsetof(Content, width), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Content, xObj), + offsetof(Content, x), 0, 0, 0}, + {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Content, yObj), + offsetof(Content, y), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; @@ -686,8 +686,8 @@ ConfigureContent( container = (TkWindow *)TkGetContainer(container)) { if (container == (TkWindow *)contentPtr->tkwin) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't put \"%s\" inside \"%s\": would cause management loop", - Tk_PathName(contentPtr->tkwin), Tk_PathName(win))); + "can't put \"%s\" inside \"%s\": would cause management loop", + Tk_PathName(contentPtr->tkwin), Tk_PathName(win))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); goto error; } @@ -794,23 +794,23 @@ PlaceInfoCommand( Tcl_AppendPrintfToObj(infoObj, "-x %d -relx %.4g -y %d -rely %.4g", contentPtr->x, contentPtr->relX, contentPtr->y, contentPtr->relY); - if (contentPtr->widthPtr) { + if (contentPtr->widthObj) { Tcl_AppendPrintfToObj(infoObj, " -width %d", contentPtr->width); } else { Tcl_AppendToObj(infoObj, " -width {}", TCL_INDEX_NONE); } - if (contentPtr->relWidthPtr) { + if (contentPtr->relWidthObj) { Tcl_AppendPrintfToObj(infoObj, " -relwidth %.4g", contentPtr->relWidth); } else { Tcl_AppendToObj(infoObj, " -relwidth {}", TCL_INDEX_NONE); } - if (contentPtr->heightPtr) { + if (contentPtr->heightObj) { Tcl_AppendPrintfToObj(infoObj, " -height %d", contentPtr->height); } else { Tcl_AppendToObj(infoObj, " -height {}", TCL_INDEX_NONE); } - if (contentPtr->relHeightPtr) { + if (contentPtr->relHeightObj) { Tcl_AppendPrintfToObj(infoObj, " -relheight %.4g", contentPtr->relHeight); } else { @@ -906,12 +906,12 @@ RecomputePlacement( x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5)); y1 = contentPtr->y + containerY + (contentPtr->relY*containerHeight); y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5)); - if ((contentPtr->widthPtr) || contentPtr->relWidthPtr) { + if ((contentPtr->widthObj) || contentPtr->relWidthObj) { width = 0; - if (contentPtr->widthPtr) { + if (contentPtr->widthObj) { width += contentPtr->width; } - if (contentPtr->relWidthPtr) { + if (contentPtr->relWidthObj) { /* * The code below is a bit tricky. In order to round correctly * when both relX and relWidth are specified, compute the @@ -928,12 +928,12 @@ RecomputePlacement( width = Tk_ReqWidth(contentPtr->tkwin) + 2*Tk_Changes(contentPtr->tkwin)->border_width; } - if (contentPtr->heightPtr || contentPtr->relHeightPtr) { + if (contentPtr->heightObj || contentPtr->relHeightObj) { height = 0; - if (contentPtr->heightPtr) { + if (contentPtr->heightObj) { height += contentPtr->height; } - if (contentPtr->relHeightPtr) { + if (contentPtr->relHeightObj) { /* * See note above for rounding errors in width computation. */ @@ -1015,9 +1015,9 @@ RecomputePlacement( || (height != Tk_Height(contentPtr->tkwin))) { Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height); } - if (abort) { - break; - } + if (abort) { + break; + } /* * Don't map the content unless the container is mapped: the content will @@ -1184,14 +1184,14 @@ PlaceRequestProc( Content *contentPtr = (Content *)clientData; Container *containerPtr; - if ((contentPtr->widthPtr || contentPtr->relWidthPtr) - && (contentPtr->heightPtr || contentPtr->relHeightPtr)) { - /* - * Send a ConfigureNotify to indicate that the size change - * request was rejected. - */ + if ((contentPtr->widthObj || contentPtr->relWidthObj) + && (contentPtr->heightObj || contentPtr->relHeightObj)) { + /* + * Send a ConfigureNotify to indicate that the size change + * request was rejected. + */ - TkDoConfigureNotify((TkWindow *)(contentPtr->tkwin)); + TkDoConfigureNotify((TkWindow *)(contentPtr->tkwin)); return; } containerPtr = contentPtr->containerPtr; -- cgit v0.12 From 72fb10940a9941ab37ccffa22f56a4f4a044e1fe Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 16 Jun 2024 22:16:46 +0000 Subject: Implement TK_CONFIG_NULL_OK for TK_CONFIG_PIXELS. Needed for "-elementborderwidth" in tkScrollbar.c Make TK_OPTION_NULL_OK the same value as TCL_NULL_OK for Tcl 9, but keep binary compatibility. Fix some spacing --- generic/tk.h | 13 +++++++++++-- generic/tkCanvas.c | 2 +- generic/tkConfig.c | 10 +++++----- generic/tkEntry.c | 2 +- generic/tkOldConfig.c | 26 +++++++++++++++----------- generic/tkScrollbar.c | 2 +- generic/tkTextDisp.c | 2 +- macosx/tkMacOSXScale.c | 2 +- macosx/tkMacOSXScrlbr.c | 2 +- unix/tkUnixMenubu.c | 2 +- unix/tkUnixScale.c | 2 +- unix/tkUnixScrlbr.c | 2 +- 12 files changed, 40 insertions(+), 27 deletions(-) diff --git a/generic/tk.h b/generic/tk.h index e3c375c..d3f9141 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -237,8 +237,13 @@ typedef struct Tk_OptionSpec { * Tk_ConfigSpec structures, so be sure to coordinate any changes carefully. */ -#define TK_OPTION_NULL_OK (1 << 0) #define TK_OPTION_DONT_SET_DEFAULT (1 << 3) +#if TCL_MAJOR_VERSION > 8 +# define TK_OPTION_NULL_OK TCL_NULL_OK +#else +# define TK_OPTION_NULL_OK (1 << 0) +#endif +#define TK_OPTION_NEG_OK (1 << 6) /* For TK_OPTION_PIXELS only, so no conflict with TK_OPTION_VAR */ #define TK_OPTION_VAR(type) ((sizeof(type) < 2 * sizeof(int)) ? ((int)(sizeof(type)&(sizeof(int)-1))<<6) : (3<<6)) #define TK_OPTION_ENUM_VAR TK_OPTION_VAR(Tk_OptionType) @@ -428,13 +433,17 @@ typedef enum { * (internal-use-only flags are defined there). */ -#define TK_CONFIG_NULL_OK (1 << 0) #define TK_CONFIG_COLOR_ONLY (1 << 1) #define TK_CONFIG_MONO_ONLY (1 << 2) #define TK_CONFIG_DONT_SET_DEFAULT (1 << 3) #ifndef TK_NO_DEPRECATED # define TK_CONFIG_OPTION_SPECIFIED (1 << 4) #endif /* !TK_NO_DEPRECATED */ +#if TCL_MAJOR_VERSION > 8 +# define TK_CONFIG_NULL_OK TCL_NULL_OK +#else +# define TK_CONFIG_NULL_OK (1 << 0) +#endif #define TK_CONFIG_USER_BIT 0x100 #endif /* __NO_OLD_CONFIG */ diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 8713497..38a297d 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -3261,7 +3261,7 @@ DisplayCanvas( Tk_Height(tkwin) - 2*canvasPtr->highlightWidth, canvasPtr->borderWidth, canvasPtr->relief); } - if (canvasPtr->highlightWidth != 0) { + if (canvasPtr->highlightWidth > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(canvasPtr->highlightBgColorPtr, diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 7362831..bbbed91 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -625,7 +625,7 @@ DoObjConfig( } else { oldInternalPtr = (char *) &internal.internalForm; } - nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK)); + nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)); switch (optionPtr->specPtr->type) { case TK_OPTION_BOOLEAN: { int newBool; @@ -2130,7 +2130,7 @@ GetObjectForOption( } case TK_OPTION_INT: { Tcl_WideInt value; - int nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK)); + int nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)); if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_MASK) { if (sizeof(long) > sizeof(int)) { @@ -2151,7 +2151,7 @@ GetObjectForOption( break; } case TK_OPTION_INDEX: - if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK)) || *((int *) internalPtr) != INT_MIN) { + if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *) internalPtr) != INT_MIN) { if (*((int *) internalPtr) == INT_MIN) { objPtr = TkNewIndexObj(TCL_INDEX_NONE); } else if (*((int *) internalPtr) == INT_MAX) { @@ -2168,7 +2168,7 @@ GetObjectForOption( } break; case TK_OPTION_DOUBLE: - if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK)) || !isnan(*((double *) internalPtr))) { + if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || !isnan(*((double *) internalPtr))) { objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); } break; @@ -2299,7 +2299,7 @@ GetObjectForOption( break; } case TK_OPTION_PIXELS: - if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK)) || *((int *) internalPtr) != INT_MIN) { + if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *) internalPtr) != INT_MIN) { objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); } break; diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 477f359..7ee455e 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1316,7 +1316,7 @@ ConfigureEntry( Tk_SetInternalBorder(entryPtr->tkwin, entryPtr->borderWidth + entryPtr->highlightWidth); - if (entryPtr->highlightWidth <= 0) { + if (entryPtr->highlightWidth < 0) { entryPtr->highlightWidth = 0; } entryPtr->inset = entryPtr->highlightWidth diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 55765e2..eed7171 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -359,7 +359,7 @@ DoConfig( int nullValue; nullValue = 0; - if ((*value == 0) && (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK))) { + if ((*value == 0) && (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1))) { nullValue = 1; } @@ -370,17 +370,17 @@ DoConfig( ptr = (char *)widgRec + specPtr->offset; switch (specPtr->type) { case TK_CONFIG_BOOLEAN: - if (Tcl_GetBoolean(interp, value, (int *) ptr) != TCL_OK) { + if (Tcl_GetBoolean(interp, value, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_INT: - if (Tcl_GetInt(interp, value, (int *) ptr) != TCL_OK) { + if (Tcl_GetInt(interp, value, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_DOUBLE: - if (Tcl_GetDouble(interp, value, (double *) ptr) != TCL_OK) { + if (Tcl_GetDouble(interp, value, (double *)ptr) != TCL_OK) { return TCL_ERROR; } break; @@ -482,7 +482,7 @@ DoConfig( } case TK_CONFIG_RELIEF: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetRelief(interp, uid, (int *) ptr) != TCL_OK) { + if (Tk_GetRelief(interp, uid, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; @@ -523,24 +523,26 @@ DoConfig( break; case TK_CONFIG_CAP_STYLE: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetCapStyle(interp, uid, (int *) ptr) != TCL_OK) { + if (Tk_GetCapStyle(interp, uid, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_JOIN_STYLE: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetJoinStyle(interp, uid, (int *) ptr) != TCL_OK) { + if (Tk_GetJoinStyle(interp, uid, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_PIXELS: - if (Tk_GetPixels(interp, tkwin, value, (int *) ptr) + if (nullValue) { + *(int *)ptr = INT_MIN; + } if (Tk_GetPixels(interp, tkwin, value, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_MM: - if (Tk_GetScreenMM(interp, tkwin, value, (double*)ptr) != TCL_OK) { + if (Tk_GetScreenMM(interp, tkwin, value, (double *)ptr) != TCL_OK) { return TCL_ERROR; } break; @@ -873,8 +875,10 @@ FormatConfigValue( result = Tk_NameOfJoinStyle(*((int *)ptr)); break; case TK_CONFIG_PIXELS: - snprintf(buffer, 200, "%d", *((int *)ptr)); - result = buffer; + if ((*(int *)ptr != INT_MIN) || !(specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1))) { + snprintf(buffer, 200, "%d", *((int *)ptr)); + result = buffer; + } break; case TK_CONFIG_MM: Tcl_PrintDouble(interp, *((double *)ptr), buffer); diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 04a4168..d91b603 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -57,7 +57,7 @@ static const Tk_ConfigSpec configSpecs[] = { DEF_SCROLLBAR_CURSOR, offsetof(TkScrollbar, cursor), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_PIXELS, "-elementborderwidth", "elementBorderWidth", "BorderWidth", DEF_SCROLLBAR_EL_BORDER_WIDTH, - offsetof(TkScrollbar, elementBorderWidth), 0, NULL}, + offsetof(TkScrollbar, elementBorderWidth), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_SCROLLBAR_HIGHLIGHT_BG, offsetof(TkScrollbar, highlightBgColorPtr), 0, NULL}, diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cc4a12c..6afd08e 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4414,7 +4414,7 @@ DisplayText( Tk_Width(textPtr->tkwin) - 2*textPtr->highlightWidth, Tk_Height(textPtr->tkwin) - 2*textPtr->highlightWidth, textPtr->borderWidth, textPtr->relief); - if (textPtr->highlightWidth != 0) { + if (textPtr->highlightWidth > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(textPtr->highlightBgColorPtr, diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index a66bba7..96a61b8 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -197,7 +197,7 @@ TkpDisplayScale( * vertical scales: border and traversal highlight. */ - if (scalePtr->highlightWidth != 0) { + if (scalePtr->highlightWidth > 0) { GC gc = Tk_GCForColor(scalePtr->highlightColorPtr, Tk_WindowId(tkwin)); Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index ec54d42..500a5cf 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -284,7 +284,7 @@ TkpDisplayScrollbar( * Draw a 3D rectangle to provide a base for the native scrollbar. */ - if (scrollPtr->highlightWidth != 0) { + if (scrollPtr->highlightWidth > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, (Pixmap) macWin); diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index dd67639..c9a33aa 100644 --- a/unix/tkUnixMenubu.c +++ b/unix/tkUnixMenubu.c @@ -279,7 +279,7 @@ TkpDisplayMenuButton( Tk_Height(tkwin) - 2*mbPtr->highlightWidth, mbPtr->borderWidth, mbPtr->relief); } - if (mbPtr->highlightWidth != 0) { + if (mbPtr->highlightWidth > 0) { if (mbPtr->flags & GOT_FOCUS) { gc = Tk_GCForColor(mbPtr->highlightColorPtr, pixmap); } else { diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index 6e73268..8f4d23b 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -632,7 +632,7 @@ TkpDisplayScale( Tk_Height(tkwin) - 2*scalePtr->highlightWidth, scalePtr->borderWidth, scalePtr->relief); } - if (scalePtr->highlightWidth != 0) { + if (scalePtr->highlightWidth > 0) { GC gc; if (scalePtr->flags & GOT_FOCUS) { diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c index 9660718..001b2e9 100644 --- a/unix/tkUnixScrlbr.c +++ b/unix/tkUnixScrlbr.c @@ -128,7 +128,7 @@ TkpDisplayScrollbar( pixmap = Tk_GetPixmap(scrollPtr->display, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); - if (scrollPtr->highlightWidth != 0) { + if (scrollPtr->highlightWidth > 0) { GC gc; if (scrollPtr->flags & GOT_FOCUS) { -- cgit v0.12 From b2546a703d6229bb48a68232ca6864f70a9e3e37 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 16 Jun 2024 22:29:14 +0000 Subject: Something wrong with previous commit --- generic/tkOldConfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index eed7171..23259ec 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -536,7 +536,7 @@ DoConfig( case TK_CONFIG_PIXELS: if (nullValue) { *(int *)ptr = INT_MIN; - } if (Tk_GetPixels(interp, tkwin, value, (int *)ptr) + } else if (Tk_GetPixels(interp, tkwin, value, (int *)ptr) != TCL_OK) { return TCL_ERROR; } -- cgit v0.12 From c7155c6da59086934fe2e1567f5c3b0335a5b693 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 16 Jun 2024 22:32:30 +0000 Subject: Unintentional change in tk.h --- generic/tk.h | 1 - 1 file changed, 1 deletion(-) diff --git a/generic/tk.h b/generic/tk.h index d3f9141..8401d14 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -243,7 +243,6 @@ typedef struct Tk_OptionSpec { #else # define TK_OPTION_NULL_OK (1 << 0) #endif -#define TK_OPTION_NEG_OK (1 << 6) /* For TK_OPTION_PIXELS only, so no conflict with TK_OPTION_VAR */ #define TK_OPTION_VAR(type) ((sizeof(type) < 2 * sizeof(int)) ? ((int)(sizeof(type)&(sizeof(int)-1))<<6) : (3<<6)) #define TK_OPTION_ENUM_VAR TK_OPTION_VAR(Tk_OptionType) -- cgit v0.12 From b8b8de56e290dd3d82585190651360c843542e7b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 17 Jun 2024 10:06:34 +0000 Subject: Change the -elementborderwidth default (for scrollbar) from -1 to {}. Move sanity check from platform-code to generic. See TIP #577. --- doc/scrollbar.n | 4 ++-- generic/tkScrollbar.c | 8 +++++++- macosx/tkMacOSXDefault.h | 2 +- macosx/tkMacOSXScrlbr.c | 4 ++-- unix/tkUnixDefault.h | 2 +- unix/tkUnixScrlbr.c | 3 --- win/tkWinDefault.h | 2 +- win/tkWinScrlbr.c | 4 ---- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/doc/scrollbar.n b/doc/scrollbar.n index 0bbfb70..c5665be 100644 --- a/doc/scrollbar.n +++ b/doc/scrollbar.n @@ -42,8 +42,8 @@ as described in \fBSCROLLING COMMANDS\fR below. Specifies the width of borders drawn around the internal elements of the scrollbar (the two arrows and the slider). The value may have any of the forms acceptable to \fBTk_GetPixels\fR. -If this value is less than zero, the value of the \fB\-borderwidth\fR -option is used in its place. +If this value is the empth string (the default), the value of +the \fB\-borderwidth\fR option is used in its place. .OP \-width width Width Specifies the desired narrow dimension of the scrollbar window, not including 3-D border, if any. For vertical diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index b43e9e5..5f03fee 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -172,7 +172,7 @@ Tk_ScrollbarObjCmd( scrollPtr->highlightBgColorPtr = NULL; scrollPtr->highlightColorPtr = NULL; scrollPtr->inset = 0; - scrollPtr->elementBorderWidth = -1; + scrollPtr->elementBorderWidth = INT_MIN; scrollPtr->arrowLength = 0; scrollPtr->sliderFirst = 0; scrollPtr->sliderLast = 0; @@ -487,6 +487,12 @@ ConfigureScrollbar( } else { scrollPtr->commandSize = 0; } + if (scrollPtr->highlightWidth < 0) { + scrollPtr->highlightWidth = 0; + } + if (scrollPtr->elementBorderWidth < 0) { + scrollPtr->elementBorderWidth = INT_MIN; + } /* * Configure platform specific options. diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 6fc98e9..60430be 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -475,7 +475,7 @@ #define DEF_SCROLLBAR_BORDER_WIDTH "0" #define DEF_SCROLLBAR_COMMAND "" #define DEF_SCROLLBAR_CURSOR "" -#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1" +#define DEF_SCROLLBAR_EL_BORDER_WIDTH NULL #define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG #define DEF_SCROLLBAR_HIGHLIGHT NORMAL_FG #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0" diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 500a5cf..f5b25f1 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -649,8 +649,8 @@ UpdateControlValues( || height <= metrics.minHeight) { msPtr->info.enableState = kThemeTrackHideTrack; } else { - msPtr->info.enableState = kThemeTrackActive; - msPtr->info.attributes = + msPtr->info.enableState = kThemeTrackActive; + msPtr->info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost; } } diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index dfcf858..16fdcc6 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -448,7 +448,7 @@ #define DEF_SCROLLBAR_BORDER_WIDTH "1" #define DEF_SCROLLBAR_COMMAND "" #define DEF_SCROLLBAR_CURSOR "" -#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1" +#define DEF_SCROLLBAR_EL_BORDER_WIDTH NULL #define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG #define DEF_SCROLLBAR_HIGHLIGHT BLACK #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0" diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c index 001b2e9..65166e4 100644 --- a/unix/tkUnixScrlbr.c +++ b/unix/tkUnixScrlbr.c @@ -283,9 +283,6 @@ TkpComputeScrollbarGeometry( { int width, fieldLength; - if (scrollPtr->highlightWidth < 0) { - scrollPtr->highlightWidth = 0; - } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; width = (scrollPtr->vertical) ? Tk_Width(scrollPtr->tkwin) : Tk_Height(scrollPtr->tkwin); diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 5318f84..5af7877 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -450,7 +450,7 @@ #define DEF_SCROLLBAR_BORDER_WIDTH "0" #define DEF_SCROLLBAR_COMMAND "" #define DEF_SCROLLBAR_CURSOR "" -#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1" +#define DEF_SCROLLBAR_EL_BORDER_WIDTH NULL #define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG #define DEF_SCROLLBAR_HIGHLIGHT HIGHLIGHT #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0" diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 457b82f..a54deeb 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -394,10 +394,6 @@ TkpComputeScrollbarGeometry( * basic sanity checks to appease backwards compatibility. */ - if (scrollPtr->highlightWidth < 0) { - scrollPtr->highlightWidth = 0; - } - if (scrollPtr->vertical) { scrollPtr->arrowLength = vArrowHeight; fieldLength = Tk_Height(scrollPtr->tkwin); -- cgit v0.12 From a983245e41399dd76602e12f17bc3170de207680 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 17 Jun 2024 13:02:57 +0000 Subject: Move scrollbar sanity checks from platform-code to generic. Fix indenting in win/* files --- generic/tkScrollbar.c | 6 + macosx/tkMacOSXScrlbr.c | 4 +- unix/tkUnixScrlbr.c | 3 - win/nmakehlp.c | 12 +- win/tkWinClipboard.c | 8 +- win/tkWinDialog.c | 720 +++++++++++++++++++++--------------------- win/tkWinDraw.c | 24 +- win/tkWinEmbed.c | 10 +- win/tkWinGDI.c | 86 +++--- win/tkWinIco.c | 20 +- win/tkWinIco.h | 3 +- win/tkWinKey.c | 12 +- win/tkWinMenu.c | 38 +-- win/tkWinPointer.c | 6 +- win/tkWinScrlbr.c | 4 - win/tkWinSendCom.h | 6 +- win/tkWinSysTray.c | 806 ++++++++++++++++++++++++------------------------ win/tkWinTest.c | 58 ++-- win/tkWinX.c | 40 +-- 19 files changed, 932 insertions(+), 934 deletions(-) diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index d91b603..ec94418 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -545,6 +545,12 @@ ConfigureScrollbar( } else { scrollPtr->commandSize = 0; } + if (scrollPtr->highlightWidth < 0) { + scrollPtr->highlightWidth = 0; + } + if (scrollPtr->elementBorderWidth < 0) { + scrollPtr->elementBorderWidth = -1; + } /* * Configure platform specific options. diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 500a5cf..f5b25f1 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -649,8 +649,8 @@ UpdateControlValues( || height <= metrics.minHeight) { msPtr->info.enableState = kThemeTrackHideTrack; } else { - msPtr->info.enableState = kThemeTrackActive; - msPtr->info.attributes = + msPtr->info.enableState = kThemeTrackActive; + msPtr->info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost; } } diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c index 001b2e9..65166e4 100644 --- a/unix/tkUnixScrlbr.c +++ b/unix/tkUnixScrlbr.c @@ -283,9 +283,6 @@ TkpComputeScrollbarGeometry( { int width, fieldLength; - if (scrollPtr->highlightWidth < 0) { - scrollPtr->highlightWidth = 0; - } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; width = (scrollPtr->vertical) ? Tk_Width(scrollPtr->tkwin) : Tk_Height(scrollPtr->tkwin); diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 4d95662..36708c9 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -91,7 +91,7 @@ main( case 'c': if (argc != 3) { chars = snprintf(msg, sizeof(msg) - 1, - "usage: %s -c \n" + "usage: %s -c \n" "Tests for whether cl.exe supports an option\n" "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]); WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, @@ -319,11 +319,11 @@ CheckForCompilerFeature( */ return !(strstr(Out.buffer, "D4002") != NULL - || strstr(Err.buffer, "D4002") != NULL - || strstr(Out.buffer, "D9002") != NULL - || strstr(Err.buffer, "D9002") != NULL - || strstr(Out.buffer, "D2021") != NULL - || strstr(Err.buffer, "D2021") != NULL); + || strstr(Err.buffer, "D4002") != NULL + || strstr(Out.buffer, "D9002") != NULL + || strstr(Err.buffer, "D9002") != NULL + || strstr(Out.buffer, "D2021") != NULL + || strstr(Err.buffer, "D2021") != NULL); } static int diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 7de4338..f51bf8a 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -60,10 +60,10 @@ TkSelGetSelection( goto error; } if (!OpenClipboard(NULL)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "clipboard cannot be opened, another application grabbed it")); - Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", NULL); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "clipboard cannot be opened, another application grabbed it")); + Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", NULL); + return TCL_ERROR; } /* diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index bb0ae79..6ced04a 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -177,9 +177,9 @@ typedef struct OFNOpts { int mustExist; /* Used only for */ int forceXPStyle; /* XXX - Force XP style even on newer systems */ WCHAR file[TK_MULTI_MAX_PATH]; /* File name - XXX - fixed size because it was so - historically. Why not malloc'ed ? - */ + XXX - fixed size because it was so + historically. Why not malloc'ed ? + */ } OFNOpts; /* Define the operation for which option parsing is to be done. */ @@ -254,26 +254,26 @@ typedef struct IShellItemArrayVtbl BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IShellItemArray *, REFIID riid,void **ppvObject); + IShellItemArray *, REFIID riid,void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )(IShellItemArray *); ULONG ( STDMETHODCALLTYPE *Release )(IShellItemArray *); HRESULT ( STDMETHODCALLTYPE *BindToHandler )(IShellItemArray *, - IBindCtx *, REFGUID, REFIID, void **); + IBindCtx *, REFGUID, REFIID, void **); /* flags is actually is enum GETPROPERTYSTOREFLAGS */ HRESULT ( STDMETHODCALLTYPE *GetPropertyStore )( - IShellItemArray *, int, REFIID, void **); + IShellItemArray *, int, REFIID, void **); /* keyType actually REFPROPERTYKEY */ HRESULT ( STDMETHODCALLTYPE *GetPropertyDescriptionList )( - IShellItemArray *, void *, REFIID, void **); + IShellItemArray *, void *, REFIID, void **); HRESULT ( STDMETHODCALLTYPE *GetAttributes )(IShellItemArray *, - SIATTRIBFLAGS, SFGAOF, SFGAOF *); + SIATTRIBFLAGS, SFGAOF, SFGAOF *); HRESULT ( STDMETHODCALLTYPE *GetCount )( - IShellItemArray *, DWORD *); + IShellItemArray *, DWORD *); HRESULT ( STDMETHODCALLTYPE *GetItemAt )( - IShellItemArray *, DWORD, IShellItem **); + IShellItemArray *, DWORD, IShellItem **); /* ppenumShellItems actually (IEnumShellItems **) */ HRESULT ( STDMETHODCALLTYPE *EnumItems )( - IShellItemArray *, void **); + IShellItemArray *, void **); END_INTERFACE } IShellItemArrayVtbl; @@ -354,56 +354,56 @@ typedef struct IFileDialogVtbl BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IFileDialog *, REFIID, void **); + IFileDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileDialog *, - UINT, const TCLCOMDLG_FILTERSPEC *); + UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(IFileDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )(IFileDialog *, UINT *); /* XXX - Actually pfde is IFileDialogEvents* but we do not use this call and do not want to define IFileDialogEvents as that pulls in a whole bunch of other stuff. */ HRESULT ( STDMETHODCALLTYPE *Advise )( - IFileDialog *, void *, DWORD *); + IFileDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )(IFileDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( - IFileDialog *, FILEOPENDIALOGOPTIONS); + IFileDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( - IFileDialog *, FILEOPENDIALOGOPTIONS *); + IFileDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( - IFileDialog *, IShellItem *); + IFileDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( - IFileDialog *, IShellItem *); + IFileDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( - IFileDialog *, IShellItem **); + IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( - IFileDialog *, IShellItem **); + IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( - IFileDialog *, LPWSTR *); + IFileDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( - IFileDialog *, IShellItem **); + IFileDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( - IFileDialog *, IShellItem *, FDAP); + IFileDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( - IFileDialog *, LPCWSTR); + IFileDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( - IFileDialog *, REFGUID); + IFileDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( IFileDialog *); /* pFilter actually IShellItemFilter. But deprecated in Win7 AND we do not use it anyways. So define as void* */ HRESULT ( STDMETHODCALLTYPE *SetFilter )( - IFileDialog *, void *); + IFileDialog *, void *); END_INTERFACE } IFileDialogVtbl; @@ -418,67 +418,67 @@ typedef struct IFileSaveDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IFileSaveDialog *, REFIID, void **); + IFileSaveDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileSaveDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( - IFileSaveDialog *, HWND); + IFileSaveDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *, - UINT, const TCLCOMDLG_FILTERSPEC *); + UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( - IFileSaveDialog *, UINT); + IFileSaveDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( - IFileSaveDialog *, UINT *); + IFileSaveDialog *, UINT *); /* Actually pfde is IFileSaveDialogEvents* */ HRESULT ( STDMETHODCALLTYPE *Advise )( - IFileSaveDialog *, void *, DWORD *); + IFileSaveDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )( IFileSaveDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( - IFileSaveDialog *, FILEOPENDIALOGOPTIONS); + IFileSaveDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( - IFileSaveDialog *, FILEOPENDIALOGOPTIONS *); + IFileSaveDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( - IFileSaveDialog *, IShellItem *); + IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( - IFileSaveDialog *, IShellItem *); + IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( - IFileSaveDialog *, IShellItem **); + IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( - IFileSaveDialog *, IShellItem **); + IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( - IFileSaveDialog *, LPWSTR *); + IFileSaveDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( - IFileSaveDialog *, IShellItem **); + IFileSaveDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( - IFileSaveDialog *, IShellItem *, FDAP); + IFileSaveDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( - IFileSaveDialog *, LPCWSTR); + IFileSaveDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileSaveDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( - IFileSaveDialog *, REFGUID); + IFileSaveDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( IFileSaveDialog *); /* pFilter Actually IShellItemFilter* */ HRESULT ( STDMETHODCALLTYPE *SetFilter )( - IFileSaveDialog *, void *); + IFileSaveDialog *, void *); HRESULT ( STDMETHODCALLTYPE *SetSaveAsItem )( - IFileSaveDialog *, IShellItem *); + IFileSaveDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetProperties )( - IFileSaveDialog *, IPropertyStore *); + IFileSaveDialog *, IPropertyStore *); HRESULT ( STDMETHODCALLTYPE *SetCollectedProperties )( - IFileSaveDialog *, IPropertyDescriptionList *, BOOL); + IFileSaveDialog *, IPropertyDescriptionList *, BOOL); HRESULT ( STDMETHODCALLTYPE *GetProperties )( - IFileSaveDialog *, IPropertyStore **); + IFileSaveDialog *, IPropertyStore **); HRESULT ( STDMETHODCALLTYPE *ApplyProperties )( - IFileSaveDialog *, IShellItem *, IPropertyStore *, - HWND, IFileOperationProgressSink *); + IFileSaveDialog *, IShellItem *, IPropertyStore *, + HWND, IFileOperationProgressSink *); END_INTERFACE @@ -493,61 +493,61 @@ typedef struct IFileOpenDialogVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IFileOpenDialog *, REFIID, void **); + IFileOpenDialog *, REFIID, void **); ULONG ( STDMETHODCALLTYPE *AddRef )( IFileOpenDialog *); ULONG ( STDMETHODCALLTYPE *Release )( IFileOpenDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileOpenDialog *, HWND); HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileOpenDialog *, - UINT, const TCLCOMDLG_FILTERSPEC *); + UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( - IFileOpenDialog *, UINT); + IFileOpenDialog *, UINT); HRESULT ( STDMETHODCALLTYPE *GetFileTypeIndex )( - IFileOpenDialog *, UINT *); + IFileOpenDialog *, UINT *); /* Actually pfde is IFileDialogEvents* */ HRESULT ( STDMETHODCALLTYPE *Advise )( - IFileOpenDialog *, void *, DWORD *); + IFileOpenDialog *, void *, DWORD *); HRESULT ( STDMETHODCALLTYPE *Unadvise )( IFileOpenDialog *, DWORD); HRESULT ( STDMETHODCALLTYPE *SetOptions )( - IFileOpenDialog *, FILEOPENDIALOGOPTIONS); + IFileOpenDialog *, FILEOPENDIALOGOPTIONS); HRESULT ( STDMETHODCALLTYPE *GetOptions )( - IFileOpenDialog *, FILEOPENDIALOGOPTIONS *); + IFileOpenDialog *, FILEOPENDIALOGOPTIONS *); HRESULT ( STDMETHODCALLTYPE *SetDefaultFolder )( - IFileOpenDialog *, IShellItem *); + IFileOpenDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *SetFolder )( - IFileOpenDialog *, IShellItem *); + IFileOpenDialog *, IShellItem *); HRESULT ( STDMETHODCALLTYPE *GetFolder )( - IFileOpenDialog *, IShellItem **); + IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *GetCurrentSelection )( - IFileOpenDialog *, IShellItem **); + IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *SetFileName )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetFileName )( - IFileOpenDialog *, LPWSTR *); + IFileOpenDialog *, LPWSTR *); HRESULT ( STDMETHODCALLTYPE *SetTitle )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetOkButtonLabel )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *SetFileNameLabel )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *GetResult )( - IFileOpenDialog *, IShellItem **); + IFileOpenDialog *, IShellItem **); HRESULT ( STDMETHODCALLTYPE *AddPlace )( - IFileOpenDialog *, IShellItem *, FDAP); + IFileOpenDialog *, IShellItem *, FDAP); HRESULT ( STDMETHODCALLTYPE *SetDefaultExtension )( - IFileOpenDialog *, LPCWSTR); + IFileOpenDialog *, LPCWSTR); HRESULT ( STDMETHODCALLTYPE *Close )( IFileOpenDialog *, HRESULT); HRESULT ( STDMETHODCALLTYPE *SetClientGuid )( - IFileOpenDialog *, REFGUID); + IFileOpenDialog *, REFGUID); HRESULT ( STDMETHODCALLTYPE *ClearClientData )( - IFileOpenDialog *); + IFileOpenDialog *); HRESULT ( STDMETHODCALLTYPE *SetFilter )( - IFileOpenDialog *, - /* pFilter is actually IShellItemFilter */ - void *); + IFileOpenDialog *, + /* pFilter is actually IShellItemFilter */ + void *); HRESULT ( STDMETHODCALLTYPE *GetResults )( - IFileOpenDialog *, IShellItemArray **); + IFileOpenDialog *, IShellItemArray **); HRESULT ( STDMETHODCALLTYPE *GetSelectedItems )( - IFileOpenDialog *, IShellItemArray **); + IFileOpenDialog *, IShellItemArray **); END_INTERFACE } IFileOpenDialogVtbl; @@ -569,18 +569,18 @@ static UINT CALLBACK ColorDlgHookProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static void CleanupOFNOptions(OFNOpts *optsPtr); static int ParseOFNOptions(void *clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[], enum OFNOper oper, OFNOpts *optsPtr); + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[], enum OFNOper oper, OFNOpts *optsPtr); static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, - enum OFNOper oper); + enum OFNOper oper); static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, - enum OFNOper oper); + enum OFNOper oper); static int GetFileName(void *clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[], enum OFNOper oper); + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[], enum OFNOper oper); static int MakeFilterVista(Tcl_Interp *interp, OFNOpts *optsPtr, - DWORD *countPtr, TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, - DWORD *defaultFilterIndexPtr); + DWORD *countPtr, TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, + DWORD *defaultFilterIndexPtr); static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr); static int MakeFilter(Tcl_Interp *interp, Tcl_Obj *valuePtr, Tcl_DString *dsPtr, Tcl_Obj *initialPtr, @@ -984,7 +984,7 @@ ParseOFNOptions( enum options { FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE, FILE_MULTIPLE, FILE_CONFIRMOW, - FILE_MUSTEXIST, + FILE_MUSTEXIST, }; struct Options { const char *name; @@ -1042,31 +1042,31 @@ ParseOFNOptions( if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, sizeof(struct Options), "option", 0, &index) != TCL_OK) { - /* - * XXX -xpstyle is explicitly checked for as it is undocumented - * and we do not want it to show in option error messages. - */ - if (strcmp(Tcl_GetString(objv[i]), "-xpstyle")) - goto error_return; - if (i + 1 == objc) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("value for \"-xpstyle\" missing", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); - goto error_return; - } + /* + * XXX -xpstyle is explicitly checked for as it is undocumented + * and we do not want it to show in option error messages. + */ + if (strcmp(Tcl_GetString(objv[i]), "-xpstyle")) + goto error_return; + if (i + 1 == objc) { + Tcl_SetObjResult(interp, Tcl_NewStringObj("value for \"-xpstyle\" missing", TCL_INDEX_NONE)); + Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); + goto error_return; + } if (Tcl_GetBooleanFromObj(interp, objv[i+1], - &optsPtr->forceXPStyle) != TCL_OK) - goto error_return; + &optsPtr->forceXPStyle) != TCL_OK) + goto error_return; - continue; + continue; } else if (i + 1 == objc) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "value for \"%s\" missing", options[index].name)); - Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); - goto error_return; + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "value for \"%s\" missing", options[index].name)); + Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); + goto error_return; } - valuePtr = objv[i + 1]; + valuePtr = objv[i + 1]; string = Tcl_GetString(valuePtr); switch (options[index].value) { case FILE_DEFAULT: @@ -1078,16 +1078,16 @@ ParseOFNOptions( case FILE_INITDIR: Tcl_DStringFree(&optsPtr->utfDirString); if (Tcl_TranslateFileName(interp, string, - &optsPtr->utfDirString) == NULL) + &optsPtr->utfDirString) == NULL) goto error_return; break; case FILE_INITFILE: if (Tcl_TranslateFileName(interp, string, &ds) == NULL) goto error_return; Tcl_UtfToExternal(NULL, TkWinGetUnicodeEncoding(), - Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), - TCL_ENCODING_PROFILE_TCL8, NULL, (char *)&optsPtr->file[0], - sizeof(optsPtr->file), NULL, NULL, NULL); + Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), + TCL_ENCODING_PROFILE_TCL8, NULL, (char *)&optsPtr->file[0], + sizeof(optsPtr->file), NULL, NULL, NULL); Tcl_DStringFree(&ds); break; case FILE_PARENT: @@ -1101,23 +1101,23 @@ ParseOFNOptions( case FILE_TYPEVARIABLE: optsPtr->typeVariableObj = valuePtr; optsPtr->initialTypeObj = Tcl_ObjGetVar2(interp, valuePtr, - NULL, TCL_GLOBAL_ONLY); + NULL, TCL_GLOBAL_ONLY); break; case FILE_MULTIPLE: if (Tcl_GetBooleanFromObj(interp, valuePtr, - &optsPtr->multi) != TCL_OK) - goto error_return; + &optsPtr->multi) != TCL_OK) + goto error_return; break; case FILE_CONFIRMOW: if (Tcl_GetBooleanFromObj(interp, valuePtr, - &optsPtr->confirmOverwrite) != TCL_OK) - goto error_return; + &optsPtr->confirmOverwrite) != TCL_OK) + goto error_return; break; - case FILE_MUSTEXIST: + case FILE_MUSTEXIST: if (Tcl_GetBooleanFromObj(interp, valuePtr, - &optsPtr->mustExist) != TCL_OK) - goto error_return; - break; + &optsPtr->mustExist) != TCL_OK) + goto error_return; + break; } } @@ -1151,7 +1151,7 @@ static int VistaFileDialogsAvailable(void) HRESULT hr; IFileDialog *fdlgPtr = NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) { tsdPtr->newFileDialogsState = FDLG_STATE_USE_OLD; @@ -1198,7 +1198,7 @@ static int VistaFileDialogsAvailable(void) *---------------------------------------------------------------------- */ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, - enum OFNOper oper) + enum OFNOper oper) { HRESULT hr; HWND hWnd; @@ -1232,8 +1232,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, * is the filter specification so do that before creating */ if (MakeFilterVista(interp, optsPtr, &nfilters, &filterPtr, - &defaultFilterIndex) != TCL_OK) - return TCL_ERROR; + &defaultFilterIndex) != TCL_OK) + return TCL_ERROR; /* * Beyond this point, do not just return on error as there will be @@ -1241,14 +1241,14 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, */ if (oper == OFN_FILE_OPEN || oper == OFN_DIR_CHOOSE) - hr = CoCreateInstance(&ClsidFileOpenDialog, NULL, - CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgIf); + hr = CoCreateInstance(&ClsidFileOpenDialog, NULL, + CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgIf); else - hr = CoCreateInstance(&ClsidFileSaveDialog, NULL, - CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog, (void **) &fdlgIf); + hr = CoCreateInstance(&ClsidFileSaveDialog, NULL, + CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog, (void **) &fdlgIf); if (FAILED(hr)) - goto vamoose; + goto vamoose; /* * Get current settings first because we want to preserve existing @@ -1257,20 +1257,20 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, */ hr = fdlgIf->lpVtbl->GetOptions(fdlgIf, &flags); if (FAILED(hr)) - goto vamoose; + goto vamoose; if (filterPtr) { - /* - * Causes -filetypes {{All *}} -defaultextension ext to return - * foo.ext.ext when foo is typed into the entry box - * flags |= FOS_STRICTFILETYPES; - */ - hr = fdlgIf->lpVtbl->SetFileTypes(fdlgIf, nfilters, filterPtr); - if (FAILED(hr)) - goto vamoose; - hr = fdlgIf->lpVtbl->SetFileTypeIndex(fdlgIf, defaultFilterIndex); - if (FAILED(hr)) - goto vamoose; + /* + * Causes -filetypes {{All *}} -defaultextension ext to return + * foo.ext.ext when foo is typed into the entry box + * flags |= FOS_STRICTFILETYPES; + */ + hr = fdlgIf->lpVtbl->SetFileTypes(fdlgIf, nfilters, filterPtr); + if (FAILED(hr)) + goto vamoose; + hr = fdlgIf->lpVtbl->SetFileTypeIndex(fdlgIf, defaultFilterIndex); + if (FAILED(hr)) + goto vamoose; } /* Flags are equivalent to those we used in the older API */ @@ -1281,88 +1281,88 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, * semantics than OFN_NOVALIDATE in the old API. */ flags |= - FOS_FORCEFILESYSTEM | /* Only want files, not other shell items */ - FOS_NOVALIDATE | /* Don't check for access denied etc. */ - FOS_PATHMUSTEXIST; /* The *directory* path must exist */ + FOS_FORCEFILESYSTEM | /* Only want files, not other shell items */ + FOS_NOVALIDATE | /* Don't check for access denied etc. */ + FOS_PATHMUSTEXIST; /* The *directory* path must exist */ if (oper == OFN_DIR_CHOOSE) { - flags |= FOS_PICKFOLDERS; - if (optsPtr->mustExist) - flags |= FOS_FILEMUSTEXIST; /* XXX - check working */ + flags |= FOS_PICKFOLDERS; + if (optsPtr->mustExist) + flags |= FOS_FILEMUSTEXIST; /* XXX - check working */ } else - flags &= ~ FOS_PICKFOLDERS; + flags &= ~ FOS_PICKFOLDERS; if (optsPtr->multi) - flags |= FOS_ALLOWMULTISELECT; + flags |= FOS_ALLOWMULTISELECT; else - flags &= ~FOS_ALLOWMULTISELECT; + flags &= ~FOS_ALLOWMULTISELECT; if (optsPtr->confirmOverwrite) - flags |= FOS_OVERWRITEPROMPT; + flags |= FOS_OVERWRITEPROMPT; else - flags &= ~FOS_OVERWRITEPROMPT; + flags &= ~FOS_OVERWRITEPROMPT; hr = fdlgIf->lpVtbl->SetOptions(fdlgIf, flags); if (FAILED(hr)) - goto vamoose; + goto vamoose; if (optsPtr->extObj != NULL) { - Tcl_DString ds; - const char *src; + Tcl_DString ds; + const char *src; - src = Tcl_GetString(optsPtr->extObj); - Tcl_DStringInit(&ds); - wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds); - if (wstr[0] == '.') - ++wstr; - hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); - Tcl_DStringFree(&ds); - if (FAILED(hr)) - goto vamoose; + src = Tcl_GetString(optsPtr->extObj); + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds); + if (wstr[0] == '.') + ++wstr; + hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); + Tcl_DStringFree(&ds); + if (FAILED(hr)) + goto vamoose; } if (optsPtr->titleObj != NULL) { - Tcl_DString ds; - const char *src; + Tcl_DString ds; + const char *src; - src = Tcl_GetString(optsPtr->titleObj); - Tcl_DStringInit(&ds); - wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds); - hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr); - Tcl_DStringFree(&ds); - if (FAILED(hr)) - goto vamoose; + src = Tcl_GetString(optsPtr->titleObj); + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds); + hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr); + Tcl_DStringFree(&ds); + if (FAILED(hr)) + goto vamoose; } if (optsPtr->file[0]) { - hr = fdlgIf->lpVtbl->SetFileName(fdlgIf, optsPtr->file); - if (FAILED(hr)) - goto vamoose; + hr = fdlgIf->lpVtbl->SetFileName(fdlgIf, optsPtr->file); + if (FAILED(hr)) + goto vamoose; } if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') { - Tcl_Obj *normPath, *iniDirPath; - iniDirPath = Tcl_NewStringObj(Tcl_DStringValue(&optsPtr->utfDirString), TCL_INDEX_NONE); - Tcl_IncrRefCount(iniDirPath); - normPath = Tcl_FSGetNormalizedPath(interp, iniDirPath); - /* XXX - Note on failures do not raise error, simply ignore ini dir */ - if (normPath) { - LPCWSTR nativePath; - Tcl_IncrRefCount(normPath); - nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ - if (nativePath) { - hr = SHCreateItemFromParsingName( - nativePath, NULL, - &IIDIShellItem, (void **) &dirIf); - if (SUCCEEDED(hr)) { - /* Note we use SetFolder, not SetDefaultFolder - see MSDN */ - fdlgIf->lpVtbl->SetFolder(fdlgIf, dirIf); /* Ignore errors */ - } - } - Tcl_DecrRefCount(normPath); /* ALSO INVALIDATES nativePath !! */ - } - Tcl_DecrRefCount(iniDirPath); + Tcl_Obj *normPath, *iniDirPath; + iniDirPath = Tcl_NewStringObj(Tcl_DStringValue(&optsPtr->utfDirString), TCL_INDEX_NONE); + Tcl_IncrRefCount(iniDirPath); + normPath = Tcl_FSGetNormalizedPath(interp, iniDirPath); + /* XXX - Note on failures do not raise error, simply ignore ini dir */ + if (normPath) { + LPCWSTR nativePath; + Tcl_IncrRefCount(normPath); + nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ + if (nativePath) { + hr = SHCreateItemFromParsingName( + nativePath, NULL, + &IIDIShellItem, (void **) &dirIf); + if (SUCCEEDED(hr)) { + /* Note we use SetFolder, not SetDefaultFolder - see MSDN */ + fdlgIf->lpVtbl->SetFolder(fdlgIf, dirIf); /* Ignore errors */ + } + } + Tcl_DecrRefCount(normPath); /* ALSO INVALIDATES nativePath !! */ + } + Tcl_DecrRefCount(iniDirPath); } oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); @@ -1377,7 +1377,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, */ if (hWnd) - EnableWindow(hWnd, 1); + EnableWindow(hWnd, 1); /* * Clear interp result since it might have been set during the modal loop. @@ -1386,108 +1386,108 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, Tcl_ResetResult(interp); if (SUCCEEDED(hr)) { - if ((oper == OFN_FILE_OPEN) && optsPtr->multi) { - IShellItemArray *multiIf; - DWORD dw, count; - IFileOpenDialog *fodIf = (IFileOpenDialog *) fdlgIf; - hr = fodIf->lpVtbl->GetResults(fodIf, &multiIf); - if (SUCCEEDED(hr)) { - Tcl_Obj *multiObj; - hr = multiIf->lpVtbl->GetCount(multiIf, &count); - multiObj = Tcl_NewListObj(count, NULL); - if (SUCCEEDED(hr)) { - IShellItem *itemIf; - for (dw = 0; dw < count; ++dw) { - hr = multiIf->lpVtbl->GetItemAt(multiIf, dw, &itemIf); - if (FAILED(hr)) - break; - hr = itemIf->lpVtbl->GetDisplayName(itemIf, - SIGDN_FILESYSPATH, &wstr); - if (SUCCEEDED(hr)) { - Tcl_DString fnds; - - ConvertExternalFilename(wstr, &fnds); - CoTaskMemFree(wstr); - Tcl_ListObjAppendElement( - interp, multiObj, - Tcl_NewStringObj(Tcl_DStringValue(&fnds), - Tcl_DStringLength(&fnds))); - Tcl_DStringFree(&fnds); - } - itemIf->lpVtbl->Release(itemIf); - if (FAILED(hr)) - break; - } - } - multiIf->lpVtbl->Release(multiIf); - if (SUCCEEDED(hr)) - resultObj = multiObj; - else - Tcl_DecrRefCount(multiObj); - } - } else { - IShellItem *resultIf; - hr = fdlgIf->lpVtbl->GetResult(fdlgIf, &resultIf); - if (SUCCEEDED(hr)) { - hr = resultIf->lpVtbl->GetDisplayName(resultIf, SIGDN_FILESYSPATH, - &wstr); - if (SUCCEEDED(hr)) { - Tcl_DString fnds; - - ConvertExternalFilename(wstr, &fnds); - resultObj = Tcl_NewStringObj(Tcl_DStringValue(&fnds), - Tcl_DStringLength(&fnds)); - CoTaskMemFree(wstr); - Tcl_DStringFree(&fnds); - } - resultIf->lpVtbl->Release(resultIf); - } - } - if (SUCCEEDED(hr)) { - if (filterPtr && optsPtr->typeVariableObj) { - UINT ftix; - - hr = fdlgIf->lpVtbl->GetFileTypeIndex(fdlgIf, &ftix); - if (SUCCEEDED(hr)) { - /* Note ftix is a 1-based index */ - if (ftix > 0 && ftix <= nfilters) { - Tcl_DString ftds; - Tcl_Obj *ftobj; - - Tcl_DStringInit(&ftds); - Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds); - ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds), - Tcl_DStringLength(&ftds)); - Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, - ftobj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); - Tcl_DStringFree(&ftds); - } - } - } - } + if ((oper == OFN_FILE_OPEN) && optsPtr->multi) { + IShellItemArray *multiIf; + DWORD dw, count; + IFileOpenDialog *fodIf = (IFileOpenDialog *) fdlgIf; + hr = fodIf->lpVtbl->GetResults(fodIf, &multiIf); + if (SUCCEEDED(hr)) { + Tcl_Obj *multiObj; + hr = multiIf->lpVtbl->GetCount(multiIf, &count); + multiObj = Tcl_NewListObj(count, NULL); + if (SUCCEEDED(hr)) { + IShellItem *itemIf; + for (dw = 0; dw < count; ++dw) { + hr = multiIf->lpVtbl->GetItemAt(multiIf, dw, &itemIf); + if (FAILED(hr)) + break; + hr = itemIf->lpVtbl->GetDisplayName(itemIf, + SIGDN_FILESYSPATH, &wstr); + if (SUCCEEDED(hr)) { + Tcl_DString fnds; + + ConvertExternalFilename(wstr, &fnds); + CoTaskMemFree(wstr); + Tcl_ListObjAppendElement( + interp, multiObj, + Tcl_NewStringObj(Tcl_DStringValue(&fnds), + Tcl_DStringLength(&fnds))); + Tcl_DStringFree(&fnds); + } + itemIf->lpVtbl->Release(itemIf); + if (FAILED(hr)) + break; + } + } + multiIf->lpVtbl->Release(multiIf); + if (SUCCEEDED(hr)) + resultObj = multiObj; + else + Tcl_DecrRefCount(multiObj); + } + } else { + IShellItem *resultIf; + hr = fdlgIf->lpVtbl->GetResult(fdlgIf, &resultIf); + if (SUCCEEDED(hr)) { + hr = resultIf->lpVtbl->GetDisplayName(resultIf, SIGDN_FILESYSPATH, + &wstr); + if (SUCCEEDED(hr)) { + Tcl_DString fnds; + + ConvertExternalFilename(wstr, &fnds); + resultObj = Tcl_NewStringObj(Tcl_DStringValue(&fnds), + Tcl_DStringLength(&fnds)); + CoTaskMemFree(wstr); + Tcl_DStringFree(&fnds); + } + resultIf->lpVtbl->Release(resultIf); + } + } + if (SUCCEEDED(hr)) { + if (filterPtr && optsPtr->typeVariableObj) { + UINT ftix; + + hr = fdlgIf->lpVtbl->GetFileTypeIndex(fdlgIf, &ftix); + if (SUCCEEDED(hr)) { + /* Note ftix is a 1-based index */ + if (ftix > 0 && ftix <= nfilters) { + Tcl_DString ftds; + Tcl_Obj *ftobj; + + Tcl_DStringInit(&ftds); + Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds); + ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds), + Tcl_DStringLength(&ftds)); + Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, + ftobj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); + Tcl_DStringFree(&ftds); + } + } + } + } } else { - if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) - hr = 0; /* User cancelled, return empty string */ + if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) + hr = 0; /* User cancelled, return empty string */ } vamoose: /* (hr != 0) => error */ if (dirIf) - dirIf->lpVtbl->Release(dirIf); + dirIf->lpVtbl->Release(dirIf); if (fdlgIf) - fdlgIf->lpVtbl->Release(fdlgIf); + fdlgIf->lpVtbl->Release(fdlgIf); if (filterPtr) - FreeFilterVista(nfilters, filterPtr); + FreeFilterVista(nfilters, filterPtr); if (hr == 0) { - if (resultObj) /* May be NULL if user cancelled */ - Tcl_SetObjResult(interp, resultObj); - return TCL_OK; + if (resultObj) /* May be NULL if user cancelled */ + Tcl_SetObjResult(interp, resultObj); + return TCL_OK; } else { - if (resultObj) - Tcl_DecrRefCount(resultObj); - Tcl_SetObjResult(interp, TkWin32ErrorObj(hr)); - return TCL_ERROR; + if (resultObj) + Tcl_DecrRefCount(resultObj); + Tcl_SetObjResult(interp, TkWin32ErrorObj(hr)); + return TCL_ERROR; } } @@ -1518,16 +1518,16 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DString extString, filterString, dirString, titleString; const char *str; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); memset(&ofnData, 0, sizeof(OFNData)); Tcl_DStringInit(&utfFilterString); Tcl_DStringInit(&dirString); /* XXX - original code was missing this - leaving dirString uninitialized for - the unlikely code path where cwd failed */ + leaving dirString uninitialized for + the unlikely code path where cwd failed */ if (MakeFilter(interp, optsPtr->filterObj, &utfFilterString, - optsPtr->initialTypeObj, &filterIndex) != TCL_OK) { + optsPtr->initialTypeObj, &filterIndex) != TCL_OK) { goto end; } @@ -1594,7 +1594,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DStringFree(&optsPtr->utfDirString); if ((Tcl_GetCwd(interp, &optsPtr->utfDirString) == NULL) || (Tcl_TranslateFileName(interp, - Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) { + Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) { Tcl_ResetResult(interp); } else { Tcl_DStringInit(&dirString); @@ -1738,23 +1738,23 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper &typeInfo) != TCL_OK) { result = TCL_ERROR; } else { - /* - * BUGFIX for d43a10ce2fed950e00890049f3c273f2cdd12583 - * The original code was broken because it passed typeinfo[0] - * directly into Tcl_ObjSetVar2. In the case of typeInfo[0] - * pointing into a list which is also referenced by - * typeVariableObj, TOSV2 shimmers the object into - * variable intrep which loses the list representation. - * This invalidates typeInfo[0] which is freed but - * nevertheless stored as the value of the variable. - */ - Tcl_Obj *selFilterObj = typeInfo[0]; - Tcl_IncrRefCount(selFilterObj); - if (Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, - selFilterObj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { - result = TCL_ERROR; - } - Tcl_DecrRefCount(selFilterObj); + /* + * BUGFIX for d43a10ce2fed950e00890049f3c273f2cdd12583 + * The original code was broken because it passed typeinfo[0] + * directly into Tcl_ObjSetVar2. In the case of typeInfo[0] + * pointing into a list which is also referenced by + * typeVariableObj, TOSV2 shimmers the object into + * variable intrep which loses the list representation. + * This invalidates typeInfo[0] which is freed but + * nevertheless stored as the value of the variable. + */ + Tcl_Obj *selFilterObj = typeInfo[0]; + Tcl_IncrRefCount(selFilterObj); + if (Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, + selFilterObj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { + result = TCL_ERROR; + } + Tcl_DecrRefCount(selFilterObj); } } } else if (cdlgerr == FNERR_INVALIDFILENAME) { @@ -1772,8 +1772,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DStringFree(&titleString); } if (ofn.lpstrInitialDir != NULL) { - /* XXX - huh? lpstrInitialDir is set from Tcl_DStringValue which - can never return NULL */ + /* XXX - huh? lpstrInitialDir is set from Tcl_DStringValue which + can never return NULL */ Tcl_DStringFree(&dirString); } Tcl_DStringFree(&filterString); @@ -1822,12 +1822,12 @@ GetFileName( result = ParseOFNOptions(clientData, interp, objc, objv, oper, &ofnOpts); if (result != TCL_OK) - return result; + return result; if (VistaFileDialogsAvailable() && ! ofnOpts.forceXPStyle) - result = GetFileNameVista(interp, &ofnOpts, oper); + result = GetFileNameVista(interp, &ofnOpts, oper); else - result = GetFileNameXP(interp, &ofnOpts, oper); + result = GetFileNameXP(interp, &ofnOpts, oper); CleanupOFNOptions(&ofnOpts); return result; @@ -2163,14 +2163,14 @@ MakeFilter( static void FreeFilterVista(DWORD count, TCLCOMDLG_FILTERSPEC *dlgFilterPtr) { if (dlgFilterPtr != NULL) { - DWORD dw; - for (dw = 0; dw < count; ++dw) { - if (dlgFilterPtr[dw].pszName != NULL) - ckfree((char *)dlgFilterPtr[dw].pszName); - if (dlgFilterPtr[dw].pszSpec != NULL) - ckfree((char *)dlgFilterPtr[dw].pszSpec); - } - ckfree(dlgFilterPtr); + DWORD dw; + for (dw = 0; dw < count; ++dw) { + if (dlgFilterPtr[dw].pszName != NULL) + ckfree((char *)dlgFilterPtr[dw].pszName); + if (dlgFilterPtr[dw].pszSpec != NULL) + ckfree((char *)dlgFilterPtr[dw].pszSpec); + } + ckfree(dlgFilterPtr); } } @@ -2195,9 +2195,9 @@ static int MakeFilterVista( OFNOpts *optsPtr, /* Caller specified options */ DWORD *countPtr, /* Will hold number of filters */ TCLCOMDLG_FILTERSPEC **dlgFilterPtrPtr, /* Will hold pointer to filter array. - Set to NULL if no filters specified. - Must be freed by calling - FreeFilterVista */ + Set to NULL if no filters specified. + Must be freed by calling + FreeFilterVista */ DWORD *initialIndexPtr) /* Will hold index of default type */ { TCLCOMDLG_FILTERSPEC *dlgFilterPtr; @@ -2209,9 +2209,9 @@ static int MakeFilterVista( int i; if (optsPtr->filterObj == NULL) { - *dlgFilterPtrPtr = NULL; - *countPtr = 0; - return TCL_OK; + *dlgFilterPtrPtr = NULL; + *countPtr = 0; + return TCL_OK; } if (optsPtr->initialTypeObj) @@ -2222,9 +2222,9 @@ static int MakeFilterVista( return TCL_ERROR; if (flist.filters == NULL) { - *dlgFilterPtrPtr = NULL; - *countPtr = 0; - return TCL_OK; + *dlgFilterPtrPtr = NULL; + *countPtr = 0; + return TCL_OK; } Tcl_DStringInit(&ds); @@ -2232,19 +2232,19 @@ static int MakeFilterVista( dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr)); for (i = 0, filterPtr = flist.filters; - filterPtr; - filterPtr = filterPtr->next, ++i) { + filterPtr; + filterPtr = filterPtr->next, ++i) { const char *sep; FileFilterClause *clausePtr; size_t nbytes; /* Check if this entry should be shown as the default */ if (initial && strcmp(initial, filterPtr->name) == 0) - initialIndex = i+1; /* Windows filter indices are 1-based */ + initialIndex = i+1; /* Windows filter indices are 1-based */ /* First stash away the text description of the pattern */ - Tcl_DStringInit(&ds); - Tcl_UtfToWCharDString(filterPtr->name, TCL_INDEX_NONE, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(filterPtr->name, TCL_INDEX_NONE, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ dlgFilterPtr[i].pszName = (LPCWSTR)ckalloc(nbytes); @@ -2272,8 +2272,8 @@ static int MakeFilterVista( } /* Again we need a Unicode form of the string */ - Tcl_DStringInit(&ds); - Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), TCL_INDEX_NONE, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), TCL_INDEX_NONE, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ dlgFilterPtr[i].pszSpec = (LPCWSTR)ckalloc(nbytes); @@ -2387,15 +2387,15 @@ Tk_ChooseDirectoryObjCmd( const char *utfDir; result = ParseOFNOptions(clientData, interp, objc, objv, - OFN_DIR_CHOOSE, &ofnOpts); + OFN_DIR_CHOOSE, &ofnOpts); if (result != TCL_OK) - return result; + return result; /* Use new dialogs if available */ if (VistaFileDialogsAvailable() && ! ofnOpts.forceXPStyle) { - result = GetFileNameVista(interp, &ofnOpts, OFN_DIR_CHOOSE); - CleanupOFNOptions(&ofnOpts); - return result; + result = GetFileNameVista(interp, &ofnOpts, OFN_DIR_CHOOSE); + CleanupOFNOptions(&ofnOpts); + return result; } /* Older dialogs */ @@ -2411,13 +2411,13 @@ Tk_ChooseDirectoryObjCmd( Tcl_DStringInit(&tempString); Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), TCL_INDEX_NONE, - &tempString); - uniStr = (WCHAR *) Tcl_DStringValue(&tempString); + &tempString); + uniStr = (WCHAR *) Tcl_DStringValue(&tempString); - /* Convert possible relative path to full path to keep dialog happy. */ + /* Convert possible relative path to full path to keep dialog happy. */ - GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL); - wcsncpy(cdCBData.initDir, saveDir, MAX_PATH); + GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL); + wcsncpy(cdCBData.initDir, saveDir, MAX_PATH); } /* XXX - rest of this (original) code has no error checks at all. */ @@ -2480,10 +2480,10 @@ Tk_ChooseDirectoryObjCmd( oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); GetCurrentDirectoryW(MAX_PATH, saveDir); if (SHGetMalloc(&pMalloc) == NOERROR) { - /* - * XXX - MSDN says CoInitialize must have been called before - * SHBrowseForFolder can be used but don't see that called anywhere. - */ + /* + * XXX - MSDN says CoInitialize must have been called before + * SHBrowseForFolder can be used but don't see that called anywhere. + */ pidl = SHBrowseForFolderW(&bInfo); /* @@ -2620,7 +2620,7 @@ ChooseDirectoryValidateProc( */ wsprintfW(selDir, L"Directory '%s' does not exist,\n" - L"please select or enter an existing directory.", + L"please select or enter an existing directory.", chooseDirSharedData->retDir); MessageBoxW(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK); chooseDirSharedData->retDir[0] = '\0'; diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 7943aa3..1022be4 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -761,7 +761,7 @@ MakeAndStrokePath( POINT *winPoints, int npoints, WinDrawFunc func) /* Name of the Windows GDI drawing function: - this is either Polyline or Polygon. */ + this is either Polyline or Polygon. */ { BeginPath(dc); func(dc, winPoints, (int)npoints); @@ -772,15 +772,15 @@ MakeAndStrokePath( * path is closed. */ if (func == Polyline) { - if ((winPoints[0].x == winPoints[npoints-1].x) && - (winPoints[0].y == winPoints[npoints-1].y)) { - CloseFigure(dc); - } - EndPath(dc); - StrokePath(dc); + if ((winPoints[0].x == winPoints[npoints-1].x) && + (winPoints[0].y == winPoints[npoints-1].y)) { + CloseFigure(dc); + } + EndPath(dc); + StrokePath(dc); } else { - EndPath(dc); - StrokeAndFillPath(dc); + EndPath(dc); + StrokeAndFillPath(dc); } } @@ -879,7 +879,7 @@ RenderObject( SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); oldMemBrush = (HBRUSH)SelectObject(dcMem, CreateSolidBrush(gc->foreground)); - MakeAndStrokePath(dcMem, winPoints, npoints, func); + MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG); /* @@ -891,7 +891,7 @@ RenderObject( if (gc->fill_style == FillOpaqueStippled) { DeleteObject(SelectObject(dcMem, CreateSolidBrush(gc->background))); - MakeAndStrokePath(dcMem, winPoints, npoints, func); + MakeAndStrokePath(dcMem, winPoints, npoints, func); BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYBG); } @@ -907,7 +907,7 @@ RenderObject( SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE : WINDING); - MakeAndStrokePath(dc, winPoints, npoints, func); + MakeAndStrokePath(dc, winPoints, npoints, func); SelectObject(dc, oldPen); } DeleteObject(SelectObject(dc, oldBrush)); diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 0a2b543..34cd8ca 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -862,12 +862,12 @@ ContainerEventProc( if (eventPtr->type == ConfigureNotify) { /* - * Send a ConfigureNotify to the embedded application. - */ + * Send a ConfigureNotify to the embedded application. + */ - if (containerPtr->embeddedPtr != NULL) { - TkDoConfigureNotify(containerPtr->embeddedPtr); - } + if (containerPtr->embeddedPtr != NULL) { + TkDoConfigureNotify(containerPtr->embeddedPtr); + } /* * Resize the embedded window, if there is any. diff --git a/win/tkWinGDI.c b/win/tkWinGDI.c index c9e03ef..7611880 100644 --- a/win/tkWinGDI.c +++ b/win/tkWinGDI.c @@ -574,20 +574,20 @@ static int Bezierize( inPointList = (double *)attemptckalloc(2 * sizeof(double) * npoly); if (inPointList == 0) { /* TODO: unreachable */ - return nbpoints; /* 0. */ + return nbpoints; /* 0. */ } for (n=0; n xScrn) { - nX2 = xScrn; + nX2 = xScrn; } if (nY2 > yScrn) { - nY2 = yScrn; + nY2 = yScrn; } nWidth = nX2 - nX; @@ -3218,19 +3218,19 @@ static HANDLE BitmapToDIB( /* Check if bitmap handle is valid. */ if (!hBitmap) { - return NULL; + return NULL; } /* Fill in BITMAP structure, return NULL if it didn't work. */ if (!GetObjectW(hBitmap, sizeof(bm), (LPWSTR)&bm)) { - return NULL; + return NULL; } /* Ff no palette is specified, use default palette. */ if (hPal == NULL) { - hPal = GetStockObject(DEFAULT_PALETTE); + hPal = GetStockObject(DEFAULT_PALETTE); } /* Calculate bits per pixel. */ @@ -3240,13 +3240,13 @@ static HANDLE BitmapToDIB( /* Make sure bits per pixel is valid. */ if (biBits <= 1) { - biBits = 1; + biBits = 1; } else if (biBits <= 4) { - biBits = 4; + biBits = 4; } else if (biBits <= 8) { - biBits = 8; + biBits = 8; } else { /* If greater than 8-bit, force to 24-bit. */ - biBits = 24; + biBits = 24; } /* Initialize BITMAPINFOHEADER. */ @@ -3313,7 +3313,7 @@ static HANDLE BitmapToDIB( /* If the driver did not fill in the biSizeImage field, make one up. */ if (bi.biSizeImage == 0) { - bi.biSizeImage = (((((DWORD)bm.bmWidth * biBits) + 31) / 32) * 4) + bi.biSizeImage = (((((DWORD)bm.bmWidth * biBits) + 31) / 32) * 4) * bm.bmHeight; } @@ -3322,7 +3322,7 @@ static HANDLE BitmapToDIB( dwLen = bi.biSize + DIBNumColors(&bi) * sizeof(RGBQUAD) + bi.biSizeImage; if ((h = GlobalReAlloc(hDIB, dwLen, 0)) != 0) { - hDIB = h; + hDIB = h; } else { /* Clean up and return NULL. */ @@ -3440,7 +3440,7 @@ static HPALETTE GetSystemPalette(void) hDC = GetDC(NULL); if (!hDC) { - return NULL; + return NULL; } nColors = PalEntriesOnDevice(hDC); /* Number of palette entries. */ @@ -3452,7 +3452,7 @@ static HPALETTE GetSystemPalette(void) if (!hLogPal) { /* If we didn't get a logical palette, return NULL. */ - return NULL; + return NULL; } /* get a pointer to the logical palette. */ @@ -3643,23 +3643,23 @@ static int PrintSelectPrinter( * script level. */ if (localPrinterName != NULL) { - char* varlink1 = (char*)ckalloc(100 * sizeof(char)); - char** varlink2 = (char**)ckalloc(sizeof(char*)); - *varlink2 = varlink1; - WideCharToMultiByte(CP_UTF8, 0, localPrinterName, -1, varlink1, 0, NULL, NULL); - - Tcl_LinkVar(interp, "::tk::print::printer_name", (char*)varlink2, - TCL_LINK_STRING | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::copies", (char*)&copies, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::dpi_x", (char*)&dpi_x, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::dpi_y", (char*)&dpi_y, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::paper_width", (char*)&paper_width, - TCL_LINK_INT | TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "::tk::print::paper_height", (char*)&paper_height, - TCL_LINK_INT | TCL_LINK_READ_ONLY); + char* varlink1 = (char*)ckalloc(100 * sizeof(char)); + char** varlink2 = (char**)ckalloc(sizeof(char*)); + *varlink2 = varlink1; + WideCharToMultiByte(CP_UTF8, 0, localPrinterName, -1, varlink1, 0, NULL, NULL); + + Tcl_LinkVar(interp, "::tk::print::printer_name", (char*)varlink2, + TCL_LINK_STRING | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::copies", (char*)&copies, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::dpi_x", (char*)&dpi_x, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::dpi_y", (char*)&dpi_y, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::paper_width", (char*)&paper_width, + TCL_LINK_INT | TCL_LINK_READ_ONLY); + Tcl_LinkVar(interp, "::tk::print::paper_height", (char*)&paper_height, + TCL_LINK_INT | TCL_LINK_READ_ONLY); } return TCL_OK; diff --git a/win/tkWinIco.c b/win/tkWinIco.c index 134e7f0..899d437 100644 --- a/win/tkWinIco.c +++ b/win/tkWinIco.c @@ -171,9 +171,9 @@ CreateIcoFromPhoto( bmInfo.bmiHeader.biCompression = BI_RGB; iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, - &bgraPixel.voidPtr, NULL, 0); + &bgraPixel.voidPtr, NULL, 0); if (!iconInfo.hbmColor) { - return NULL; + return NULL; } /* @@ -182,10 +182,10 @@ CreateIcoFromPhoto( bufferSize = height * width * 4; for (idx = 0 ; idx < bufferSize ; idx += 4) { - bgraPixel.ptr[idx] = block.pixelPtr[idx+2]; - bgraPixel.ptr[idx+1] = block.pixelPtr[idx+1]; - bgraPixel.ptr[idx+2] = block.pixelPtr[idx+0]; - bgraPixel.ptr[idx+3] = block.pixelPtr[idx+3]; + bgraPixel.ptr[idx] = block.pixelPtr[idx+2]; + bgraPixel.ptr[idx+1] = block.pixelPtr[idx+1]; + bgraPixel.ptr[idx+2] = block.pixelPtr[idx+0]; + bgraPixel.ptr[idx+3] = block.pixelPtr[idx+3]; } /* @@ -197,10 +197,10 @@ CreateIcoFromPhoto( bmInfo.bmiHeader.biBitCount = 1; iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, - &bgraMask.voidPtr, NULL, 0); + &bgraMask.voidPtr, NULL, 0); if (!iconInfo.hbmMask) { - DeleteObject(iconInfo.hbmColor); - return NULL; + DeleteObject(iconInfo.hbmColor); + return NULL; } memset(bgraMask.ptr, 0, width*height/8); @@ -213,7 +213,7 @@ CreateIcoFromPhoto( DeleteObject(iconInfo.hbmColor); DeleteObject(iconInfo.hbmMask); if (hIcon == NULL) { - return NULL; + return NULL; } return hIcon; diff --git a/win/tkWinIco.h b/win/tkWinIco.h index 16cbb77..d690f49 100644 --- a/win/tkWinIco.h +++ b/win/tkWinIco.h @@ -86,8 +86,7 @@ typedef struct { DWORD BytesPerLine(LPBITMAPINFOHEADER lpBMIH); LPSTR FindDIBBits(LPSTR lpbi); -HICON CreateIcoFromPhoto(int width, int height, - Tk_PhotoImageBlock block); +HICON CreateIcoFromPhoto(int width, int height, Tk_PhotoImageBlock block); /* diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 5be9e0e..02477cc 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -358,9 +358,9 @@ KeycodeToKeysym( */ case VK_CONTROL: - if (state & EXTENDED_MASK) { - return XK_Control_R; - } + if (state & EXTENDED_MASK) { + return XK_Control_R; + } break; case VK_SHIFT: if (GetKeyState(VK_RSHIFT) & 0x80) { @@ -368,9 +368,9 @@ KeycodeToKeysym( } break; case VK_MENU: - if (state & EXTENDED_MASK) { - return XK_Alt_R; - } + if (state & EXTENDED_MASK) { + return XK_Alt_R; + } break; } return keymap[keycode]; diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 0175514..29332e2 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1601,14 +1601,14 @@ GetMenuIndicatorGeometry( menuPtr->borderWidthPtr, &borderWidth); *widthPtr = indicatorDimensions[1] - borderWidth; - /* - * Quite dubious about the above (why would borderWidth play a role?) - * and about how indicatorDimensions[1] is obtained in SetDefaults(). - * At least don't let the result be negative! - */ - if (*widthPtr < 0) { - *widthPtr = 0; - } + /* + * Quite dubious about the above (why would borderWidth play a role?) + * and about how indicatorDimensions[1] is obtained in SetDefaults(). + * At least don't let the result be negative! + */ + if (*widthPtr < 0) { + *widthPtr = 0; + } } } @@ -1639,12 +1639,12 @@ GetMenuAccelGeometry( { *heightPtr = fmPtr->linespace; if (mePtr->type == CASCADE_ENTRY) { - /* - * Cascade entries have no accelerator but do show an arrow. Set - * this field width to the width of the OBM_MNARROW system bitmap - * used to display the arrow. I couldn't find how to query the - * system for this value, therefore I resort to hardcoding. - */ + /* + * Cascade entries have no accelerator but do show an arrow. Set + * this field width to the width of the OBM_MNARROW system bitmap + * used to display the arrow. I couldn't find how to query the + * system for this value, therefore I resort to hardcoding. + */ *widthPtr = CASCADE_ARROW_WIDTH; } else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) { const char *accel = Tcl_GetString(mePtr->accelPtr); @@ -1908,7 +1908,7 @@ DrawMenuEntryAccelerator( const char *accel; if (menuPtr->menuType == MENUBAR) { - return; + return; } if (mePtr->accelPtr != NULL) { @@ -1991,8 +1991,8 @@ DrawMenuEntryArrow( */ if ((mePtr->childMenuRefPtr == NULL) - || (mePtr->childMenuRefPtr->menuPtr == NULL)) { - return; + || (mePtr->childMenuRefPtr->menuPtr == NULL)) { + return; } oldFgColor = gc->foreground; @@ -2949,8 +2949,8 @@ DrawMenuEntryBackground( Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, activeBorderWidth, relief); } else { - Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, 0, - TK_RELIEF_FLAT); + Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, 0, + TK_RELIEF_FLAT); } } diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index b895a96..5ccd862 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -377,8 +377,8 @@ void TkSetCursorPos( * requested position is off the primary screen. */ if ( x < 0 || x > xscreen || y < 0 || y > yscreen ) { - SetCursorPos(x, y); - return; + SetCursorPos(x, y); + return; } input.type = INPUT_MOUSE; @@ -394,7 +394,7 @@ void TkSetCursorPos( * See ticket [69b48f427e]. */ if (input.mi.dx == 0 && input.mi.dy == 0) { - input.mi.dx = 1; + input.mi.dx = 1; } input.mi.mouseData = 0; diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 457b82f..a54deeb 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -394,10 +394,6 @@ TkpComputeScrollbarGeometry( * basic sanity checks to appease backwards compatibility. */ - if (scrollPtr->highlightWidth < 0) { - scrollPtr->highlightWidth = 0; - } - if (scrollPtr->vertical) { scrollPtr->arrowLength = vArrowHeight; fieldLength = Tk_Height(scrollPtr->tkwin); diff --git a/win/tkWinSendCom.h b/win/tkWinSendCom.h index d20b48c..73f326b 100644 --- a/win/tkWinSendCom.h +++ b/win/tkWinSendCom.h @@ -46,11 +46,11 @@ typedef struct { */ MODULE_SCOPE HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp, - REFIID riid, void **ppv); + REFIID riid, void **ppv); MODULE_SCOPE int TkWinSend_QueueCommand(Tcl_Interp *interp, - Tcl_Obj *cmdPtr); + Tcl_Obj *cmdPtr); MODULE_SCOPE void TkWinSend_SetExcepInfo(Tcl_Interp *interp, - EXCEPINFO *pExcepInfo); + EXCEPINFO *pExcepInfo); #endif /* _tkWinSendCom_h_INCLUDE */ diff --git a/win/tkWinSysTray.c b/win/tkWinSysTray.c index 6c8893e..a710ee6 100644 --- a/win/tkWinSysTray.c +++ b/win/tkWinSysTray.c @@ -36,11 +36,11 @@ typedef struct IcoInfo { HICON hIcon; /* icon handle returned by LoadIcon. */ unsigned id; /* Identifier for command; used to - * cancel it. */ + * cancel it. */ Tcl_Obj *taskbar_txt; /* text to display in the taskbar */ Tcl_Interp *interp; /* interp which created the icon */ Tcl_Obj *taskbar_command; /* command to eval if events in the taskbar - * arrive */ + * arrive */ int taskbar_flags; /* taskbar related flags*/ HWND hwndFocus; struct IcoInfo *nextPtr; @@ -102,9 +102,9 @@ DrawXORMask( /* Sanity checks */ if (lpIcon == NULL) - return FALSE; + return FALSE; if (lpIcon->lpBits == NULL) - return FALSE; + return FALSE; /* Account for height*2 thing */ lpIcon->lpbi->bmiHeader.biHeight /= 2; @@ -115,10 +115,10 @@ DrawXORMask( /* Blast it to the screen */ SetDIBitsToDevice(hDC, x, y, - lpIcon->lpbi->bmiHeader.biWidth, - lpIcon->lpbi->bmiHeader.biHeight, - 0, 0, 0, lpIcon->lpbi->bmiHeader.biHeight, - lpIcon->lpXOR, lpIcon->lpbi, DIB_RGB_COLORS); + lpIcon->lpbi->bmiHeader.biWidth, + lpIcon->lpbi->bmiHeader.biHeight, + 0, 0, 0, lpIcon->lpbi->bmiHeader.biHeight, + lpIcon->lpXOR, lpIcon->lpbi, DIB_RGB_COLORS); /* UnAccount for height*2 thing */ lpIcon->lpbi->bmiHeader.biHeight *= 2; @@ -153,9 +153,9 @@ DrawANDMask( /* Sanity checks */ if (lpIcon == NULL) - return FALSE; + return FALSE; if (lpIcon->lpBits == NULL) - return FALSE; + return FALSE; /* Need a bitmap header for the mono mask */ lpbi = ckalloc(sizeof(BITMAPINFO) + (2 * sizeof(RGBQUAD))); @@ -185,10 +185,10 @@ DrawANDMask( /* Blast it to the screen */ SetDIBitsToDevice(hDC, x, y, - lpbi->bmiHeader.biWidth, - lpbi->bmiHeader.biHeight, - 0, 0, 0, lpbi->bmiHeader.biHeight, - lpIcon->lpAND, lpbi, DIB_RGB_COLORS); + lpbi->bmiHeader.biWidth, + lpbi->bmiHeader.biHeight, + 0, 0, 0, lpbi->bmiHeader.biHeight, + lpIcon->lpAND, lpbi, DIB_RGB_COLORS); /* clean up */ ckfree(lpbi); @@ -230,22 +230,22 @@ TaskbarOperation( ni.hIcon = icoPtr->hIcon; if (icoPtr->taskbar_txt != NULL) { - Tcl_DString dst; - Tcl_DStringInit(&dst); - str = (WCHAR *)Tcl_UtfToWCharDString(Tcl_GetString(icoPtr->taskbar_txt), TCL_INDEX_NONE, &dst); - wcsncpy(ni.szTip, str, (Tcl_DStringLength(&dst) + 2) / 2); - Tcl_DStringFree(&dst); + Tcl_DString dst; + Tcl_DStringInit(&dst); + str = (WCHAR *)Tcl_UtfToWCharDString(Tcl_GetString(icoPtr->taskbar_txt), TCL_INDEX_NONE, &dst); + wcsncpy(ni.szTip, str, (Tcl_DStringLength(&dst) + 2) / 2); + Tcl_DStringFree(&dst); } else { - ni.szTip[0] = 0; + ni.szTip[0] = 0; } if (Shell_NotifyIconW(oper, &ni) == 1) { - if (oper == NIM_ADD || oper == NIM_MODIFY) { - icoPtr->taskbar_flags |= TASKBAR_ICON; - } - if (oper == NIM_DELETE) { - icoPtr->taskbar_flags &= ~TASKBAR_ICON; - } + if (oper == NIM_ADD || oper == NIM_MODIFY) { + icoPtr->taskbar_flags |= TASKBAR_ICON; + } + if (oper == NIM_DELETE) { + icoPtr->taskbar_flags &= ~TASKBAR_ICON; + } } /* Silently ignore error? */ return TCL_OK; @@ -312,22 +312,22 @@ FreeIcoPtr( { IcoInfo *prevPtr; if (icoInterpPtr->firstIcoPtr == icoPtr) { - icoInterpPtr->firstIcoPtr = icoPtr->nextPtr; + icoInterpPtr->firstIcoPtr = icoPtr->nextPtr; } else { - for (prevPtr = icoInterpPtr->firstIcoPtr; prevPtr->nextPtr != icoPtr; - prevPtr = prevPtr->nextPtr) { - /* Empty loop body. */ - } - prevPtr->nextPtr = icoPtr->nextPtr; + for (prevPtr = icoInterpPtr->firstIcoPtr; prevPtr->nextPtr != icoPtr; + prevPtr = prevPtr->nextPtr) { + /* Empty loop body. */ + } + prevPtr->nextPtr = icoPtr->nextPtr; } if (icoPtr->taskbar_flags & TASKBAR_ICON) { - TaskbarOperation(icoInterpPtr, icoPtr, NIM_DELETE); + TaskbarOperation(icoInterpPtr, icoPtr, NIM_DELETE); } if (icoPtr->taskbar_txt != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_txt); + Tcl_DecrRefCount(icoPtr->taskbar_txt); } if (icoPtr->taskbar_command != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_command); + Tcl_DecrRefCount(icoPtr->taskbar_command); } ckfree(icoPtr); } @@ -360,22 +360,22 @@ GetIcoPtr( char *end; if (strncmp(string, "ico#", 4) != 0) { - goto notfound; + goto notfound; } start = string + 4; id = strtoul(start, &end, 10); if ((end == start) || (*end != 0)) { - goto notfound; + goto notfound; } for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { - if (icoPtr->id == id) { - return icoPtr; - } + if (icoPtr->id == id) { + return icoPtr; + } } notfound: Tcl_AppendResult(interp, "icon \"", string, - "\" doesn't exist", NULL); + "\" doesn't exist", NULL); return NULL; } @@ -466,117 +466,117 @@ TaskbarExpandPercents( char* dst; dst = after; while (*before) { - const char *ptr = before; - int len = 1; - if(*before == '%') { - switch(before[1]){ - case 'M': - case 'm': { - before++; - len = strlen(msgstring); - ptr = msgstring; - break; - } - /* case 'W': { - before++; - len = (int)strlen(winstring); - ptr = winstring; - break; - } - */ - case 'i': { - before++; - snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); - len = strlen(buffer); - ptr = buffer; - break; - } - case 'w': { - before++; - len = GetInt((long)wParam,buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'l': { - before++; - len = GetInt((long)lParam,buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 't': { - before++; - len = GetInt((long)GetTickCount(), buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'x': { - POINT pt; - GetCursorPos(&pt); - before++; - len = GetIntDec((long)pt.x, buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'y': { - POINT pt; - GetCursorPos(&pt); - before++; - len = GetIntDec((long)pt.y,buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'X': { - DWORD dw; - dw = GetMessagePos(); - before++; - len = GetIntDec((long)LOWORD(dw),buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'Y': { - DWORD dw; - dw = GetMessagePos(); - before++; - len = GetIntDec((long)HIWORD(dw),buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case 'H': { - before++; - len = GetInt(PTR2INT(icoPtr->hwndFocus), buffer, sizeof(buffer)); - ptr = buffer; - break; - } - case '%': { - before++; - len = 1; - ptr = "%"; - break; - } - } - } - if (SPACELEFT < len) { - char *newspace; - ptrdiff_t dist = dst - after; - int alloclen = ALLOCLEN; - newspace = (char *)ckalloc(alloclen); - if (dist>0) - memcpy(newspace, after, dist); - if (after && *aftersize) { - ckfree(after); - } - *aftersize =alloclen; - after = newspace; - dst = after + dist; - } - if (len > 0) { - memcpy(dst, ptr, len); - } - dst += len; - if ((dst-after)>(*aftersize-1)) { - printf("oops\n"); - } - before++; + const char *ptr = before; + int len = 1; + if(*before == '%') { + switch(before[1]){ + case 'M': + case 'm': { + before++; + len = strlen(msgstring); + ptr = msgstring; + break; + } + /* case 'W': { + before++; + len = (int)strlen(winstring); + ptr = winstring; + break; + } + */ + case 'i': { + before++; + snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); + len = strlen(buffer); + ptr = buffer; + break; + } + case 'w': { + before++; + len = GetInt((long)wParam,buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'l': { + before++; + len = GetInt((long)lParam,buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 't': { + before++; + len = GetInt((long)GetTickCount(), buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'x': { + POINT pt; + GetCursorPos(&pt); + before++; + len = GetIntDec((long)pt.x, buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'y': { + POINT pt; + GetCursorPos(&pt); + before++; + len = GetIntDec((long)pt.y,buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'X': { + DWORD dw; + dw = GetMessagePos(); + before++; + len = GetIntDec((long)LOWORD(dw),buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'Y': { + DWORD dw; + dw = GetMessagePos(); + before++; + len = GetIntDec((long)HIWORD(dw),buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case 'H': { + before++; + len = GetInt(PTR2INT(icoPtr->hwndFocus), buffer, sizeof(buffer)); + ptr = buffer; + break; + } + case '%': { + before++; + len = 1; + ptr = "%"; + break; + } + } + } + if (SPACELEFT < len) { + char *newspace; + ptrdiff_t dist = dst - after; + int alloclen = ALLOCLEN; + newspace = (char *)ckalloc(alloclen); + if (dist>0) + memcpy(newspace, after, dist); + if (after && *aftersize) { + ckfree(after); + } + *aftersize =alloclen; + after = newspace; + dst = after + dist; + } + if (len > 0) { + memcpy(dst, ptr, len); + } + dst += len; + if ((dst-after)>(*aftersize-1)) { + printf("oops\n"); + } + before++; } *dst = 0; return after; @@ -612,87 +612,87 @@ TaskbarEval( switch (lParam) { case WM_MOUSEMOVE: - msgstring = "WM_MOUSEMOVE"; - icoPtr->hwndFocus = GetFocus(); - break; + msgstring = "WM_MOUSEMOVE"; + icoPtr->hwndFocus = GetFocus(); + break; case WM_LBUTTONDOWN: - msgstring = "WM_LBUTTONDOWN"; - fixup = 1; - break; + msgstring = "WM_LBUTTONDOWN"; + fixup = 1; + break; case WM_LBUTTONUP: - msgstring = "WM_LBUTTONUP"; - fixup = 1; - break; + msgstring = "WM_LBUTTONUP"; + fixup = 1; + break; case WM_LBUTTONDBLCLK: - msgstring = "WM_LBUTTONDBLCLK"; - fixup = 1; - break; + msgstring = "WM_LBUTTONDBLCLK"; + fixup = 1; + break; case WM_RBUTTONDOWN: - msgstring = "WM_RBUTTONDOWN"; - fixup = 1; - break; + msgstring = "WM_RBUTTONDOWN"; + fixup = 1; + break; case WM_RBUTTONUP: - msgstring = "WM_RBUTTONUP"; - fixup = 1; - break; + msgstring = "WM_RBUTTONUP"; + fixup = 1; + break; case WM_RBUTTONDBLCLK: - msgstring = "WM_RBUTTONDBLCLK"; - fixup = 1; - break; + msgstring = "WM_RBUTTONDBLCLK"; + fixup = 1; + break; case WM_MBUTTONDOWN: - msgstring = "WM_MBUTTONDOWN"; - fixup = 1; - break; + msgstring = "WM_MBUTTONDOWN"; + fixup = 1; + break; case WM_MBUTTONUP: - msgstring = "WM_MBUTTONUP"; - fixup = 1; - break; + msgstring = "WM_MBUTTONUP"; + fixup = 1; + break; case WM_MBUTTONDBLCLK: - msgstring = "WM_MBUTTONDBLCLK"; - fixup = 1; - break; + msgstring = "WM_MBUTTONDBLCLK"; + fixup = 1; + break; default: - msgstring = "WM_NULL"; - fixup = 0; + msgstring = "WM_NULL"; + fixup = 0; } expanded = TaskbarExpandPercents(icoPtr, msgstring, wParam, lParam, - Tcl_GetString(icoPtr->taskbar_command), evalspace, &evalsize); + Tcl_GetString(icoPtr->taskbar_command), evalspace, &evalsize); if (icoPtr->interp != NULL) { - int result; - HWND hwnd = NULL; - - /* See http://support.microsoft.com/kb/q135788/ - * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ - if (fixup) { - if (icoPtr->hwndFocus != NULL && IsWindow(icoPtr->hwndFocus)) { - hwnd = icoPtr->hwndFocus; - } else { - Tk_Window tkwin = Tk_MainWindow(icoPtr->interp); - if (tkwin != NULL) { - hwnd = Tk_GetHWND(Tk_WindowId(tkwin)); - } - } - if (hwnd != NULL) { - SetForegroundWindow(hwnd); - } - } - - result = Tcl_GlobalEval(icoPtr->interp, expanded); - - if (hwnd != NULL) { - /* See http://support.microsoft.com/kb/q135788/ - * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ - PostMessageW(hwnd, WM_NULL, 0, 0); - } - if (result != TCL_OK) { - char buffer[100]; - snprintf(buffer, 100, "\n (command bound to taskbar-icon ico#%d)", icoPtr->id); - Tcl_AddErrorInfo(icoPtr->interp, buffer); - Tcl_BackgroundError(icoPtr->interp); - } + int result; + HWND hwnd = NULL; + + /* See http://support.microsoft.com/kb/q135788/ + * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ + if (fixup) { + if (icoPtr->hwndFocus != NULL && IsWindow(icoPtr->hwndFocus)) { + hwnd = icoPtr->hwndFocus; + } else { + Tk_Window tkwin = Tk_MainWindow(icoPtr->interp); + if (tkwin != NULL) { + hwnd = Tk_GetHWND(Tk_WindowId(tkwin)); + } + } + if (hwnd != NULL) { + SetForegroundWindow(hwnd); + } + } + + result = Tcl_GlobalEval(icoPtr->interp, expanded); + + if (hwnd != NULL) { + /* See http://support.microsoft.com/kb/q135788/ + * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */ + PostMessageW(hwnd, WM_NULL, 0, 0); + } + if (result != TCL_OK) { + char buffer[100]; + snprintf(buffer, 100, "\n (command bound to taskbar-icon ico#%d)", icoPtr->id); + Tcl_AddErrorInfo(icoPtr->interp, buffer); + Tcl_BackgroundError(icoPtr->interp); + } } if (expanded != evalspace) { - ckfree(expanded); + ckfree(expanded); } } @@ -726,43 +726,43 @@ TaskbarHandlerProc( switch (message) { case WM_CREATE: - msgTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated")); - break; + msgTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated")); + break; case ICON_MESSAGE: - for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { - if (icoInterpPtr->hwnd == hwnd) { - for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { - if (icoPtr->id == wParam) { - if (icoPtr->taskbar_command != NULL) { - TaskbarEval(icoPtr, wParam, lParam); - } - break; - } - } - break; - } - } - break; + for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { + if (icoInterpPtr->hwnd == hwnd) { + for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { + if (icoPtr->id == wParam) { + if (icoPtr->taskbar_command != NULL) { + TaskbarEval(icoPtr, wParam, lParam); + } + break; + } + } + break; + } + } + break; default: - /* - * Check to see if explorer has been restarted and we need to - * re-add our icons. - */ - if (message == msgTaskbarCreated) { - for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { - if (icoInterpPtr->hwnd == hwnd) { - for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { - if (icoPtr->taskbar_flags & TASKBAR_ICON) { - TaskbarOperation(icoInterpPtr, icoPtr, NIM_ADD); - } - } - break; - } - } - } - return DefWindowProc(hwnd, message, wParam, lParam); + /* + * Check to see if explorer has been restarted and we need to + * re-add our icons. + */ + if (message == msgTaskbarCreated) { + for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) { + if (icoInterpPtr->hwnd == hwnd) { + for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) { + if (icoPtr->taskbar_flags & TASKBAR_ICON) { + TaskbarOperation(icoInterpPtr, icoPtr, NIM_ADD); + } + } + break; + } + } + } + return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } @@ -823,12 +823,12 @@ CreateTaskbarHandlerWindow(void) { static int registered = 0; HINSTANCE hInstance = GETHINSTANCE; if (!registered) { - if (!RegisterHandlerClass(hInstance)) - return 0; - registered = 1; + if (!RegisterHandlerClass(hInstance)) + return 0; + registered = 1; } return CreateWindow(HANDLER_CLASS, "", WS_OVERLAPPED, 0, 0, - CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); + CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); } /* @@ -860,23 +860,23 @@ WinIcoDestroy( IcoInfo *nextPtr; if (eventPtr->type != DestroyNotify) { - return; + return; } if (firstIcoInterpPtr == icoInterpPtr) { - firstIcoInterpPtr = icoInterpPtr->nextPtr; + firstIcoInterpPtr = icoInterpPtr->nextPtr; } else { - for (prevIcoInterpPtr = firstIcoInterpPtr; prevIcoInterpPtr->nextPtr != icoInterpPtr; - prevIcoInterpPtr = prevIcoInterpPtr->nextPtr) { - /* Empty loop body. */ - } - prevIcoInterpPtr->nextPtr = icoInterpPtr->nextPtr; + for (prevIcoInterpPtr = firstIcoInterpPtr; prevIcoInterpPtr->nextPtr != icoInterpPtr; + prevIcoInterpPtr = prevIcoInterpPtr->nextPtr) { + /* Empty loop body. */ + } + prevIcoInterpPtr->nextPtr = icoInterpPtr->nextPtr; } DestroyWindow(icoInterpPtr->hwnd); for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = nextPtr) { - nextPtr = icoPtr->nextPtr; - FreeIcoPtr(icoInterpPtr, icoPtr); + nextPtr = icoPtr->nextPtr; + FreeIcoPtr(icoInterpPtr, icoPtr); } ckfree(icoInterpPtr); } @@ -905,11 +905,11 @@ WinSystrayCmd( Tcl_Obj *const objv[]) { static const char *const cmdStrings[] = { - "add", "delete", "modify", NULL + "add", "delete", "modify", NULL }; enum { CMD_ADD, CMD_DELETE, CMD_MODIFY }; static const char *const optStrings[] = { - "-callback", "-image", "-text", NULL + "-callback", "-image", "-text", NULL }; enum { OPT_CALLBACK, OPT_IMAGE, OPT_TEXT }; int cmd, opt; @@ -920,124 +920,124 @@ WinSystrayCmd( IcoInfo *icoPtr = NULL; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "command ..."); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 1, objv, "command ..."); + return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], cmdStrings, "command", - 0, &cmd) == TCL_ERROR) { - return TCL_ERROR; + 0, &cmd) == TCL_ERROR) { + return TCL_ERROR; } switch (cmd) { - case CMD_ADD: - case CMD_MODIFY: { - Tcl_Obj *imageObj = NULL, *textObj = NULL, *callbackObj = NULL; - int optStart; - int oper; - if (cmd == CMD_ADD) { - optStart = 2; - oper = NIM_ADD; - } else { - optStart = 3; - oper = NIM_MODIFY; - if (objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "id option value"); - return TCL_ERROR; - } - icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); - if (icoPtr == NULL) { - return TCL_ERROR; - } - } - for (i = optStart; i < objc; i += 2) { - if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", - 0, &opt) == TCL_ERROR) { - return TCL_ERROR; - } - if (i+1 >= objc) { - Tcl_AppendResult(interp, - "missing value for option \"", Tcl_GetString(objv[i]), - "\"", NULL); - return TCL_ERROR; - } - switch (opt) { - case OPT_IMAGE: - imageObj = objv[i+1]; - break; - case OPT_TEXT: - textObj = objv[i+1]; - break; - case OPT_CALLBACK: - callbackObj = objv[i+1]; - break; - } - } - if (cmd == CMD_ADD && imageObj == NULL) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("missing required option \"-image\"", TCL_INDEX_NONE)); - return TCL_ERROR; - } - if (imageObj != NULL) { - Tk_PhotoHandle photo; - int width, height; - Tk_PhotoImageBlock block; - - photo = Tk_FindPhoto(interp, Tcl_GetString(imageObj)); - if (photo == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "image \"%s\" doesn't exist", Tcl_GetString(imageObj))); - return TCL_ERROR; - } - Tk_PhotoGetSize(photo, &width, &height); - Tk_PhotoGetImage(photo, &block); - hIcon = CreateIcoFromPhoto(width, height, block); - if (hIcon == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "failed to create an iconphoto with image \"%s\"", Tcl_GetString(imageObj))); - return TCL_ERROR; - } - } - if (cmd == CMD_ADD) { - icoPtr = NewIcon(interp, icoInterpPtr, hIcon); - } else { - if (imageObj != NULL) { - DestroyIcon(icoPtr->hIcon); - icoPtr->hIcon = hIcon; - } - } - if (callbackObj != NULL) { - if (icoPtr->taskbar_command != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_command); - } - icoPtr->taskbar_command = callbackObj; - Tcl_IncrRefCount(icoPtr->taskbar_command); - } - if (textObj != NULL) { - if (icoPtr->taskbar_txt != NULL) { - Tcl_DecrRefCount(icoPtr->taskbar_txt); - } - icoPtr->taskbar_txt = textObj; - Tcl_IncrRefCount(icoPtr->taskbar_txt); - } - TaskbarOperation(icoInterpPtr, icoPtr, oper); - if (cmd == CMD_ADD) { - char buffer[5 + TCL_INTEGER_SPACE]; - int n; - n = snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); - buffer[n] = 0; - Tcl_SetObjResult(interp, Tcl_NewStringObj(buffer, n)); - } - return TCL_OK; - } - case CMD_DELETE: - if (objc != 3) { - Tcl_WrongNumArgs(interp, 2, objv, "id"); - return TCL_ERROR; - } - icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); - if (icoPtr == NULL) { - return TCL_ERROR; - } - FreeIcoPtr(icoInterpPtr, icoPtr); - return TCL_OK; + case CMD_ADD: + case CMD_MODIFY: { + Tcl_Obj *imageObj = NULL, *textObj = NULL, *callbackObj = NULL; + int optStart; + int oper; + if (cmd == CMD_ADD) { + optStart = 2; + oper = NIM_ADD; + } else { + optStart = 3; + oper = NIM_MODIFY; + if (objc != 5) { + Tcl_WrongNumArgs(interp, 2, objv, "id option value"); + return TCL_ERROR; + } + icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); + if (icoPtr == NULL) { + return TCL_ERROR; + } + } + for (i = optStart; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", + 0, &opt) == TCL_ERROR) { + return TCL_ERROR; + } + if (i+1 >= objc) { + Tcl_AppendResult(interp, + "missing value for option \"", Tcl_GetString(objv[i]), + "\"", NULL); + return TCL_ERROR; + } + switch (opt) { + case OPT_IMAGE: + imageObj = objv[i+1]; + break; + case OPT_TEXT: + textObj = objv[i+1]; + break; + case OPT_CALLBACK: + callbackObj = objv[i+1]; + break; + } + } + if (cmd == CMD_ADD && imageObj == NULL) { + Tcl_SetObjResult(interp, Tcl_NewStringObj("missing required option \"-image\"", TCL_INDEX_NONE)); + return TCL_ERROR; + } + if (imageObj != NULL) { + Tk_PhotoHandle photo; + int width, height; + Tk_PhotoImageBlock block; + + photo = Tk_FindPhoto(interp, Tcl_GetString(imageObj)); + if (photo == NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "image \"%s\" doesn't exist", Tcl_GetString(imageObj))); + return TCL_ERROR; + } + Tk_PhotoGetSize(photo, &width, &height); + Tk_PhotoGetImage(photo, &block); + hIcon = CreateIcoFromPhoto(width, height, block); + if (hIcon == NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "failed to create an iconphoto with image \"%s\"", Tcl_GetString(imageObj))); + return TCL_ERROR; + } + } + if (cmd == CMD_ADD) { + icoPtr = NewIcon(interp, icoInterpPtr, hIcon); + } else { + if (imageObj != NULL) { + DestroyIcon(icoPtr->hIcon); + icoPtr->hIcon = hIcon; + } + } + if (callbackObj != NULL) { + if (icoPtr->taskbar_command != NULL) { + Tcl_DecrRefCount(icoPtr->taskbar_command); + } + icoPtr->taskbar_command = callbackObj; + Tcl_IncrRefCount(icoPtr->taskbar_command); + } + if (textObj != NULL) { + if (icoPtr->taskbar_txt != NULL) { + Tcl_DecrRefCount(icoPtr->taskbar_txt); + } + icoPtr->taskbar_txt = textObj; + Tcl_IncrRefCount(icoPtr->taskbar_txt); + } + TaskbarOperation(icoInterpPtr, icoPtr, oper); + if (cmd == CMD_ADD) { + char buffer[5 + TCL_INTEGER_SPACE]; + int n; + n = snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id); + buffer[n] = 0; + Tcl_SetObjResult(interp, Tcl_NewStringObj(buffer, n)); + } + return TCL_OK; + } + case CMD_DELETE: + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "id"); + return TCL_ERROR; + } + icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); + if (icoPtr == NULL) { + return TCL_ERROR; + } + FreeIcoPtr(icoInterpPtr, icoPtr); + return TCL_OK; } return TCL_OK; } @@ -1074,22 +1074,22 @@ WinSysNotifyCmd( char *msginfo; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "command ..."); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 1, objv, "command ..."); + return TCL_ERROR; } if (strcmp(Tcl_GetString(objv[1]), "notify") != 0) { - Tcl_AppendResult(interp, "unknown subcommand \"", Tcl_GetString(objv[1]), - "\": must be notify", NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, "unknown subcommand \"", Tcl_GetString(objv[1]), + "\": must be notify", NULL); + return TCL_ERROR; } if (objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "id title detail"); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 2, objv, "id title detail"); + return TCL_ERROR; } icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2])); if (icoPtr == NULL) { - return TCL_ERROR; + return TCL_ERROR; } ni.cbSize = sizeof(NOTIFYICONDATAW); @@ -1105,18 +1105,18 @@ WinSysNotifyCmd( /* Balloon notification for system tray icon. */ if (msgtitle != NULL) { - WCHAR *title; - Tcl_DStringInit(&titledst); - title = Tcl_UtfToWCharDString(msgtitle, TCL_INDEX_NONE, &titledst); - wcsncpy(ni.szInfoTitle, title, (Tcl_DStringLength(&titledst) + 2) / 2); - Tcl_DStringFree(&titledst); + WCHAR *title; + Tcl_DStringInit(&titledst); + title = Tcl_UtfToWCharDString(msgtitle, TCL_INDEX_NONE, &titledst); + wcsncpy(ni.szInfoTitle, title, (Tcl_DStringLength(&titledst) + 2) / 2); + Tcl_DStringFree(&titledst); } if (msginfo != NULL) { - WCHAR *info; - Tcl_DStringInit(&infodst); - info = Tcl_UtfToWCharDString(msginfo, TCL_INDEX_NONE, &infodst); - wcsncpy(ni.szInfo, info, (Tcl_DStringLength(&infodst) + 2) / 2); - Tcl_DStringFree(&infodst); + WCHAR *info; + Tcl_DStringInit(&infodst); + info = Tcl_UtfToWCharDString(msginfo, TCL_INDEX_NONE, &infodst); + wcsncpy(ni.szInfo, info, (Tcl_DStringLength(&infodst) + 2) / 2); + Tcl_DStringFree(&infodst); } Shell_NotifyIconW(NIM_MODIFY, &ni); @@ -1148,8 +1148,8 @@ WinIcoInit( mainWindow = Tk_MainWindow(interp); if (mainWindow == NULL) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("main window has been destroyed", TCL_INDEX_NONE)); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_NewStringObj("main window has been destroyed", TCL_INDEX_NONE)); + return TCL_ERROR; } icoInterpPtr = (IcoInterpInfo*) ckalloc(sizeof(IcoInterpInfo)); @@ -1159,12 +1159,12 @@ WinIcoInit( icoInterpPtr->nextPtr = firstIcoInterpPtr; firstIcoInterpPtr = icoInterpPtr; Tcl_CreateObjCommand(interp, "::tk::systray::_systray", WinSystrayCmd, - icoInterpPtr, NULL); + icoInterpPtr, NULL); Tcl_CreateObjCommand(interp, "::tk::sysnotify::_sysnotify", WinSysNotifyCmd, - icoInterpPtr, NULL); + icoInterpPtr, NULL); Tk_CreateEventHandler(mainWindow, StructureNotifyMask, - WinIcoDestroy, icoInterpPtr); + WinIcoDestroy, icoInterpPtr); return TCL_OK; } diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 544f89c..4e993af 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -98,10 +98,10 @@ HWND TestFindControl(HWND root, int id) fcs.control = GetDlgItem(root, id); if (fcs.control == NULL) { - /* Control is not a direct child. Look in descendents */ - fcs.id = id; - fcs.control = NULL; - EnumChildWindows(root, TestFindControlCallback, (LPARAM) &fcs); + /* Control is not a direct child. Look in descendents */ + fcs.id = id; + fcs.control = NULL; + EnumChildWindows(root, TestFindControlCallback, (LPARAM) &fcs); } return fcs.control; } @@ -360,15 +360,15 @@ TestwineventObjCmd( #if 0 GetDlgItemTextA(hwnd, id, buf, 256); #else - control = TestFindControl(hwnd, id); - if (control == NULL) { - Tcl_SetObjResult(interp, - Tcl_ObjPrintf("Could not find control with id %d", id)); - return TCL_ERROR; - } - buf[0] = 0; - SendMessageA(control, WM_GETTEXT, (WPARAM)sizeof(buf), - (LPARAM) buf); + control = TestFindControl(hwnd, id); + if (control == NULL) { + Tcl_SetObjResult(interp, + Tcl_ObjPrintf("Could not find control with id %d", id)); + return TCL_ERROR; + } + buf[0] = 0; + SendMessageA(control, WM_GETTEXT, (WPARAM)sizeof(buf), + (LPARAM) buf); #endif Tcl_AppendResult(interp, Tcl_ExternalToUtfDString(NULL, buf, TCL_INDEX_NONE, &ds), NULL); Tcl_DStringFree(&ds); @@ -443,8 +443,8 @@ TestfindwindowObjCmd( Tcl_DStringInit(&titleString); if (objc < 2 || objc > 3) { - Tcl_WrongNumArgs(interp, 1, objv, "title ?class?"); - return TCL_ERROR; + Tcl_WrongNumArgs(interp, 1, objv, "title ?class?"); + return TCL_ERROR; } Tcl_DStringInit(&titleString); @@ -454,23 +454,23 @@ TestfindwindowObjCmd( windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), TCL_INDEX_NONE, &classString); } if (title[0] == 0) - title = NULL; + title = NULL; /* We want find a window the belongs to us and not some other process */ hwnd = NULL; myPid = GetCurrentProcessId(); while (1) { - DWORD pid, tid; - hwnd = FindWindowExW(NULL, hwnd, windowClass, title); - if (hwnd == NULL) - break; - tid = GetWindowThreadProcessId(hwnd, &pid); - if (tid == 0) { - /* Window has gone */ - hwnd = NULL; - break; - } - if (pid == myPid) - break; /* Found it */ + DWORD pid, tid; + hwnd = FindWindowExW(NULL, hwnd, windowClass, title); + if (hwnd == NULL) + break; + tid = GetWindowThreadProcessId(hwnd, &pid); + if (tid == 0) { + /* Window has gone */ + hwnd = NULL; + break; + } + if (pid == myPid) + break; /* Found it */ } if (hwnd == NULL) { @@ -478,7 +478,7 @@ TestfindwindowObjCmd( AppendSystemError(interp, GetLastError()); r = TCL_ERROR; } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(PTR2INT(hwnd))); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(PTR2INT(hwnd))); } Tcl_DStringFree(&titleString); diff --git a/win/tkWinX.c b/win/tkWinX.c index 34e93ed..2047536 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -806,16 +806,16 @@ TkWinChildProc( break; case WM_UNICHAR: - if (wParam == UNICODE_NOCHAR) { + if (wParam == UNICODE_NOCHAR) { /* If wParam is UNICODE_NOCHAR and the application processes * this message, then return TRUE. */ result = 1; } else { /* If the event was translated, we must return 0 */ - if (TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) { - result = 0; + if (TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) { + result = 0; } else { - result = 1; + result = 1; } } break; @@ -872,20 +872,20 @@ TkTranslateWinEvent( } case WM_RENDERALLFORMATS: { - TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); - - if (winPtr && OpenClipboard(hwnd)) { - /* - * Make sure that nobody had taken ownership of the clipboard - * before we opened it. - */ - - if (GetClipboardOwner() == hwnd) { - TkWinClipboardRender(winPtr->dispPtr, CF_TEXT); - } - CloseClipboard(); - } - return 1; + TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); + + if (winPtr && OpenClipboard(hwnd)) { + /* + * Make sure that nobody had taken ownership of the clipboard + * before we opened it. + */ + + if (GetClipboardOwner() == hwnd) { + TkWinClipboardRender(winPtr->dispPtr, CF_TEXT); + } + CloseClipboard(); + } + return 1; } case WM_COMMAND: @@ -1221,7 +1221,7 @@ GenerateXEvent( event.x.xany.send_event = -1; event.x.xkey.keycode = wParam; GetTranslatedKey(&event.key, (message == WM_KEYDOWN) ? WM_CHAR : - WM_SYSCHAR); + WM_SYSCHAR); break; case WM_SYSKEYUP: @@ -1294,7 +1294,7 @@ GenerateXEvent( MSG msg; if ((PeekMessageW(&msg, NULL, WM_CHAR, WM_CHAR, - PM_NOREMOVE) != 0) + PM_NOREMOVE) != 0) && (msg.message == WM_CHAR)) { GetMessageW(&msg, NULL, WM_CHAR, WM_CHAR); event.key.nbytes = 2; -- cgit v0.12 From 8abb78aec188d72fbbd9bda28f1f9702ad3b60e5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 17 Jun 2024 13:14:45 +0000 Subject: "less than 0" -> negative, as everywhere else in the documentation --- doc/TextLayout.3 | 4 ++-- doc/canvas.n | 8 ++++---- doc/dialog.n | 2 +- doc/entry.n | 2 +- doc/frame.n | 8 ++++---- doc/labelframe.n | 4 ++-- doc/message.n | 2 +- doc/options.n | 2 +- doc/scale.n | 4 ++-- doc/scrollbar.n | 4 ++-- doc/spinbox.n | 2 +- doc/toplevel.n | 4 ++-- doc/ttk_entry.n | 2 +- doc/ttk_image.n | 4 ++-- doc/ttk_label.n | 2 +- doc/ttk_treeview.n | 4 ++-- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/doc/TextLayout.3 b/doc/TextLayout.3 index 7df0685..ab73d12 100644 --- a/doc/TextLayout.3 +++ b/doc/TextLayout.3 @@ -51,7 +51,7 @@ stored in the text layout. The \fIstring\fR must remain valid for the lifetime of the text layout. .AP int numChars in The number of characters to consider from \fIstring\fR. If -\fInumChars\fR is less than 0, then assumes \fIstring\fR is null +\fInumChars\fR is negative, then assumes \fIstring\fR is null terminated and uses \fBTcl_NumUtfChars\fR to determine the length of \fIstring\fR. .AP int wrapLength in @@ -179,7 +179,7 @@ located at (0, 0). Any point whose \fIy\fR-value is less that 0 will be considered closest to the first character in the text layout; any point whose \fIy\fR-value is greater than the height of the text layout will be considered closest to the last character in the text layout. Any point -whose \fIx\fR-value is less than 0 will be considered closest to the first +whose \fIx\fR-value is negative will be considered closest to the first character on that line; any point whose \fIx\fR-value is greater than the width of the text layout will be considered closest to the last character on that line. The return value is the index of the character that was closest diff --git a/doc/canvas.n b/doc/canvas.n index cda7706..bffa48e 100644 --- a/doc/canvas.n +++ b/doc/canvas.n @@ -67,7 +67,7 @@ the canvas x coordinate at the left edge of the window is always an even multiple of \fBxScrollIncrement\fR; furthermore, the units for scrolling (e.g., the change in view when the left and right arrows of a scrollbar are selected) will also be \fBxScrollIncrement\fR. If the value of -this option is less than or equal to zero, then horizontal scrolling +this option is negative or zero, then horizontal scrolling is unconstrained. .OP \-yscrollincrement yScrollIncrement ScrollIncrement Specifies an increment for vertical scrolling, in any of the usual forms @@ -77,7 +77,7 @@ the canvas y coordinate at the top edge of the window is always an even multiple of \fByScrollIncrement\fR; furthermore, the units for scrolling (e.g., the change in view when the top and bottom arrows of a scrollbar are selected) will also be \fByScrollIncrement\fR. If the value of -this option is less than or equal to zero, then vertical scrolling +this option is negative or zero, then vertical scrolling is unconstrained. .BE .SH INTRODUCTION @@ -264,10 +264,10 @@ within the text item. 0 refers to the first character, 1 to the next character, and so on. If indexes are odd for lines and polygons, they will be automatically decremented by one. -A number less than 0 is treated as if it were zero, and a +A negative number is treated as if it were zero, and a number greater than the length of the text item is treated as if it were equal to the length of the text item. For -polygons, numbers less than 0 or greater than the length +polygons, negative numbers or numbers greater than the length of the coordinate list will be adjusted by adding or subtracting the length until the result is between zero and the length, inclusive. diff --git a/doc/dialog.n b/doc/dialog.n index e4938d2..4245810 100644 --- a/doc/dialog.n +++ b/doc/dialog.n @@ -40,7 +40,7 @@ If this is an empty string then no bitmap is displayed in the dialog. If this is an integer greater than or equal to zero, then it gives the index of the button that is to be the default button for the dialog (0 for the leftmost button, and so on). -If less than zero or an empty string then there will not be any default +If negative or an empty string then there will not be any default button. .TP \fIstring\fR diff --git a/doc/entry.n b/doc/entry.n index 80e8428..850932c 100644 --- a/doc/entry.n +++ b/doc/entry.n @@ -77,7 +77,7 @@ See \fBVALIDATION\fR below for more information. .OP \-width width Width Specifies an integer value indicating the desired width of the entry window, in average-size characters of the widget's font. -If the value is less than or equal to zero, the widget picks a +If the value is negative or zero, the widget picks a size just large enough to hold its current text. .BE .SH DESCRIPTION diff --git a/doc/frame.n b/doc/frame.n index 5520f32..97ff3b1 100644 --- a/doc/frame.n +++ b/doc/frame.n @@ -66,8 +66,8 @@ Note that \fB\-borderwidth\fR, \fB\-padx\fR and \fB\-pady\fR are ignored when configured as a container since a container has no border. .OP \-height height Height Specifies the desired height for the window in any of the forms -acceptable to \fBTk_GetPixels\fR. If this option is less than or equal -to zero then the window will not request any size at all. Note that this +acceptable to \fBTk_GetPixels\fR. If this option is negative or +zero then the window will not request any size at all. Note that this sets the total height of the frame, any \fB\-borderwidth\fR or similar is not added. Normally \fB\-height\fR should not be used if a propagating geometry manager, such as \fBgrid\fR or \fBpack\fR, is used within the @@ -90,8 +90,8 @@ The \fB\-visual\fR option may not be modified with the \fBconfigure\fR widget command. .OP \-width width Width Specifies the desired width for the window in any of the forms -acceptable to \fBTk_GetPixels\fR. If this option is less than or equal -to zero then the window will not request any size at all. Note that this +acceptable to \fBTk_GetPixels\fR. If this option is negative or +zero then the window will not request any size at all. Note that this sets the total width of the frame, any \fB\-borderwidth\fR or similar is not added. Normally \fB\-width\fR should not be used if a propagating geometry manager, such as \fBgrid\fR or \fBpack\fR, is used within the diff --git a/doc/labelframe.n b/doc/labelframe.n index 89f56c4..d8dd2c3 100644 --- a/doc/labelframe.n +++ b/doc/labelframe.n @@ -47,7 +47,7 @@ widget command. .OP \-height height Height Specifies the desired height for the window in any of the forms acceptable to \fBTk_GetPixels\fR. -If this option is less than or equal to zero then the window will +If this option is negative or zero then the window will not request any size at all. .OP \-labelanchor labelAnchor LabelAnchor Specifies where to place the label. A label is only displayed if the @@ -71,7 +71,7 @@ widget command. .OP \-width width Width Specifies the desired width for the window in any of the forms acceptable to \fBTk_GetPixels\fR. -If this option is less than or equal to zero then the window will +If this option is negative or zero then the window will not request any size at all. .BE .SH DESCRIPTION diff --git a/doc/message.n b/doc/message.n index eb83d2f..a8bf6b7 100644 --- a/doc/message.n +++ b/doc/message.n @@ -57,7 +57,7 @@ The value may have any of the forms acceptable to \fBTk_GetPixels\fR. If this option has a value greater than zero then the \fB\-aspect\fR option is ignored and the \fB\-width\fR option determines the line length. -If this option has a value less than or equal to zero, then +If this option value is negative or zero, then the \fB\-aspect\fR option determines the line length. .BE .SH DESCRIPTION diff --git a/doc/options.n b/doc/options.n index de03ec8..71e4713 100644 --- a/doc/options.n +++ b/doc/options.n @@ -325,7 +325,7 @@ Lines that would exceed this length are wrapped onto the next line, so that no line is longer than the specified length. The value may be specified in any of the standard forms for screen distances. -If this value is less than or equal to 0 then no wrapping is done: lines +If this value is negative or zero then no wrapping is done: lines will break only at newline characters in the text. .OP \-xscrollcommand xScrollCommand ScrollCommand Specifies the prefix for a command used to communicate with horizontal diff --git a/doc/scale.n b/doc/scale.n index 0499d0a..86abdec 100644 --- a/doc/scale.n +++ b/doc/scale.n @@ -36,7 +36,7 @@ new value of the scale. .OP \-digits digits Digits An integer specifying how many significant digits should be retained when converting the value of the scale to a string. -If the number is less than or equal to zero, then the scale picks +If the number is negative or zero, then the scale picks the smallest value that guarantees that every possible slider position prints as a different string. .OP \-from from From @@ -56,7 +56,7 @@ it is the scale's width. A real value specifying the resolution for the scale. If this value is greater than zero then the scale's value will always be rounded to an even multiple of this value, as will -the endpoints of the scale. If the value is less than zero then no +the endpoints of the scale. If the value is negative then no rounding occurs. Defaults to 1 (i.e., the value will be integral). .OP \-showvalue showValue ShowValue Specifies a boolean value indicating whether or not the current diff --git a/doc/scrollbar.n b/doc/scrollbar.n index fee959d..ee6f6dd 100644 --- a/doc/scrollbar.n +++ b/doc/scrollbar.n @@ -42,8 +42,8 @@ as described in \fBSCROLLING COMMANDS\fR below. Specifies the width of borders drawn around the internal elements of the scrollbar (the two arrows and the slider). The value may have any of the forms acceptable to \fBTk_GetPixels\fR. -If this value is less than zero, the value of the \fB\-borderwidth\fR -option is used in its place. +If this value is negative (the default is -1), the value of +the \fB\-borderwidth\fR option is used in its place. .OP \-width width Width Specifies the desired narrow dimension of the scrollbar window, not including 3-D border, if any. For vertical diff --git a/doc/spinbox.n b/doc/spinbox.n index 104ef13..f44d145 100644 --- a/doc/spinbox.n +++ b/doc/spinbox.n @@ -109,7 +109,7 @@ option has precedence over the \fB\-from\fR and \fB\-to\fR range. .OP \-width width Width Specifies an integer value indicating the desired width of the spinbox window, in average-size characters of the widget's font. -If the value is less than or equal to zero, the widget picks a +If the value is negative or zero, the widget picks a size just large enough to hold its current text. .OP \-wrap wrap wrap Must be a proper boolean value. If on, the spinbox will wrap around the diff --git a/doc/toplevel.n b/doc/toplevel.n index e946248..6e5ec0e 100644 --- a/doc/toplevel.n +++ b/doc/toplevel.n @@ -68,7 +68,7 @@ widget command. .OP \-height height Height Specifies the desired height for the window in any of the forms acceptable to \fBTk_GetPixels\fR. -If this option is less than or equal to zero then the window will +If this option is negative or zero then the window will not request any size at all. .OP \-menu menu Menu Specifies a menu widget to be used as a menubar. On the Macintosh, the @@ -113,7 +113,7 @@ widget command. .OP \-width width Width Specifies the desired width for the window in any of the forms acceptable to \fBTk_GetPixels\fR. -If this option is less than or equal to zero then the window will +If this option is negative or zero then the window will not request any size at all. .BE .SH DESCRIPTION diff --git a/doc/ttk_entry.n b/doc/ttk_entry.n index c4176ec..4f8e0a3 100644 --- a/doc/ttk_entry.n +++ b/doc/ttk_entry.n @@ -82,7 +82,7 @@ See \fBVALIDATION\fR below. .OP \-width width Width Specifies an integer value indicating the desired width of the entry window, in average-size characters of the widget's font. -.\" Not in ttk: If the value is less than or equal to zero, the widget picks a +.\" Not in ttk: If the value is negative or zero, the widget picks a .\" Not in ttk: size just large enough to hold its current text. .SH NOTES .PP diff --git a/doc/ttk_image.n b/doc/ttk_image.n index 09cf1f8..300a0e4 100644 --- a/doc/ttk_image.n +++ b/doc/ttk_image.n @@ -44,7 +44,7 @@ See \fBIMAGE STRETCHING\fR, below. \fB\-height \fIheight\fR . Specifies a minimum height for the element. -If less than zero, the base image's height is used as a default. +If negative, the base image's height is used as a default. .\" OPTION: -padding .TP \fB\-padding\fI padding\fR @@ -76,7 +76,7 @@ or \fB\-width \fIwidth\fR . Specifies a minimum width for the element. -If less than zero, the base image's width is used as a default. +If negative, the base image's width is used as a default. .SH "IMAGE STRETCHING" .PP If the element's allocated parcel is larger than the image, diff --git a/doc/ttk_label.n b/doc/ttk_label.n index 149ef9b..49f6d6c 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -37,7 +37,7 @@ Valid values are and \fBsunken\fR. .OP \-wraplength wrapLength WrapLength Specifies the maximum line length (in pixels). -If this option is less than or equal to zero, +If this option is negative or zero, then automatic wrapping is not performed; otherwise the text is split into lines such that no line is longer than the specified value. diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index 8ff0091..2531772 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -384,7 +384,7 @@ or the empty string \fB{}\fR to create a new top-level item. \fIindex\fR is an integer, or the value \fBend\fR, specifying where in the list of \fIparent\fR's children to insert the new item. -If \fIindex\fR is less than or equal to zero, +If \fIindex\fR is negative or zero, the new node is inserted at the beginning; if \fIindex\fR is greater than or equal to the current number of children, it is inserted at the end. @@ -416,7 +416,7 @@ Moves \fIitem\fR to position \fIindex\fR in \fIparent\fR's list of children. It is illegal to move an item under one of its descendants. .RS .PP -If \fIindex\fR is less than or equal to zero, \fIitem\fR is moved +If \fIindex\fR is negative or zero, \fIitem\fR is moved to the beginning; if greater than or equal to the number of children, it is moved to the end. .RE -- cgit v0.12 From 608fd32e78ef596819f4240cccb94f5556eb6111 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 18 Jun 2024 15:01:05 +0000 Subject: Add braces, indenting --- win/nmakehlp.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 36708c9..4fc9f7a 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -19,7 +19,6 @@ #pragma comment (lib, "kernel32.lib") #endif #include -#include /* * This library is required for x64 builds with _some_ versions of MSVC @@ -601,9 +600,9 @@ list_free(list_item_t **listPtrPtr) * * Usage is something like: * nmakehlp -S << $** > $@ - * @PACKAGE_NAME@ $(PACKAGE_NAME) - * @PACKAGE_VERSION@ $(PACKAGE_VERSION) - * << + * @PACKAGE_NAME@ $(PACKAGE_NAME) + * @PACKAGE_VERSION@ $(PACKAGE_VERSION) + * << */ static int @@ -727,11 +726,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) int keylen, ret; WIN32_FIND_DATA finfo; - if (dir == NULL || keypath == NULL) + if (dir == NULL || keypath == NULL) { return 2; /* Have no real error reporting mechanism into nmake */ + } dirlen = strlen(dir); - if ((dirlen + 3) > sizeof(path)) + if ((dirlen + 3) > sizeof(path)) { return 2; + } strncpy(path, dir, dirlen); strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */ keylen = strlen(keypath); @@ -746,8 +747,9 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) #else hSearch = FindFirstFile(path, &finfo); #endif - if (hSearch == INVALID_HANDLE_VALUE) + if (hSearch == INVALID_HANDLE_VALUE) { return 1; /* Not found */ + } /* Loop through all subdirs checking if the keypath is under there */ ret = 1; /* Assume not found */ @@ -757,11 +759,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * We need to check it is a directory despite the * FindExSearchLimitToDirectories in the above call. See SDK docs */ - if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { continue; + } sublen = strlen(finfo.cFileName); - if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) + if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) { continue; /* Path does not fit, assume not matched */ + } strncpy(path+dirlen+1, finfo.cFileName, sublen); path[dirlen+1+sublen] = '\\'; strncpy(path+dirlen+1+sublen+1, keypath, keylen+1); @@ -781,13 +785,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * LocateDependency -- * * Locates a dependency for a package. - * keypath - a relative path within the package directory - * that is used to confirm it is the correct directory. + * keypath - a relative path within the package directory + * that is used to confirm it is the correct directory. * The search path for the package directory is currently only - * the parent and grandparent of the current working directory. - * If found, the command prints - * name_DIRPATH= - * and returns 0. If not found, does not print anything and returns 1. + * the parent and grandparent of the current working directory. + * If found, the command prints + * name_DIRPATH= + * and returns 0. If not found, does not print anything and returns 1. */ static int LocateDependency(const char *keypath) { @@ -797,8 +801,9 @@ static int LocateDependency(const char *keypath) for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) { ret = LocateDependencyHelper(paths[i], keypath); - if (ret == 0) + if (ret == 0) { return ret; + } } return ret; } -- cgit v0.12 From 65c315a27d0aa38c5fd0397b72e946e6eb3bf908 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 19 Jun 2024 15:03:31 +0000 Subject: Use "(char *)NULL" sentinels in more places. Fix some indenting --- generic/tkConfig.c | 250 ++++++++++++++++++++++++------------------------ generic/tkListbox.c | 116 +++++++++++----------- generic/tkMenu.c | 120 +++++++++++------------ generic/tkObj.c | 12 +-- generic/tkOption.c | 10 +- generic/tkPack.c | 36 +++---- generic/tkPanedWindow.c | 116 +++++++++++----------- generic/tkPlace.c | 8 +- generic/tkSelect.c | 8 +- generic/tkTextTag.c | 6 +- generic/tkTextWind.c | 8 +- 11 files changed, 345 insertions(+), 345 deletions(-) diff --git a/generic/tkConfig.c b/generic/tkConfig.c index bbbed91..3336467 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -215,7 +215,7 @@ Tk_CreateOptionTable( * reuse the existing table. */ - hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->hashTable, (char *) templatePtr, + hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->hashTable, (char *)templatePtr, &newEntry); if (!newEntry) { tablePtr = (OptionTable *)Tcl_GetHashValue(hashEntryPtr); @@ -262,7 +262,7 @@ Tk_CreateOptionTable( Tcl_Panic("Tk_CreateOptionTable couldn't find synonym"); } if (strcmp(specPtr2->optionName, - (char *) specPtr->clientData) == 0) { + (char *)specPtr->clientData) == 0) { optionPtr->extra.synonymPtr = tablePtr->options + i; break; } @@ -621,9 +621,9 @@ DoObjConfig( if (savedOptionPtr != NULL) { savedOptionPtr->optionPtr = optionPtr; savedOptionPtr->valuePtr = oldPtr; - oldInternalPtr = (char *) &savedOptionPtr->internalForm; + oldInternalPtr = (char *)&savedOptionPtr->internalForm; } else { - oldInternalPtr = (char *) &internal.internalForm; + oldInternalPtr = (char *)&internal.internalForm; } nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)); switch (optionPtr->specPtr->type) { @@ -643,17 +643,17 @@ DoObjConfig( if (internalPtr != NULL) { if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) oldInternalPtr) = *((char *) internalPtr); - *((char *) internalPtr) = (char)newBool; + *((char *)oldInternalPtr) = *((char *)internalPtr); + *((char *)internalPtr) = (char)newBool; } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) oldInternalPtr) = *((short *) internalPtr); - *((short *) internalPtr) = (short)newBool; + *((short *)oldInternalPtr) = *((short *)internalPtr); + *((short *)internalPtr) = (short)newBool; } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_BOOLEAN"); } } else { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = newBool; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = newBool; } } break; @@ -670,13 +670,13 @@ DoObjConfig( if (nullOK && interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected integer or \"\" but got \"%.50s\"", Tcl_GetString(valuePtr))); - Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL); + Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", (char *)NULL); } return TCL_ERROR; } if (internalPtr != NULL) { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = newInt; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = newInt; } } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_MASK) { Tcl_WideInt newWideInt; @@ -688,11 +688,11 @@ DoObjConfig( } if (internalPtr != NULL) { if (sizeof(long) > sizeof(int)) { - *((long *) oldInternalPtr) = *((long *) internalPtr); - *((long *) internalPtr) = (long)newWideInt; + *((long *)oldInternalPtr) = *((long *)internalPtr); + *((long *)internalPtr) = (long)newWideInt; } else { - *((long long *) oldInternalPtr) = *((long long *) internalPtr); - *((long long *) internalPtr) = (long long)newWideInt; + *((long long *)oldInternalPtr) = *((long long *)internalPtr); + *((long long *)internalPtr) = (long long)newWideInt; } } } else { @@ -716,8 +716,8 @@ DoObjConfig( newIndex = INT_MAX; } if (internalPtr != NULL) { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = (int)newIndex; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = (int)newIndex; } break; } @@ -739,15 +739,15 @@ DoObjConfig( Tcl_AppendLimitedToObj(msg, Tcl_GetString(valuePtr), TCL_INDEX_NONE, 50, ""); Tcl_AppendToObj(msg, "\"", TCL_INDEX_NONE); Tcl_SetObjResult(interp, msg); - Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL); + Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", (char *)NULL); } return TCL_ERROR; } } if (internalPtr != NULL) { - *((double *) oldInternalPtr) = *((double *) internalPtr); - *((double *) internalPtr) = newDbl; + *((double *)oldInternalPtr) = *((double *)internalPtr); + *((double *)internalPtr) = newDbl; } break; } @@ -767,8 +767,8 @@ DoObjConfig( } else { newStr = NULL; } - *((char **) oldInternalPtr) = *((char **) internalPtr); - *((char **) internalPtr) = newStr; + *((char **)oldInternalPtr) = *((char **)internalPtr); + *((char **)internalPtr) = newStr; } break; } @@ -792,17 +792,17 @@ DoObjConfig( if (internalPtr != NULL) { if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) oldInternalPtr) = *((char *) internalPtr); - *((char *) internalPtr) = (char)newValue; + *((char *)oldInternalPtr) = *((char *)internalPtr); + *((char *)internalPtr) = (char)newValue; } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) oldInternalPtr) = *((short *) internalPtr); - *((short *) internalPtr) = (short)newValue; + *((short *)oldInternalPtr) = *((short *)internalPtr); + *((short *)internalPtr) = (short)newValue; } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE"); } } else { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = newValue; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = newValue; } } break; @@ -820,8 +820,8 @@ DoObjConfig( } } if (internalPtr != NULL) { - *((XColor **) oldInternalPtr) = *((XColor **) internalPtr); - *((XColor **) internalPtr) = newPtr; + *((XColor **)oldInternalPtr) = *((XColor **)internalPtr); + *((XColor **)internalPtr) = newPtr; } break; } @@ -838,8 +838,8 @@ DoObjConfig( } } if (internalPtr != NULL) { - *((Tk_Font *) oldInternalPtr) = *((Tk_Font *) internalPtr); - *((Tk_Font *) internalPtr) = newFont; + *((Tk_Font *)oldInternalPtr) = *((Tk_Font *)internalPtr); + *((Tk_Font *)internalPtr) = newFont; } break; } @@ -856,8 +856,8 @@ DoObjConfig( } } if (internalPtr != NULL) { - *((Tk_Style *) oldInternalPtr) = *((Tk_Style *) internalPtr); - *((Tk_Style *) internalPtr) = newStyle; + *((Tk_Style *)oldInternalPtr) = *((Tk_Style *)internalPtr); + *((Tk_Style *)internalPtr) = newStyle; } break; } @@ -874,8 +874,8 @@ DoObjConfig( } } if (internalPtr != NULL) { - *((Pixmap *) oldInternalPtr) = *((Pixmap *) internalPtr); - *((Pixmap *) internalPtr) = newBitmap; + *((Pixmap *)oldInternalPtr) = *((Pixmap *)internalPtr); + *((Pixmap *)internalPtr) = newBitmap; } break; } @@ -892,8 +892,8 @@ DoObjConfig( } } if (internalPtr != NULL) { - *((Tk_3DBorder *) oldInternalPtr) = *((Tk_3DBorder *) internalPtr); - *((Tk_3DBorder *) internalPtr) = newBorder; + *((Tk_3DBorder *)oldInternalPtr) = *((Tk_3DBorder *)internalPtr); + *((Tk_3DBorder *)internalPtr) = newBorder; } break; } @@ -910,17 +910,17 @@ DoObjConfig( if (internalPtr != NULL) { if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) oldInternalPtr) = *((char *) internalPtr); - *((char *) internalPtr) = (char)newRelief; + *((char *)oldInternalPtr) = *((char *)internalPtr); + *((char *)internalPtr) = (char)newRelief; } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) oldInternalPtr) = *((short *) internalPtr); - *((short *) internalPtr) = (short)newRelief; + *((short *)oldInternalPtr) = *((short *)internalPtr); + *((short *)internalPtr) = (short)newRelief; } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_RELIEF"); } } else { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = newRelief; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = newRelief; } } if (slotPtrPtr != NULL && valuePtr != NULL) { @@ -961,17 +961,17 @@ DoObjConfig( if (internalPtr != NULL) { if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) oldInternalPtr) = *((char *) internalPtr); - *((char *) internalPtr) = (char)newJustify; + *((char *)oldInternalPtr) = *((char *)internalPtr); + *((char *)internalPtr) = (char)newJustify; } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) oldInternalPtr) = *((short *) internalPtr); - *((short *) internalPtr) = (short)newJustify; + *((short *)oldInternalPtr) = *((short *)internalPtr); + *((short *)internalPtr) = (short)newJustify; } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_JUSTIFY"); } } else { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = newJustify; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = newJustify; } } if (slotPtrPtr != NULL && valuePtr != NULL) { @@ -993,17 +993,17 @@ DoObjConfig( if (internalPtr != NULL) { if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) oldInternalPtr) = *((char *) internalPtr); - *((char *) internalPtr) = (char)newAnchor; + *((char *)oldInternalPtr) = *((char *)internalPtr); + *((char *)internalPtr) = (char)newAnchor; } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) oldInternalPtr) = *((short *) internalPtr); - *((short *) internalPtr) = (short)newAnchor; + *((short *)oldInternalPtr) = *((short *)internalPtr); + *((short *)internalPtr) = (short)newAnchor; } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_JUSTIFY"); } } else { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = newAnchor; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = newAnchor; } } if (slotPtrPtr != NULL && valuePtr != NULL) { @@ -1020,16 +1020,16 @@ DoObjConfig( newPixels = INT_MIN; } else if (Tk_GetPixelsFromObj(nullOK ? NULL : interp, tkwin, valuePtr, &newPixels) != TCL_OK) { - if (nullOK && interp) { + if (nullOK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected screen distance or \"\" but got \"%.50s\"", Tcl_GetString(valuePtr))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL); } return TCL_ERROR; } if (internalPtr != NULL) { - *((int *) oldInternalPtr) = *((int *) internalPtr); - *((int *) internalPtr) = newPixels; + *((int *)oldInternalPtr) = *((int *)internalPtr); + *((int *)internalPtr) = newPixels; } break; } @@ -1044,8 +1044,8 @@ DoObjConfig( return TCL_ERROR; } if (internalPtr != NULL) { - *((Tk_Window *) oldInternalPtr) = *((Tk_Window *) internalPtr); - *((Tk_Window *) internalPtr) = newWin; + *((Tk_Window *)oldInternalPtr) = *((Tk_Window *)internalPtr); + *((Tk_Window *)internalPtr) = newWin; } break; } @@ -1064,7 +1064,7 @@ DoObjConfig( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad config table: unknown type %d", optionPtr->specPtr->type)); - Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", NULL); + Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", (char *)NULL); return TCL_ERROR; } @@ -1271,7 +1271,7 @@ GetOptionFromObj( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown option \"%s\"", name)); - Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", name, NULL); + Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", name, (char *)NULL); } return NULL; } @@ -1447,7 +1447,7 @@ Tk_SetOptions( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(*objv))); - Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", (char *)NULL); goto error; } } @@ -1570,86 +1570,86 @@ Tk_RestoreSavedOptions( = savePtr->items[i].valuePtr; } if (specPtr->internalOffset != TCL_INDEX_NONE) { - char *ptr = (char *) &savePtr->items[i].internalForm; + char *ptr = (char *)&savePtr->items[i].internalForm; CLANG_ASSERT(internalPtr); switch (specPtr->type) { case TK_OPTION_BOOLEAN: if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) internalPtr) = *((char *) ptr); + *((char *)internalPtr) = *((char *)ptr); } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) internalPtr) = *((short *) ptr); + *((short *)internalPtr) = *((short *)ptr); } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_BOOLEAN"); } } else { - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); } break; case TK_OPTION_INT: if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_MASK) { if (sizeof(long) > sizeof(int)) { - *((long *) internalPtr) = *((long *) ptr); + *((long *)internalPtr) = *((long *)ptr); } else { - *((long long *) internalPtr) = *((long long *) ptr); + *((long long *)internalPtr) = *((long long *)ptr); } } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_INT"); } } else { - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); } break; case TK_OPTION_INDEX: - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); break; case TK_OPTION_DOUBLE: - *((double *) internalPtr) = *((double *) ptr); + *((double *)internalPtr) = *((double *)ptr); break; case TK_OPTION_STRING: - *((char **) internalPtr) = *((char **) ptr); + *((char **)internalPtr) = *((char **)ptr); break; case TK_OPTION_STRING_TABLE: if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) internalPtr) = *((char *) ptr); + *((char *)internalPtr) = *((char *)ptr); } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) internalPtr) = *((short *) ptr); + *((short *)internalPtr) = *((short *)ptr); } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE"); } } else { - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); } break; case TK_OPTION_COLOR: - *((XColor **) internalPtr) = *((XColor **) ptr); + *((XColor **)internalPtr) = *((XColor **)ptr); break; case TK_OPTION_FONT: - *((Tk_Font *) internalPtr) = *((Tk_Font *) ptr); + *((Tk_Font *)internalPtr) = *((Tk_Font *)ptr); break; case TK_OPTION_STYLE: - *((Tk_Style *) internalPtr) = *((Tk_Style *) ptr); + *((Tk_Style *)internalPtr) = *((Tk_Style *)ptr); break; case TK_OPTION_BITMAP: - *((Pixmap *) internalPtr) = *((Pixmap *) ptr); + *((Pixmap *)internalPtr) = *((Pixmap *)ptr); break; case TK_OPTION_BORDER: - *((Tk_3DBorder *) internalPtr) = *((Tk_3DBorder *) ptr); + *((Tk_3DBorder *)internalPtr) = *((Tk_3DBorder *)ptr); break; case TK_OPTION_RELIEF: if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) internalPtr) = *((char *) ptr); + *((char *)internalPtr) = *((char *)ptr); } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) internalPtr) = *((short *) ptr); + *((short *)internalPtr) = *((short *)ptr); } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_RELIEF"); } } else { - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); } break; case TK_OPTION_CURSOR: @@ -1659,34 +1659,34 @@ Tk_RestoreSavedOptions( case TK_OPTION_JUSTIFY: if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) internalPtr) = *((char *) ptr); + *((char *)internalPtr) = *((char *)ptr); } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) internalPtr) = *((short *) ptr); + *((short *)internalPtr) = *((short *)ptr); } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_JUSTIFY"); } } else { - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); } break; case TK_OPTION_ANCHOR: if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { - *((char *) internalPtr) = *((char *) ptr); + *((char *)internalPtr) = *((char *)ptr); } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) { - *((short *) internalPtr) = *((short *) ptr); + *((short *)internalPtr) = *((short *)ptr); } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_ANCHOR"); } } else { - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); } break; case TK_OPTION_PIXELS: - *((int *) internalPtr) = *((int *) ptr); + *((int *)internalPtr) = *((int *)ptr); break; case TK_OPTION_WINDOW: - *((Tk_Window *) internalPtr) = *((Tk_Window *) ptr); + *((Tk_Window *)internalPtr) = *((Tk_Window *)ptr); break; case TK_OPTION_CUSTOM: { const Tk_ObjCustomOption *custom = optionPtr->extra.custom; @@ -1738,7 +1738,7 @@ Tk_FreeSavedOptions( savedOptionPtr = &savePtr->items[count-1]; if (savedOptionPtr->optionPtr->flags & OPTION_NEEDS_FREEING) { FreeResources(savedOptionPtr->optionPtr, savedOptionPtr->valuePtr, - (char *) &savedOptionPtr->internalForm, savePtr->tkwin); + (char *)&savedOptionPtr->internalForm, savePtr->tkwin); } if (savedOptionPtr->valuePtr != NULL) { Tcl_DecrRefCount(savedOptionPtr->valuePtr); @@ -1849,17 +1849,17 @@ FreeResources( switch (optionPtr->specPtr->type) { case TK_OPTION_STRING: if (internalFormExists) { - if (*((char **) internalPtr) != NULL) { - ckfree(*((char **) internalPtr)); - *((char **) internalPtr) = NULL; + if (*((char **)internalPtr) != NULL) { + ckfree(*((char **)internalPtr)); + *((char **)internalPtr) = NULL; } } break; case TK_OPTION_COLOR: if (internalFormExists) { - if (*((XColor **) internalPtr) != NULL) { - Tk_FreeColor(*((XColor **) internalPtr)); - *((XColor **) internalPtr) = NULL; + if (*((XColor **)internalPtr) != NULL) { + Tk_FreeColor(*((XColor **)internalPtr)); + *((XColor **)internalPtr) = NULL; } } else if (objPtr != NULL) { Tk_FreeColorFromObj(tkwin, objPtr); @@ -1867,23 +1867,23 @@ FreeResources( break; case TK_OPTION_FONT: if (internalFormExists) { - Tk_FreeFont(*((Tk_Font *) internalPtr)); - *((Tk_Font *) internalPtr) = NULL; + Tk_FreeFont(*((Tk_Font *)internalPtr)); + *((Tk_Font *)internalPtr) = NULL; } else if (objPtr != NULL) { Tk_FreeFontFromObj(tkwin, objPtr); } break; case TK_OPTION_STYLE: if (internalFormExists) { - Tk_FreeStyle(*((Tk_Style *) internalPtr)); - *((Tk_Style *) internalPtr) = NULL; + Tk_FreeStyle(*((Tk_Style *)internalPtr)); + *((Tk_Style *)internalPtr) = NULL; } break; case TK_OPTION_BITMAP: if (internalFormExists) { - if (*((Pixmap *) internalPtr) != None) { - Tk_FreeBitmap(Tk_Display(tkwin), *((Pixmap *) internalPtr)); - *((Pixmap *) internalPtr) = None; + if (*((Pixmap *)internalPtr) != None) { + Tk_FreeBitmap(Tk_Display(tkwin), *((Pixmap *)internalPtr)); + *((Pixmap *)internalPtr) = None; } } else if (objPtr != NULL) { Tk_FreeBitmapFromObj(tkwin, objPtr); @@ -1891,9 +1891,9 @@ FreeResources( break; case TK_OPTION_BORDER: if (internalFormExists) { - if (*((Tk_3DBorder *) internalPtr) != NULL) { - Tk_Free3DBorder(*((Tk_3DBorder *) internalPtr)); - *((Tk_3DBorder *) internalPtr) = NULL; + if (*((Tk_3DBorder *)internalPtr) != NULL) { + Tk_Free3DBorder(*((Tk_3DBorder *)internalPtr)); + *((Tk_3DBorder *)internalPtr) = NULL; } } else if (objPtr != NULL) { Tk_Free3DBorderFromObj(tkwin, objPtr); @@ -2151,25 +2151,25 @@ GetObjectForOption( break; } case TK_OPTION_INDEX: - if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *) internalPtr) != INT_MIN) { - if (*((int *) internalPtr) == INT_MIN) { + if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *)internalPtr) != INT_MIN) { + if (*((int *)internalPtr) == INT_MIN) { objPtr = TkNewIndexObj(TCL_INDEX_NONE); - } else if (*((int *) internalPtr) == INT_MAX) { + } else if (*((int *)internalPtr) == INT_MAX) { objPtr = Tcl_NewStringObj("end+1", TCL_INDEX_NONE); - } else if (*((int *) internalPtr) == -1) { + } else if (*((int *)internalPtr) == -1) { objPtr = Tcl_NewStringObj("end", TCL_INDEX_NONE); - } else if (*((int *) internalPtr) < 0) { + } else if (*((int *)internalPtr) < 0) { char buf[32]; - snprintf(buf, 32, "end%d", 1 + *((int *) internalPtr)); + snprintf(buf, 32, "end%d", 1 + *((int *)internalPtr)); objPtr = Tcl_NewStringObj(buf, TCL_INDEX_NONE); } else { - objPtr = Tcl_NewWideIntObj(*((int *) internalPtr)); + objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); } } break; case TK_OPTION_DOUBLE: - if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || !isnan(*((double *) internalPtr))) { - objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); + if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || !isnan(*((double *)internalPtr))) { + objPtr = Tcl_NewDoubleObj(*((double *)internalPtr)); } break; case TK_OPTION_STRING: @@ -2189,7 +2189,7 @@ GetObjectForOption( value = *((int *)internalPtr); } if (value >= 0) { - objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[ + objPtr = Tcl_NewStringObj(((char **)optionPtr->specPtr->clientData)[ value], TCL_INDEX_NONE); } break; @@ -2299,12 +2299,12 @@ GetObjectForOption( break; } case TK_OPTION_PIXELS: - if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *) internalPtr) != INT_MIN) { + if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *)internalPtr) != INT_MIN) { objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); } break; case TK_OPTION_WINDOW: { - tkwin = *((Tk_Window *) internalPtr); + tkwin = *((Tk_Window *)internalPtr); if (tkwin != NULL) { objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), TCL_INDEX_NONE); diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 4a2ea5f..4e4fa23 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -115,7 +115,7 @@ typedef struct { * is offset to the left by this many pixels * (0 means no offset, positive means there is * an offset). This is x scrolling information - * is not linked to justification. */ + * is not linked to justification. */ /* * Information about what's selected or active, if any. @@ -874,7 +874,7 @@ ListboxWidgetObjCmd( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "item number \"%s\" out of range", Tcl_GetString(objv[2]))); - Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", (char *)NULL); result = TCL_ERROR; break; } @@ -911,7 +911,7 @@ ListboxWidgetObjCmd( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "item number \"%s\" out of range", Tcl_GetString(objv[2]))); - Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", (char *)NULL); result = TCL_ERROR; break; } @@ -1111,15 +1111,15 @@ ListboxBboxSubCmd( Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); - if (listPtr->justify == TK_JUSTIFY_LEFT) { - x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; - } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { - x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth) - - pixelWidth - listPtr->xOffset + GetMaxOffset(listPtr); - } else { - x = (Tk_Width(tkwin) - pixelWidth)/2 - - listPtr->xOffset + GetMaxOffset(listPtr)/2; - } + if (listPtr->justify == TK_JUSTIFY_LEFT) { + x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; + } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { + x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth) + - pixelWidth - listPtr->xOffset + GetMaxOffset(listPtr); + } else { + x = (Tk_Width(tkwin) - pixelWidth)/2 + - listPtr->xOffset + GetMaxOffset(listPtr)/2; + } y = ((index - listPtr->topIndex)*listPtr->lineHeight) + listPtr->inset + listPtr->selBorderWidth; results[0] = Tcl_NewWideIntObj(x); @@ -2072,24 +2072,24 @@ DisplayListbox( * Draw the actual text of this item. */ - Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); - stringRep = Tcl_GetStringFromObj(curElement, &stringLen); - textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); + Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); + stringRep = Tcl_GetStringFromObj(curElement, &stringLen); + textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; - if (listPtr->justify == TK_JUSTIFY_LEFT) { - x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; - } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { - x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth) - - textWidth - listPtr->xOffset + GetMaxOffset(listPtr); - } else { - x = (Tk_Width(tkwin) - textWidth)/2 - - listPtr->xOffset + GetMaxOffset(listPtr)/2; - } - - Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont, + if (listPtr->justify == TK_JUSTIFY_LEFT) { + x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; + } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { + x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth) + - textWidth - listPtr->xOffset + GetMaxOffset(listPtr); + } else { + x = (Tk_Width(tkwin) - textWidth)/2 + - listPtr->xOffset + GetMaxOffset(listPtr)/2; + } + + Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont, stringRep, stringLen, x, y); /* @@ -2769,9 +2769,9 @@ GetListboxIndex( stringRep = Tcl_GetString(indexObj); if (stringRep[0] == '@') { - /* - * @x,y index - */ + /* + * @x,y index + */ int y; char *start; @@ -2804,7 +2804,7 @@ GetListboxIndex( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad listbox index \"%s\": must be active, anchor, end, @x,y," " or an index", Tcl_GetString(indexObj))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", (char *)NULL); return TCL_ERROR; } @@ -3203,7 +3203,7 @@ ListboxLostSelection( if ((listPtr->exportSelection) && (!Tcl_IsSafe(listPtr->interp)) && (listPtr->nElements > 0)) { ListboxSelect(listPtr, 0, listPtr->nElements-1, 0); - GenerateListboxSelectEvent(listPtr); + GenerateListboxSelectEvent(listPtr); } } @@ -3448,27 +3448,27 @@ ListboxListVarProc( if (flags & TCL_TRACE_UNSETS) { - if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) { - void *probe = NULL; - - do { - probe = Tcl_VarTraceInfo(interp, - listPtr->listVarName, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ListboxListVarProc, probe); - if (probe == (void *)listPtr) { - break; - } - } while (probe); - if (probe) { - /* - * We were able to fetch the unset trace for our - * listVarName, which means it is not unset and not - * the cause of this unset trace. Instead some outdated - * former variable must be, and we should ignore it. - */ - return NULL; - } + if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) { + void *probe = NULL; + + do { + probe = Tcl_VarTraceInfo(interp, + listPtr->listVarName, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + ListboxListVarProc, probe); + if (probe == (void *)listPtr) { + break; + } + } while (probe); + if (probe) { + /* + * We were able to fetch the unset trace for our + * listVarName, which means it is not unset and not + * the cause of this unset trace. Instead some outdated + * former variable must be, and we should ignore it. + */ + return NULL; + } Tcl_SetVar2Ex(interp, listPtr->listVarName, NULL, listPtr->listObj, TCL_GLOBAL_ONLY); Tcl_TraceVar2(interp, listPtr->listVarName, @@ -3650,15 +3650,15 @@ static int GetMaxOffset( int maxOffset; maxOffset = listPtr->maxWidth - - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - - 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; + (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - + 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; if (maxOffset < 0) { - /* - * Listbox is larger in width than its largest width item. - */ + /* + * Listbox is larger in width than its largest width item. + */ - maxOffset = 0; + maxOffset = 0; } maxOffset -= maxOffset % listPtr->xScrollUnit; diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 7819b11..b32c114 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -904,9 +904,9 @@ MenuWidgetObjCmd( goto error; } if (objc == 5) { - if (GetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) { - goto error; - } + if (GetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) { + goto error; + } } /* @@ -918,9 +918,9 @@ MenuWidgetObjCmd( */ if (menuPtr->menuType == MENUBAR) { - Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL); - return TCL_ERROR; - } else if (menuPtr->menuType != TEAROFF_MENU) { + Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL); + return TCL_ERROR; + } else if (menuPtr->menuType != TEAROFF_MENU) { result = TkpPostMenu(interp, menuPtr, x, y, index); } else { result = TkpPostTearoffMenu(interp, menuPtr, x, y, index); @@ -1201,16 +1201,16 @@ DestroyMenuInstance( */ for (i = menuPtr->numEntries; --i >= 0; ) { - /* - * Clean up the hash entry for the menu item ID. - * This cannot be postponed until the entry is eventually freed, - * because the hash table may already have been deleted by then. - */ + /* + * Clean up the hash entry for the menu item ID. + * This cannot be postponed until the entry is eventually freed, + * because the hash table may already have been deleted by then. + */ - if (menuPtr->entries[i]->entryPtr) { - Tcl_DeleteHashEntry(menuPtr->entries[i]->entryPtr); - menuPtr->entries[i]->entryPtr = NULL; - } + if (menuPtr->entries[i]->entryPtr) { + Tcl_DeleteHashEntry(menuPtr->entries[i]->entryPtr); + menuPtr->entries[i]->entryPtr = NULL; + } /* * As each menu entry is deleted from the end of the array of entries, @@ -1499,8 +1499,8 @@ DestroyMenuEntry( MenuVarProc, mePtr); } if (mePtr->entryPtr) { - Tcl_DeleteHashEntry(mePtr->entryPtr); - mePtr->entryPtr = NULL; + Tcl_DeleteHashEntry(mePtr->entryPtr); + mePtr->entryPtr = NULL; } TkpDestroyMenuEntry(mePtr); TkMenuEntryFreeDrawOptions(mePtr); @@ -2203,9 +2203,9 @@ GetMenuIndex( entryPtr = Tcl_FindHashEntry(&menuPtr->items, string); if (entryPtr) { - TkMenuEntry *mePtr = (TkMenuEntry *)Tcl_GetHashValue(entryPtr); - *indexPtr = mePtr->index; - return TCL_OK; + TkMenuEntry *mePtr = (TkMenuEntry *)Tcl_GetHashValue(entryPtr); + *indexPtr = mePtr->index; + return TCL_OK; } for (i = 0; i < menuPtr->numEntries; i++) { @@ -2220,7 +2220,7 @@ GetMenuIndex( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad menu entry index \"%s\"", string)); - Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", (char *)NULL); return TCL_ERROR; } @@ -2411,7 +2411,7 @@ MenuAddOrInsert( if (index < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad menu entry index \"%s\"", Tcl_GetString(indexPtr))); - Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", (char *)NULL); return TCL_ERROR; } if (menuPtr->tearoff && (index == 0)) { @@ -2433,14 +2433,14 @@ MenuAddOrInsert( */ if (objc % 2 == 0) { - idPtr = objv[offs]; - if (Tcl_FindHashEntry(&menuPtr->items, Tcl_GetString(idPtr))) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( + idPtr = objv[offs]; + if (Tcl_FindHashEntry(&menuPtr->items, Tcl_GetString(idPtr))) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( "entry \"%s\" already exists", Tcl_GetString(idPtr))); - Tcl_SetErrorCode(interp, "TK", "MENU", "ENTRY_EXISTS", NULL); - return TCL_ERROR; - } - offs++; + Tcl_SetErrorCode(interp, "TK", "MENU", "ENTRY_EXISTS", (char *)NULL); + return TCL_ERROR; + } + offs++; } /* @@ -2477,22 +2477,22 @@ MenuAddOrInsert( return TCL_ERROR; } - if (idPtr == NULL) { - char idbuf[16]; - /* Generate an id for the new entry on the main menu */ - do { - snprintf(idbuf, sizeof(idbuf), "e%03X", ++menuPtr->serial); - entryPtr = Tcl_CreateHashEntry( + if (idPtr == NULL) { + char idbuf[16]; + /* Generate an id for the new entry on the main menu */ + do { + snprintf(idbuf, sizeof(idbuf), "e%03X", ++menuPtr->serial); + entryPtr = Tcl_CreateHashEntry( &menuListPtr->items, idbuf, &isNew); - } while (!isNew); - idPtr = Tcl_NewStringObj(idbuf, TCL_INDEX_NONE); - } else { - /* Reuse the specified or previously generated id on all clones */ - entryPtr = Tcl_CreateHashEntry( + } while (!isNew); + idPtr = Tcl_NewStringObj(idbuf, TCL_INDEX_NONE); + } else { + /* Reuse the specified or previously generated id on all clones */ + entryPtr = Tcl_CreateHashEntry( &menuListPtr->items, Tcl_GetString(idPtr), &isNew); - } - Tcl_SetHashValue(entryPtr, mePtr); - mePtr->entryPtr = entryPtr; + } + Tcl_SetHashValue(entryPtr, mePtr); + mePtr->entryPtr = entryPtr; /* * If a menu has cascades, then every instance of the menu has to have @@ -2597,26 +2597,26 @@ MenuVarProc( */ if (flags & TCL_TRACE_UNSETS) { - void *probe = NULL; + void *probe = NULL; mePtr->entryFlags &= ~ENTRY_SELECTED; - do { - probe = Tcl_VarTraceInfo(interp, name, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - MenuVarProc, probe); - if (probe == (void *)mePtr) { - break; - } - } while (probe); - if (probe) { - /* - * We were able to fetch the unset trace for our - * namePtr, which means it is not unset and not - * the cause of this unset trace. Instead some outdated - * former variable must be, and we should ignore it. - */ + do { + probe = Tcl_VarTraceInfo(interp, name, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + MenuVarProc, probe); + if (probe == (void *)mePtr) { + break; + } + } while (probe); + if (probe) { + /* + * We were able to fetch the unset trace for our + * namePtr, which means it is not unset and not + * the cause of this unset trace. Instead some outdated + * former variable must be, and we should ignore it. + */ return NULL; - } + } Tcl_TraceVar2(interp, name, NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, clientData); diff --git a/generic/tkObj.c b/generic/tkObj.c index 0b1e104..2eadff3 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -547,7 +547,7 @@ SetPixelFromAny( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected screen distance but got \"%.50s\"", string)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL); } return TCL_ERROR; } @@ -831,7 +831,7 @@ SetMMFromAny( error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected screen distance but got \"%.50s\"", string)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL); return TCL_ERROR; } switch (*rest) { @@ -1132,7 +1132,7 @@ TkParsePadAmount( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad pad value \"%s\": must be positive screen distance", Tcl_GetString(specObj))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", (char *)NULL); return TCL_ERROR; } secondInt = firstInt; @@ -1150,7 +1150,7 @@ TkParsePadAmount( if (objc != 1 && objc != 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "wrong number of parts to pad specification", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "PARTS", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "PARTS", (char *)NULL); return TCL_ERROR; } @@ -1163,7 +1163,7 @@ TkParsePadAmount( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad pad value \"%s\": must be positive screen distance", Tcl_GetString(objv[0]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", (char *)NULL); return TCL_ERROR; } @@ -1179,7 +1179,7 @@ TkParsePadAmount( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad 2nd pad value \"%s\": must be positive screen distance", Tcl_GetString(objv[1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", (char *)NULL); return TCL_ERROR; } diff --git a/generic/tkOption.c b/generic/tkOption.c index e626930..f6976bd 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -881,7 +881,7 @@ ParsePriority( "bad priority level \"%s\": must be " "widgetDefault, startupFile, userDefault, " "interactive, or a number between 0 and 100", string)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PRIORITY", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PRIORITY", (char *)NULL); return -1; } } @@ -965,7 +965,7 @@ AddFromString( if ((*src == '\0') || (*src == '\n')) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing colon on line %d", lineNum)); - Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "COLON", NULL); + Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "COLON", (char *)NULL); return TCL_ERROR; } if ((src[0] == '\\') && (src[1] == '\n')) { @@ -1002,7 +1002,7 @@ AddFromString( if (*src == '\0') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing value on line %d", lineNum)); - Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "VALUE", (char *)NULL); return TCL_ERROR; } @@ -1016,7 +1016,7 @@ AddFromString( if (*src == '\0') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing newline on line %d", lineNum)); - Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "NEWLINE", NULL); + Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "NEWLINE", (char *)NULL); return TCL_ERROR; } if (*src == '\\'){ @@ -1096,7 +1096,7 @@ ReadOptionFile( if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't read options from a file in a safe interpreter", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "OPTION_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "OPTION_FILE", (char *)NULL); return TCL_ERROR; } diff --git a/generic/tkPack.c b/generic/tkPack.c index a7ed8b2..65962bf 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -251,7 +251,7 @@ Tk_PackObjCmd( if (prevPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); - Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); + Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", (char *)NULL); return TCL_ERROR; } return PackAfter(interp, prevPtr, prevPtr->containerPtr, objc-3, objv+3); @@ -285,7 +285,7 @@ Tk_PackObjCmd( if (packPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); - Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); + Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", (char *)NULL); return TCL_ERROR; } containerPtr = packPtr->containerPtr; @@ -309,7 +309,7 @@ Tk_PackObjCmd( if (argv2[0] != '.') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument \"%s\": must be name of window", argv2)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", (char *)NULL); return TCL_ERROR; } return ConfigureContent(interp, tkwin, objc-2, objv+2); @@ -351,7 +351,7 @@ Tk_PackObjCmd( if (contentPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); - Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); + Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", (char *)NULL); return TCL_ERROR; } @@ -1125,7 +1125,7 @@ PackAfter( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: window \"%s\" should be followed by options", Tcl_GetString(objv[0]))); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL); return TCL_ERROR; } @@ -1150,7 +1150,7 @@ PackAfter( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[0]), Tk_PathName(containerPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", (char *)NULL); return TCL_ERROR; } } @@ -1213,7 +1213,7 @@ PackAfter( "wrong # args: \"%s\" option must be" " followed by screen distance", curOpt)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", - NULL); + (char *)NULL); return TCL_ERROR; } if (TkParsePadAmount(interp, tkwin, options[index+1], @@ -1243,7 +1243,7 @@ PackAfter( "wrong # args: \"frame\"" " option must be followed by anchor point", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", - NULL); + (char *)NULL); return TCL_ERROR; } if (Tk_GetAnchorFromObj(interp, options[index+1], @@ -1257,7 +1257,7 @@ PackAfter( " right, expand, fill, fillx, filly, padx, pady, or" " frame", curOpt)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", - NULL); + (char *)NULL); return TCL_ERROR; } } @@ -1586,7 +1586,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack \"%s\": it's a top-level window", Tcl_GetString(objv[j]))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", (char *)NULL); return TCL_ERROR; } contentPtr = GetPacker(content); @@ -1612,7 +1612,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "extra option \"%s\" (option with no value?)", Tcl_GetString(objv[i]))); - Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", NULL); + Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", (char *)NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, @@ -1634,7 +1634,7 @@ ConfigureContent( "window \"%s\" isn't packed", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", - NULL); + (char *)NULL); return TCL_ERROR; } containerPtr = prevPtr->containerPtr; @@ -1692,7 +1692,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad fill style \"%s\": must be " "none, x, y, or both", string)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "FILL", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "FILL", (char *)NULL); return TCL_ERROR; } break; @@ -1718,7 +1718,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipadx value \"%s\": must be positive screen" " distance", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", (char *)NULL); return TCL_ERROR; } contentPtr->iPadX = tmp * 2; @@ -1729,7 +1729,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipady value \"%s\": must be positive screen" " distance", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", (char *)NULL); return TCL_ERROR; } contentPtr->iPadY = tmp * 2; @@ -1809,14 +1809,14 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", (char *)NULL); return TCL_ERROR; } } if (content == containerPtr->tkwin) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack \"%s\" inside itself", Tcl_GetString(objv[j]))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", (char *)NULL); return TCL_ERROR; } @@ -1830,7 +1830,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't put \"%s\" inside \"%s\": would cause management loop", Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", (char *)NULL); return TCL_ERROR; } } diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 25f87bc..b244c9a 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -674,7 +674,7 @@ PanedWindowWidgetObjCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj( "not managed by this window", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", - NULL); + (char *)NULL); } result = TCL_ERROR; } else { @@ -693,15 +693,15 @@ PanedWindowWidgetObjCmd( if (objc <= 4) { tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), pwPtr->tkwin); - if (tkwin == NULL) { - /* - * Just a plain old bad window; Tk_NameToWindow filled in an - * error message for us. - */ - - result = TCL_ERROR; - break; - } + if (tkwin == NULL) { + /* + * Just a plain old bad window; Tk_NameToWindow filled in an + * error message for us. + */ + + result = TCL_ERROR; + break; + } for (i = 0; i < pwPtr->numPanes; i++) { if (pwPtr->panes[i]->tkwin == tkwin) { resultObj = Tk_GetOptionInfo(interp, @@ -799,7 +799,7 @@ ConfigurePanes( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't add %s to itself", arg)); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", (char *)NULL); return TCL_ERROR; } else if (Tk_IsTopLevel(tkwin)) { /* @@ -809,7 +809,7 @@ ConfigurePanes( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't add toplevel %s to %s", arg, Tk_PathName(pwPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", (char *)NULL); return TCL_ERROR; } else { /* @@ -827,7 +827,7 @@ ConfigurePanes( "can't add %s to %s", arg, Tk_PathName(pwPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", - "HIERARCHY", NULL); + "HIERARCHY", (char *)NULL); return TCL_ERROR; } } @@ -887,7 +887,7 @@ ConfigurePanes( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" is not managed by %s", Tk_PathName(tkwin), Tk_PathName(pwPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL); + Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", (char *)NULL); Tk_FreeConfigOptions(&options, pwPtr->paneOpts, pwPtr->tkwin); return TCL_ERROR; @@ -1127,7 +1127,7 @@ PanedWindowSashCommand( if (!ValidSashIndex(pwPtr, sash)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid sash index", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", (char *)NULL); return TCL_ERROR; } panePtr = pwPtr->panes[sash]; @@ -1150,7 +1150,7 @@ PanedWindowSashCommand( if (!ValidSashIndex(pwPtr, sash)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid sash index", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", (char *)NULL); return TCL_ERROR; } @@ -1186,7 +1186,7 @@ PanedWindowSashCommand( if (!ValidSashIndex(pwPtr, sash)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid sash index", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", (char *)NULL); return TCL_ERROR; } @@ -1369,17 +1369,17 @@ PanedWindowEventProc( } else if (eventPtr->type == DestroyNotify) { DestroyPanedWindow(pwPtr); } else if (eventPtr->type == UnmapNotify) { - for (i = 0; i < pwPtr->numPanes; i++) { - if (!pwPtr->panes[i]->hide) { - Tk_UnmapWindow(pwPtr->panes[i]->tkwin); - } - } + for (i = 0; i < pwPtr->numPanes; i++) { + if (!pwPtr->panes[i]->hide) { + Tk_UnmapWindow(pwPtr->panes[i]->tkwin); + } + } } else if (eventPtr->type == MapNotify) { - for (i = 0; i < pwPtr->numPanes; i++) { - if (!pwPtr->panes[i]->hide) { - Tk_MapWindow(pwPtr->panes[i]->tkwin); - } - } + for (i = 0; i < pwPtr->numPanes; i++) { + if (!pwPtr->panes[i]->hide) { + Tk_MapWindow(pwPtr->panes[i]->tkwin); + } + } } } @@ -1789,18 +1789,18 @@ ArrangePanes( */ if (horizontal) { - if (panePtr->width > 0) { - paneSize = panePtr->width; - } else { - paneSize = panePtr->paneWidth; - } + if (panePtr->width > 0) { + paneSize = panePtr->width; + } else { + paneSize = panePtr->paneWidth; + } stretchReserve -= paneSize + (2 * panePtr->padx); } else { - if (panePtr->height > 0) { - paneSize = panePtr->height; - } else { - paneSize = panePtr->paneHeight; - } + if (panePtr->height > 0) { + paneSize = panePtr->height; + } else { + paneSize = panePtr->paneHeight; + } stretchReserve -= paneSize + (2 * panePtr->pady); } if (IsStretchable(panePtr->stretch,i,first,last) @@ -1850,18 +1850,18 @@ ArrangePanes( */ if (horizontal) { - if (panePtr->width > 0) { - paneSize = panePtr->width; - } else { - paneSize = panePtr->paneWidth; - } + if (panePtr->width > 0) { + paneSize = panePtr->width; + } else { + paneSize = panePtr->paneWidth; + } pwSize = pwWidth; } else { - if (panePtr->height > 0) { - paneSize = panePtr->height; - } else { - paneSize = panePtr->paneHeight; - } + if (panePtr->height > 0) { + paneSize = panePtr->height; + } else { + paneSize = panePtr->paneHeight; + } pwSize = pwHeight; } if (IsStretchable(panePtr->stretch, i, first, last)) { @@ -2491,7 +2491,7 @@ SetSticky( "bad stickyness value \"%s\": must be a string" " containing zero or more of n, e, s, and w", Tcl_GetString(*value))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", (char *)NULL); return TCL_ERROR; } } @@ -2907,16 +2907,16 @@ PanedWindowProxyCommand( return TCL_ERROR; } - internalBW = Tk_InternalBorderLeft(pwPtr->tkwin); + internalBW = Tk_InternalBorderLeft(pwPtr->tkwin); if (pwPtr->orient == ORIENT_HORIZONTAL) { if (x < 0) { x = 0; } - pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW); - if (x > pwWidth) { - x = pwWidth; - } - y = Tk_InternalBorderLeft(pwPtr->tkwin); + pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW); + if (x > pwWidth) { + x = pwWidth; + } + y = Tk_InternalBorderLeft(pwPtr->tkwin); sashWidth = pwPtr->sashWidth; sashHeight = Tk_Height(pwPtr->tkwin) - (2 * Tk_InternalBorderLeft(pwPtr->tkwin)); @@ -2924,10 +2924,10 @@ PanedWindowProxyCommand( if (y < 0) { y = 0; } - pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW); - if (y > pwHeight) { - y = pwHeight; - } + pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW); + if (y > pwHeight) { + y = pwHeight; + } x = Tk_InternalBorderLeft(pwPtr->tkwin); sashHeight = pwPtr->sashWidth; sashWidth = Tk_Width(pwPtr->tkwin) - diff --git a/generic/tkPlace.c b/generic/tkPlace.c index f60861a..013c531 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -626,7 +626,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use placer on top-level window \"%s\"; use " "wm command instead", Tk_PathName(tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", (char *)NULL); return TCL_ERROR; } @@ -666,7 +666,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't place \"%s\" relative to \"%s\"", Tk_PathName(contentPtr->tkwin), Tk_PathName(win))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", (char *)NULL); goto error; } } @@ -674,7 +674,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't place \"%s\" relative to itself", Tk_PathName(contentPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", (char *)NULL); goto error; } @@ -688,7 +688,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't put \"%s\" inside \"%s\": would cause management loop", Tk_PathName(contentPtr->tkwin), Tk_PathName(win))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", (char *)NULL); goto error; } } diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 9a36b5b..3478c3c 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -715,7 +715,7 @@ Tk_SelectionObjCmd( if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); - Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL); return TCL_ERROR; } @@ -775,7 +775,7 @@ Tk_SelectionObjCmd( if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); - Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL); return TCL_ERROR; } @@ -853,7 +853,7 @@ Tk_SelectionObjCmd( if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); - Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL); return TCL_ERROR; } @@ -940,7 +940,7 @@ Tk_SelectionObjCmd( if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); - Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL); return TCL_ERROR; } diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 26b9f0c..de91e54 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -62,7 +62,7 @@ SetPixels( if (nullOK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected screen distance or \"\" but got \"%.50s\"", Tcl_GetString(*value))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL); } return TCL_ERROR; } @@ -503,7 +503,7 @@ TkTextTagCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj( "requested illegal events; only key, button, motion," " enter, leave, and virtual events may be used", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "TEXT", "TAG_BIND_EVENT",NULL); + Tcl_SetErrorCode(interp, "TK", "TEXT", "TAG_BIND_EVENT", (char *)NULL); return TCL_ERROR; } } else if (objc == 5) { @@ -1245,7 +1245,7 @@ FindTag( "tag \"%s\" isn't defined in text widget", Tcl_GetString(tagName))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_TAG", - Tcl_GetString(tagName), NULL); + Tcl_GetString(tagName), (char *)NULL); } return NULL; } diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index 954e16f..8c71e48 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -171,7 +171,7 @@ TkTextWindowCmd( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no embedded window at index \"%s\"", Tcl_GetString(objv[3]))); - Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", NULL); + Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", (char *)NULL); return TCL_ERROR; } @@ -209,7 +209,7 @@ TkTextWindowCmd( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no embedded window at index \"%s\"", Tcl_GetString(objv[3]))); - Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", NULL); + Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", (char *)NULL); return TCL_ERROR; } if (objc <= 5) { @@ -443,7 +443,7 @@ EmbWinConfigure( Tk_PathName(ewPtr->body.ew.tkwin), Tk_PathName(textPtr->tkwin))); Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY", - "HIERARCHY", NULL); + "HIERARCHY", (char *)NULL); ewPtr->body.ew.tkwin = NULL; if (client != NULL) { client->tkwin = NULL; @@ -940,7 +940,7 @@ EmbWinLayoutProc( Tk_PathName(ewPtr->body.ew.tkwin), Tk_PathName(textPtr->tkwin))); Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY", "HIERARCHY", - NULL); + (char *)NULL); Tcl_BackgroundException(textPtr->interp, TCL_ERROR); ewPtr->body.ew.tkwin = NULL; goto gotWindow; -- cgit v0.12 From c396a4b95748839c327870844fef288f1b7d973e Mon Sep 17 00:00:00 2001 From: csaba Date: Wed, 19 Jun 2024 18:56:06 +0000 Subject: TTK_STATE_USER1 -> TTK_STATE_FIRST in win/ttkWinXPTheme.c. --- win/ttkWinXPTheme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 755deb4..51b236a 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -805,7 +805,7 @@ static void TabElementDraw( return; if (nbTabsStickBit == TTK_STICK_S) { - if (state & TTK_STATE_USER1) { + if (state & TTK_STATE_FIRST) { partId = TABP_TABITEMLEFTEDGE; } -- cgit v0.12 From 581a06b7efecf3d1acd01cf774fc1821f16b6b31 Mon Sep 17 00:00:00 2001 From: csaba Date: Thu, 20 Jun 2024 15:59:17 +0000 Subject: Improvements in the proc ::tk::ScrollByPixels. --- library/tk.tcl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/tk.tcl b/library/tk.tcl index 7153974..bcbf8ce 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -558,12 +558,12 @@ proc ::tk::PreciseScrollDeltas {dxdy} { return [list $deltaX $deltaY] } -# Helper for smooth scrolling of widgets that support xview moveto, -# yview moveto, height and width. +## Helper for smooth scrolling of widgets that support xview moveto and +## yview moveto. proc ::tk::ScrollByPixels {w deltaX deltaY} { - set width [expr {1.0 * [$w cget -width]}] - set height [expr {1.0 * [$w cget -height]}] + set width [expr {1.0 * [winfo width $w]}] + set height [expr {1.0 * [winfo height $w]}] set X [lindex [$w xview] 0] set Y [lindex [$w yview] 0] set x [expr {$X - $deltaX / $width}] -- cgit v0.12 From 74acf64ef4a52d7b938ec54ffa39e337a3adc924 Mon Sep 17 00:00:00 2001 From: csaba Date: Fri, 21 Jun 2024 20:10:06 +0000 Subject: Updated the Widget Demo script cscroll.tcl. --- library/demos/cscroll.tcl | 11 +++++------ library/demos/widget | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl index 98a4be2..b155d37 100644 --- a/library/demos/cscroll.tcl +++ b/library/demos/cscroll.tcl @@ -79,7 +79,7 @@ if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk # (int)1/-30 = -1, # but # (int)-1/-30 = 0 - # The following code ensure equal +/- behaviour. + # The following code ensures equal +/- behaviour. bind $c { if {%D >= 0} { %W yview scroll [expr {%D/-30}] units @@ -89,9 +89,9 @@ if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk } bind $c { if {%D >= 0} { - %W yview scroll [expr {%D/-3}] units + %W yview scroll [expr {%D/-12}] units } else { - %W yview scroll [expr {(%D-2)/-3}] units + %W yview scroll [expr {(%D-11)/-12}] units } } bind $c { @@ -103,9 +103,9 @@ if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk } bind $c { if {%D >= 0} { - %W xview scroll [expr {%D/-3}] units + %W xview scroll [expr {%D/-12}] units } else { - %W xview scroll [expr {(%D-2)/-3}] units + %W xview scroll [expr {(%D-11)/-12}] units } } } @@ -137,7 +137,6 @@ if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8 } } - proc scrollEnter canvas { global oldFill set id [$canvas find withtag current] diff --git a/library/demos/widget b/library/demos/widget index 59a8d34..4c0d4ad 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -10,7 +10,7 @@ exec wish "$0" ${1+"$@"} # separate ".tcl" files is this directory, which are sourced by this script as # needed. -package require Tk 8.5 +package require Tk 8.5- package require msgcat destroy {*}[winfo children .] -- cgit v0.12 From d5d68cc968cfeb0349723c6d43a0613753b476e9 Mon Sep 17 00:00:00 2001 From: csaba Date: Sat, 22 Jun 2024 14:54:41 +0000 Subject: Some more cleanup, mainly in the Widget Demo. --- library/demos/ctext.tcl | 6 +----- library/demos/floor.tcl | 9 ++------- library/demos/items.tcl | 15 ++++----------- library/demos/widget | 2 +- library/tk.tcl | 10 ++++------ 5 files changed, 12 insertions(+), 30 deletions(-) diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl index 6874226..5fc32f0 100644 --- a/library/demos/ctext.tcl +++ b/library/demos/ctext.tcl @@ -50,11 +50,7 @@ $c bind text "textInsert $c \\n" $c bind text "textBs $c" $c bind text "textBs $c" $c bind text "textDel $c" -if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { - $c bind text "textPaste $c @%x,%y" -} else { - $c bind text "textPaste $c @%x,%y" -} +$c bind text "textPaste $c @%x,%y" # Next, create some items that allow the text's anchor position # to be edited. diff --git a/library/demos/floor.tcl b/library/demos/floor.tcl index 81920ed..9b66116 100644 --- a/library/demos/floor.tcl +++ b/library/demos/floor.tcl @@ -1372,13 +1372,8 @@ $c bind floor2 "floorDisplay $c 2" $c bind floor3 "floorDisplay $c 3" $c bind room "newRoom $c" $c bind room {set currentRoom ""} -if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { - bind $c "$c scan mark %x %y" - bind $c "$c scan dragto %x %y" -} else { - bind $c "$c scan mark %x %y" - bind $c "$c scan dragto %x %y" -} +bind $c "$c scan mark %x %y" +bind $c "$c scan dragto %x %y" bind $c "unset currentRoom" set currentRoom "" trace add variable currentRoom write "roomChanged $c" diff --git a/library/demos/items.tcl b/library/demos/items.tcl index 335971b..5dc14b8 100644 --- a/library/demos/items.tcl +++ b/library/demos/items.tcl @@ -185,17 +185,10 @@ $c create text 28.5c 17.4c -text Scale: -anchor s $c bind item "itemEnter $c" $c bind item "itemLeave $c" -if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { - bind $c "itemMark $c %x %y" - bind $c "itemStroke $c %x %y" - bind $c "$c scan mark %x %y" - bind $c "$c scan dragto %x %y" -} else { - bind $c "$c scan mark %x %y" - bind $c "$c scan dragto %x %y" - bind $c "itemMark $c %x %y" - bind $c "itemStroke $c %x %y" -} +bind $c "$c scan mark %x %y" +bind $c "$c scan dragto %x %y" +bind $c "itemMark $c %x %y" +bind $c "itemStroke $c %x %y" bind $c <> "itemsUnderArea $c" bind $c "itemStartDrag $c %x %y" bind $c "itemDrag $c %x %y" diff --git a/library/demos/widget b/library/demos/widget index 9e7c234..39fbbb1 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -10,7 +10,7 @@ exec wish "$0" ${1+"$@"} # separate ".tcl" files is this directory, which are sourced by this script as # needed. -package require Tk 8.6- +package require Tk 8.7- package require msgcat destroy {*}[winfo children .] diff --git a/library/tk.tcl b/library/tk.tcl index bcbf8ce..7916ccb 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -562,14 +562,12 @@ proc ::tk::PreciseScrollDeltas {dxdy} { ## yview moveto. proc ::tk::ScrollByPixels {w deltaX deltaY} { + set fracX [lindex [$w xview] 0] + set fracY [lindex [$w yview] 0] set width [expr {1.0 * [winfo width $w]}] set height [expr {1.0 * [winfo height $w]}] - set X [lindex [$w xview] 0] - set Y [lindex [$w yview] 0] - set x [expr {$X - $deltaX / $width}] - set y [expr {$Y - $deltaY / $height}] - $w xview moveto $x - $w yview moveto $y + $w xview moveto [expr {$fracX - $deltaX / $width}] + $w yview moveto [expr {$fracY - $deltaY / $height}] } # ::tk::TabToWindow -- -- cgit v0.12 From 5ab67140d1731ad13e636e68300dac32fe358642 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 23 Jun 2024 08:13:09 +0000 Subject: Backout incorrect fix [d7b0c443], that created problem [a0dca39fd1]. --- generic/tkFont.c | 1 - 1 file changed, 1 deletion(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 51c4c18..4141b59 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -1327,7 +1327,6 @@ Tk_GetFontFromObj( FreeFontObj(objPtr); fontPtr = NULL; } else if (Tk_Screen(tkwin) == fontPtr->screen) { - fontPtr->resourceRefCount++; return (Tk_Font) fontPtr; } } -- cgit v0.12 From 18a87e1021b7a5177a4373a841e499f8d245f247 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 23 Jun 2024 08:20:29 +0000 Subject: Fix typo in comment. --- generic/tkFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 4141b59..b1586aa 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -4253,7 +4253,7 @@ Tcl_Obj * TkDebugFont( Tk_Window tkwin, /* The window in which the font will be used * (not currently used). */ - const char *name) /* Name of the desired color. */ + const char *name) /* Name of the desired font. */ { TkFont *fontPtr; Tcl_HashEntry *hashPtr; -- cgit v0.12 From 6af02f49d75679a98b1ca939d9693ced5d567ac1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 23 Jun 2024 15:12:43 +0000 Subject: Fix [610aa08858]: Crash when collapsing toplevel vertically on X11. Thanks to Emiliano Gavilan and Donal Fellows. --- generic/tkFrame.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 32f89f2..302542c 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -1468,10 +1468,14 @@ DisplayFrame( * off-screen memory, then copies it back on-screen in a single operation. * This means there's no point in time where the on-screen image has been * cleared. + * Also, ensure that the pixmap size is at least 1x1 pixels to prevent + * crashes, see [610aa08858]. */ pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin), - Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); + (Tk_Width(tkwin) > 0 ? Tk_Width(tkwin) : 1), + (Tk_Height(tkwin) > 0 ? Tk_Height(tkwin) : 1), + Tk_Depth(tkwin)); #else pixmap = Tk_WindowId(tkwin); #endif /* TK_NO_DOUBLE_BUFFERING */ -- cgit v0.12 From 8c12a6f12a69788e2d20a5a93fc8b3a16b0c804b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Jun 2024 21:44:23 +0000 Subject: Don't use -encoding "binary" any more in Tk --- generic/tkImgBmap.c | 4 ---- generic/tkImgGIF.c | 4 ++-- generic/tkImgPNG.c | 9 ++------- generic/tkImgPPM.c | 5 ----- generic/tkImgPhoto.c | 13 ++----------- win/tkWinWm.c | 5 ----- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index a7da3d9..49de20a 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -513,10 +513,6 @@ TkGetBitmapData( != TCL_OK) { return NULL; } - if (Tcl_SetChannelOption(interp, pi.chan, "-encoding", "binary") - != TCL_OK) { - return NULL; - } } else { pi.chan = NULL; } diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index a58f820..32b01e4 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -1928,8 +1928,8 @@ FileWriteGIF( if (!chan) { return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-translation", - "binary") != TCL_OK) { + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index 2879ae2..a49ed15 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -3765,13 +3765,8 @@ FileWritePNG( goto cleanup; } - /* - * Set the translation mode to binary so that CR and LF are not to the - * platform's EOL sequence. - */ - - if (Tcl_SetChannelOption(interp, chan, "-translation", - "binary") != TCL_OK) { + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) { goto cleanup; } diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index 50d37d7..a9d0391 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -305,11 +305,6 @@ FileWritePPM( Tcl_Close(NULL, chan); return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, chan); - return TCL_ERROR; - } snprintf(header, sizeof(header), "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); Tcl_Write(chan, header, TCL_INDEX_NONE); diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 28c1b5b..0138e68 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -1111,11 +1111,6 @@ ImgPhotoCmd( Tcl_Close(NULL, chan); return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, chan); - return TCL_ERROR; - } if (MatchFileFormat(interp, chan, Tcl_GetString(options.name), options.format, @@ -2166,12 +2161,8 @@ ImgPhotoConfigureModel( metadataOutObj = Tcl_NewDictObj(); Tcl_IncrRefCount(metadataOutObj); - /* - * -translation binary also sets -encoding binary - */ - - if ((Tcl_SetChannelOption(interp, chan, - "-translation", "binary") != TCL_OK) || + if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) || (MatchFileFormat(interp, chan, modelPtr->fileString, modelPtr->format, modelPtr->metadata, metadataOutObj, &imageFormat, &imageFormatVersion3, diff --git a/win/tkWinWm.c b/win/tkWinWm.c index f6d3216..7938539 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -1436,11 +1436,6 @@ ReadIconOrCursorFromFile( Tcl_Close(NULL, channel); return NULL; } - if (Tcl_SetChannelOption(interp, channel, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, channel); - return NULL; - } /* * Allocate memory for the resource structure -- cgit v0.12 From 2de66fa92b783d8956a5df8852deba5fc3af6aa3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 25 Jun 2024 17:17:36 +0000 Subject: Don't use -encoding "binary" any more in Tk. Backport some more formatting changes --- generic/tkImgBmap.c | 46 +++++++-------- generic/tkImgGIF.c | 45 +++++++-------- generic/tkImgPNG.c | 21 +++---- generic/tkImgPPM.c | 13 ++--- generic/tkImgPhoto.c | 155 ++++++++++++++++++++++++--------------------------- win/tkWinWm.c | 65 +++++++++++---------- 6 files changed, 162 insertions(+), 183 deletions(-) diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index a7fd14e..f02b560 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -77,15 +77,15 @@ static int GetByte(Tcl_Channel chan); static int ImgBmapCreate(Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model, - ClientData *clientDataPtr); -static ClientData ImgBmapGet(Tk_Window tkwin, ClientData clientData); -static void ImgBmapDisplay(ClientData clientData, + void **clientDataPtr); +static void *ImgBmapGet(Tk_Window tkwin, void *clientData); +static void ImgBmapDisplay(void *clientData, Display *display, Drawable drawable, int imageX, int imageY, int width, int height, int drawableX, int drawableY); -static void ImgBmapFree(ClientData clientData, Display *display); -static void ImgBmapDelete(ClientData clientData); -static int ImgBmapPostscript(ClientData clientData, +static void ImgBmapFree(void *clientData, Display *display); +static void ImgBmapDelete(void *clientData); +static int ImgBmapPostscript(void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass); @@ -145,9 +145,9 @@ typedef struct ParseInfo { * Prototypes for procedures used only locally in this file: */ -static int ImgBmapCmd(ClientData clientData, Tcl_Interp *interp, +static int ImgBmapCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static void ImgBmapCmdDeletedProc(ClientData clientData); +static void ImgBmapCmdDeletedProc(void *clientData); static void ImgBmapConfigureInstance(BitmapInstance *instancePtr); static int ImgBmapConfigureModel(BitmapModel *modelPtr, int objc, Tcl_Obj *const objv[], int flags); @@ -180,7 +180,7 @@ ImgBmapCreate( TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */ Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ - ClientData *clientDataPtr) /* Store manager's token for image here; it + void **clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { BitmapModel *modelPtr = (BitmapModel *)ckalloc(sizeof(BitmapModel)); @@ -513,10 +513,6 @@ TkGetBitmapData( != TCL_OK) { return NULL; } - if (Tcl_SetChannelOption(interp, pi.chan, "-encoding", "binary") - != TCL_OK) { - return NULL; - } } else { pi.chan = NULL; } @@ -744,7 +740,7 @@ NextBitmapWord( static int ImgBmapCmd( - ClientData clientData, /* Information about the image model. */ + void *clientData, /* Information about the image model. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -768,14 +764,14 @@ ImgBmapCmd( return TCL_ERROR; } return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, - (char *) modelPtr, Tcl_GetString(objv[2]), 0); + (char *)modelPtr, Tcl_GetString(objv[2]), 0); case 1: /* configure */ if (objc == 2) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) modelPtr, NULL, 0); + configSpecs, (char *)modelPtr, NULL, 0); } else if (objc == 3) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) modelPtr, + configSpecs, (char *)modelPtr, Tcl_GetString(objv[2]), 0); } else { return ImgBmapConfigureModel(modelPtr, objc-2, objv+2, @@ -805,11 +801,11 @@ ImgBmapCmd( *---------------------------------------------------------------------- */ -static ClientData +static void * ImgBmapGet( Tk_Window tkwin, /* Window in which the instance will be * used. */ - ClientData modelData) /* Pointer to our model structure for the + void *modelData) /* Pointer to our model structure for the * image. */ { BitmapModel *modelPtr = (BitmapModel *)modelData; @@ -876,7 +872,7 @@ ImgBmapGet( static void ImgBmapDisplay( - ClientData clientData, /* Pointer to BitmapInstance structure for + void *clientData, /* Pointer to BitmapInstance structure for * instance to be displayed. */ Display *display, /* Display on which to draw image. */ Drawable drawable, /* Pixmap or window in which to draw image. */ @@ -937,7 +933,7 @@ ImgBmapDisplay( static void ImgBmapFree( - ClientData clientData, /* Pointer to BitmapInstance structure for + void *clientData, /* Pointer to BitmapInstance structure for * instance to be displayed. */ Display *display) /* Display containing window that used image. */ { @@ -999,7 +995,7 @@ ImgBmapFree( static void ImgBmapDelete( - ClientData modelData) /* Pointer to BitmapModel structure for + void *modelData) /* Pointer to BitmapModel structure for * image. Must not have any more instances. */ { BitmapModel *modelPtr = (BitmapModel *)modelData; @@ -1017,7 +1013,7 @@ ImgBmapDelete( if (modelPtr->maskData != NULL) { ckfree(modelPtr->maskData); } - Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0); + Tk_FreeOptions(configSpecs, (char *)modelPtr, NULL, 0); ckfree(modelPtr); } @@ -1040,7 +1036,7 @@ ImgBmapDelete( static void ImgBmapCmdDeletedProc( - ClientData clientData) /* Pointer to BitmapModel structure for + void *clientData) /* Pointer to BitmapModel structure for * image. */ { BitmapModel *modelPtr = (BitmapModel *)clientData; @@ -1181,7 +1177,7 @@ ImgBmapPsImagemask( static int ImgBmapPostscript( - ClientData clientData, + void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 549a997..5cb43bb 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -111,7 +111,7 @@ typedef struct { * serializing in the GIF format. */ -typedef int (WriteBytesFunc) (ClientData clientData, const char *bytes, +typedef int (WriteBytesFunc) (void *clientData, const char *bytes, int byteCount); /* @@ -135,7 +135,7 @@ static int FileWriteGIF(Tcl_Interp *interp, const char *filename, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); static int StringWriteGIF(Tcl_Interp *interp, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); -static int CommonWriteGIF(Tcl_Interp *interp, ClientData clientData, +static int CommonWriteGIF(Tcl_Interp *interp, void *clientData, WriteBytesFunc *writeProc, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); @@ -280,7 +280,7 @@ typedef struct { */ int initialBits; - ClientData destination; + void *destination; WriteBytesFunc *writeProc; int clearCode; @@ -308,7 +308,7 @@ typedef struct { static int ColorNumber(GifWriterState *statePtr, int red, int green, int blue); -static void Compress(int initBits, ClientData handle, +static void Compress(int initBits, void *handle, WriteBytesFunc *writeProc, ifunptr readValue, GifWriterState *statePtr); static int IsNewColor(GifWriterState *statePtr, @@ -351,7 +351,7 @@ FileMatchGIF( int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here if the file is a valid raw GIF file. */ - Tcl_Interp *interp) /* not used */ + TCL_UNUSED(Tcl_Interp *), /* not used */ { GIFImageConfig gifConf; @@ -603,7 +603,7 @@ FileReadGIF( goto error; } nBytes = fileWidth * fileHeight * 3; - trashBuffer = ckalloc(nBytes); + trashBuffer = (unsigned char *)ckalloc(nBytes); if (trashBuffer) { memset(trashBuffer, 0, nBytes); } @@ -706,7 +706,7 @@ FileReadGIF( goto error; } nBytes = block.pitch * imageHeight; - pixelPtr = ckalloc(nBytes); + pixelPtr = (unsigned char*)ckalloc(nBytes); if (pixelPtr) { memset(pixelPtr, 0, nBytes); } @@ -1050,7 +1050,8 @@ ReadImage( Tcl_Channel chan, int len, int rows, unsigned char cmap[MAXCOLORMAPSIZE][4], - int srcX, int srcY, + TCL_UNUSED(int), + TCL_UNUSED(int), int interlace, int transparent) { @@ -1446,8 +1447,8 @@ Mread( size_t numChunks, /* number of chunks */ MFile *handle) /* mmdecode "file" handle */ { - int i, c; - int count = chunkSize * numChunks; + int c; + int i, count = chunkSize * numChunks; for (i=0; ifromData == INLINE_DATA_BINARY) { MFile *handle = (MFile *) chan; - if (handle->length <= 0 || (size_t) handle->length < hunk*count) { + if ((handle->length <= 0) || ((size_t)handle->length < hunk*count)) { return -1; } - memcpy(dst, handle->data, (size_t) (hunk * count)); + memcpy(dst, handle->data, hunk * count); handle->data += hunk * count; handle->length -= hunk * count; - return (int)(hunk * count); + return hunk * count; } /* * Otherwise we've got a real file to read. */ - return Tcl_Read(chan, (char *) dst, (int) (hunk * count)); + return Tcl_Read(chan, (char *) dst, hunk * count); } /* @@ -1660,8 +1661,8 @@ FileWriteGIF( if (!chan) { return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-translation", - "binary") != TCL_OK) { + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1696,22 +1697,22 @@ StringWriteGIF( static int WriteToChannel( - ClientData clientData, + void *clientData, const char *bytes, int byteCount) { - Tcl_Channel handle = clientData; + Tcl_Channel handle = (Tcl_Channel)clientData; return Tcl_Write(handle, bytes, byteCount); } static int WriteToByteArray( - ClientData clientData, + void *clientData, const char *bytes, int byteCount) { - Tcl_Obj *objPtr = clientData; + Tcl_Obj *objPtr = (Tcl_Obj *)clientData; Tcl_Obj *tmpObj = Tcl_NewByteArrayObj((unsigned char *) bytes, byteCount); Tcl_IncrRefCount(tmpObj); @@ -1723,7 +1724,7 @@ WriteToByteArray( static int CommonWriteGIF( Tcl_Interp *interp, - ClientData handle, + void *handle, WriteBytesFunc *writeProc, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr) @@ -1979,7 +1980,7 @@ ReadValue( static void Compress( int initialBits, - ClientData handle, + void *handle, WriteBytesFunc *writeProc, ifunptr readValue, GifWriterState *statePtr) diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index fccb465..99ba37a 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -2387,7 +2387,8 @@ DecodePNG( * image being read. */ { unsigned long chunkType; - int result, chunkSz; + int result; + int chunkSz; unsigned long crc; /* @@ -2525,11 +2526,11 @@ DecodePNG( pngPtr->thisLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->thisLineObj); - pngPtr->block.pixelPtr = attemptckalloc(pngPtr->blockLen); + pngPtr->block.pixelPtr = (unsigned char *)attemptckalloc(pngPtr->blockLen); if (!pngPtr->block.pixelPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "memory allocation failed", -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); return TCL_ERROR; } @@ -2852,7 +2853,7 @@ WriteData( int srcSz, unsigned long *crcPtr) { - if (!srcPtr || !srcSz) { + if (!srcPtr || srcSz <= 0) { return TCL_OK; } @@ -3135,9 +3136,10 @@ WriteIDAT( PNGImage *pngPtr, Tk_PhotoImageBlock *blockPtr) { - int rowNum, flush = TCL_ZLIB_NO_FLUSH, outputSize, result; + int rowNum, flush = TCL_ZLIB_NO_FLUSH, result; Tcl_Obj *outputObj; unsigned char *outputBytes; + int outputSize; /* * Filter and compress each row one at a time. @@ -3483,13 +3485,8 @@ FileWritePNG( goto cleanup; } - /* - * Set the translation mode to binary so that CR and LF are not to the - * platform's EOL sequence. - */ - - if (Tcl_SetChannelOption(interp, chan, "-translation", - "binary") != TCL_OK) { + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) { goto cleanup; } diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index fe76e36..9d62a66 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -145,7 +145,8 @@ FileReadPPM( * image being read. */ { int fileWidth, fileHeight, maxIntensity; - int nLines, nBytes, h, type, count, bytesPerChannel = 1; + int nLines, h, type, bytesPerChannel = 1; + int nBytes, count; unsigned char *pixelPtr; Tk_PhotoImageBlock block; @@ -303,11 +304,6 @@ FileWritePPM( Tcl_Close(NULL, chan); return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, chan); - return TCL_ERROR; - } snprintf(header, sizeof(header), "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); Tcl_Write(chan, header, -1); @@ -326,7 +322,7 @@ FileWritePPM( for (h = blockPtr->height; h > 0; h--) { pixelPtr = pixLinePtr; for (w = blockPtr->width; w > 0; w--) { - if ( Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 || + if (Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 || Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1) == -1 || Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) == -1) { goto writeerror; @@ -765,7 +761,8 @@ ReadPPMStringHeader( { #define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE], c; - int i, numFields, dataSize, type = 0; + int i, numFields, type = 0; + int dataSize; unsigned char *dataBuffer; dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize); diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index e619910..5d5921b 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -102,9 +102,9 @@ static const char *const optionNames[] = { static int ImgPhotoCreate(Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model, - ClientData *clientDataPtr); -static void ImgPhotoDelete(ClientData clientData); -static int ImgPhotoPostscript(ClientData clientData, + void **clientDataPtr); +static void ImgPhotoDelete(void *clientData); +static int ImgPhotoPostscript(void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psInfo, int x, int y, int width, int height, int prepass); @@ -172,14 +172,14 @@ static const Tk_ConfigSpec configSpecs[] = { * Forward declarations */ -static void PhotoFormatThreadExitProc(ClientData clientData); -static int ImgPhotoCmd(ClientData clientData, Tcl_Interp *interp, +static void PhotoFormatThreadExitProc(void *clientData); +static int ImgPhotoCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int ParseSubcommandOptions( struct SubcommandOptions *optPtr, Tcl_Interp *interp, int allowedOptions, int *indexPtr, int objc, Tcl_Obj *const objv[]); -static void ImgPhotoCmdDeletedProc(ClientData clientData); +static void ImgPhotoCmdDeletedProc(void *clientData); static int ImgPhotoConfigureModel(Tcl_Interp *interp, PhotoModel *modelPtr, int objc, Tcl_Obj *const objv[], int flags); @@ -335,9 +335,9 @@ ImgPhotoCreate( 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). */ - Tk_ImageModel model, /* Token for image, to be used by us in later + Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ - ClientData *clientDataPtr) /* Store manager's token for image here; it + void **clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { PhotoModel *modelPtr; @@ -390,7 +390,7 @@ ImgPhotoCreate( static int ImgPhotoCmd( - ClientData clientData, /* Information about photo model. */ + void *clientData, /* Information about photo model. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -405,15 +405,16 @@ ImgPhotoCmd( PHOTO_WRITE }; - PhotoModel *modelPtr = clientData; - int result, index, x, y, width, height, dataWidth, dataHeight, listObjc; + PhotoModel *modelPtr = (PhotoModel *)clientData; + int result, x, y, width, height, dataWidth, dataHeight, listObjc; + int index; struct SubcommandOptions options; Tcl_Obj **listObjv, **srcObjv; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_Window tkwin; Tk_PhotoImageFormat *imageFormat; - size_t length; + int length; int imageWidth, imageHeight, matched, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; @@ -463,7 +464,7 @@ ImgPhotoCmd( } } else { Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, - (char *) modelPtr, Tcl_GetString(objv[2]), 0); + (char *)modelPtr, Tcl_GetString(objv[2]), 0); } return TCL_OK; } @@ -477,7 +478,7 @@ ImgPhotoCmd( Tcl_Obj *obj, *subobj; result = Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) modelPtr, NULL, 0); + configSpecs, (char *)modelPtr, NULL, 0); if (result != TCL_OK) { return result; } @@ -486,14 +487,14 @@ ImgPhotoCmd( if (modelPtr->dataString) { Tcl_ListObjAppendElement(NULL, subobj, modelPtr->dataString); } else { - Tcl_AppendStringsToObj(subobj, " {}", NULL); + Tcl_AppendStringsToObj(subobj, " {}", (char *)NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewStringObj("-format {} {} {}", 16); if (modelPtr->format) { Tcl_ListObjAppendElement(NULL, subobj, modelPtr->format); } else { - Tcl_AppendStringsToObj(subobj, " {}", NULL); + Tcl_AppendStringsToObj(subobj, " {}", (char *)NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_ListObjAppendList(interp, obj, Tcl_GetObjResult(interp)); @@ -505,7 +506,7 @@ ImgPhotoCmd( length = objv[2]->length; if (length > 1 && !strncmp(arg, "-data", length)) { - Tcl_AppendResult(interp, "-data {} {} {}", NULL); + Tcl_AppendResult(interp, "-data {} {} {}", (char *)NULL); if (modelPtr->dataString) { /* * TODO: Modifying result is bad! @@ -514,12 +515,12 @@ ImgPhotoCmd( Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), modelPtr->dataString); } else { - Tcl_AppendResult(interp, " {}", NULL); + Tcl_AppendResult(interp, " {}", (char *)NULL); } return TCL_OK; } else if (length > 1 && !strncmp(arg, "-format", length)) { - Tcl_AppendResult(interp, "-format {} {} {}", NULL); + Tcl_AppendResult(interp, "-format {} {} {}", (char *)NULL); if (modelPtr->format) { /* * TODO: Modifying result is bad! @@ -528,7 +529,7 @@ ImgPhotoCmd( Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), modelPtr->format); } else { - Tcl_AppendResult(interp, " {}", NULL); + Tcl_AppendResult(interp, " {}", (char *)NULL); } return TCL_OK; } else { @@ -573,7 +574,7 @@ ImgPhotoCmd( "image \"%s\" doesn't exist or is not a photo image", Tcl_GetString(options.name))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO", - Tcl_GetString(options.name), NULL); + Tcl_GetString(options.name), (char *)NULL); return TCL_ERROR; } Tk_PhotoGetImage(srcHandle, &block); @@ -583,7 +584,7 @@ ImgPhotoCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); return TCL_ERROR; } @@ -658,7 +659,7 @@ ImgPhotoCmd( options.toY2) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); return TCL_ERROR; } } @@ -701,7 +702,7 @@ ImgPhotoCmd( || (options.fromY2 > modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); if (options.background) { Tk_FreeColor(options.background); } @@ -822,7 +823,7 @@ ImgPhotoCmd( "%s get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", - NULL); + (char *)NULL); return TCL_ERROR; } @@ -1051,7 +1052,7 @@ ImgPhotoCmd( if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get image from a file in a safe interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL); return TCL_ERROR; } @@ -1069,11 +1070,6 @@ ImgPhotoCmd( Tcl_Close(NULL, chan); return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, chan); - return TCL_ERROR; - } if (MatchFileFormat(interp, chan, Tcl_GetString(options.name), options.format, &imageFormat, @@ -1092,7 +1088,7 @@ ImgPhotoCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1114,7 +1110,7 @@ ImgPhotoCmd( Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1207,7 +1203,7 @@ ImgPhotoCmd( "%s transparency get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", - NULL); + (char *)NULL); return TCL_ERROR; } @@ -1237,7 +1233,7 @@ ImgPhotoCmd( "%s transparency set: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", - NULL); + (char *)NULL); return TCL_ERROR; } @@ -1302,7 +1298,7 @@ ImgPhotoCmd( if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't write image to a file in a safe interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL); return TCL_ERROR; } @@ -1332,7 +1328,7 @@ ImgPhotoCmd( || (options.fromY2 > modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); if (options.background) { Tk_FreeColor(options.background); } @@ -1414,7 +1410,7 @@ ImgPhotoCmd( fmtString)); } Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", - fmtString, NULL); + fmtString, (char *)NULL); if (options.background) { Tk_FreeColor(options.background); } @@ -1513,9 +1509,9 @@ ParseSubcommandOptions( * TK_PHOTO_COMPOSITE_* constants. */ NULL }; - size_t length; - int index, c, bit, currentBit; - int values[4], numValues, maxValues, argIndex; + int index, length, argIndex; + int c, bit, currentBit; + int values[4], numValues, maxValues; const char *option, *expandedOption, *needed; const char *const *listPtr; Tcl_Obj *msgObj; @@ -1526,8 +1522,7 @@ ParseSubcommandOptions( * optPtr->name. */ - expandedOption = option = Tcl_GetString(objv[index]); - length = objv[index]->length; + expandedOption = option = Tcl_GetStringFromObj(objv[index], &length); if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; @@ -1724,20 +1719,20 @@ ParseSubcommandOptions( oneValueRequired: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the \"%s\" option requires a value", expandedOption)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", (char *)NULL); return TCL_ERROR; manyValuesRequired: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the \"%s\" option requires one %s integer values", expandedOption, (maxValues == 2) ? "or two": "to four")); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", (char *)NULL); return TCL_ERROR; numberOutOfRange: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value(s) for the %s option must be %s", expandedOption, needed)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_VALUE", (char *)NULL); return TCL_ERROR; unknownOrAmbiguousOption: @@ -1757,7 +1752,7 @@ ParseSubcommandOptions( bit <<= 1; } Tcl_SetObjResult(interp, msgObj); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", (char *)NULL); return TCL_ERROR; } @@ -1795,15 +1790,14 @@ ImgPhotoConfigureModel( const char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL; Tcl_Obj *tempdata, *tempformat; - size_t length; - int i, result, imageWidth, imageHeight, oldformat; + int i, length; + int result, imageWidth, imageHeight, oldformat; double oldGamma; Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; for (i = 0; i < objc; i++) { - const char *arg = Tcl_GetString(objv[i]); - length = objv[i]->length; + const char *arg = Tcl_GetStringFromObj(objv[i], &length); if ((length > 1) && (arg[0] == '-')) { if ((arg[1] == 'd') && !strncmp(arg, "-data", length)) { @@ -1813,7 +1807,7 @@ ImgPhotoConfigureModel( Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-data\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "MISSING_VALUE", NULL); + "MISSING_VALUE", (char *)NULL); return TCL_ERROR; } } else if ((arg[1] == 'f') && @@ -1824,7 +1818,7 @@ ImgPhotoConfigureModel( Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-format\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "MISSING_VALUE", NULL); + "MISSING_VALUE", (char *)NULL); return TCL_ERROR; } } @@ -1915,7 +1909,7 @@ ImgPhotoConfigureModel( modelPtr->height) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); goto errorExit; } @@ -1936,7 +1930,7 @@ ImgPhotoConfigureModel( Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get image from a file in a safe interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL); goto errorExit; } @@ -1945,12 +1939,8 @@ ImgPhotoConfigureModel( goto errorExit; } - /* - * -translation binary also sets -encoding binary - */ - - if ((Tcl_SetChannelOption(interp, chan, - "-translation", "binary") != TCL_OK) || + if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) || (MatchFileFormat(interp, chan, modelPtr->fileString, modelPtr->format, &imageFormat, &imageWidth, &imageHeight, &oldformat) != TCL_OK)) { @@ -1962,7 +1952,7 @@ ImgPhotoConfigureModel( Tcl_Close(NULL, chan); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); goto errorExit; } tempformat = modelPtr->format; @@ -1993,7 +1983,7 @@ ImgPhotoConfigureModel( if (ImgPhotoSetSize(modelPtr, imageWidth, imageHeight) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); goto errorExit; } tempformat = modelPtr->format; @@ -2133,7 +2123,7 @@ ToggleComplexAlphaIfNeeded( static void ImgPhotoDelete( - ClientData modelData) /* Pointer to PhotoModel structure for image. + void *modelData) /* Pointer to PhotoModel structure for image. * Must not have any more instances. */ { PhotoModel *modelPtr = (PhotoModel *)modelData; @@ -2185,7 +2175,7 @@ ImgPhotoDelete( static void ImgPhotoCmdDeletedProc( - ClientData clientData) /* Pointer to PhotoModel structure for + void *clientData) /* Pointer to PhotoModel structure for * image. */ { PhotoModel *modelPtr = (PhotoModel *)clientData; @@ -2422,7 +2412,8 @@ MatchFileFormat( * here. */ int *oldformat) /* Returns 1 if the old image API is used. */ { - int matched = 0, useoldformat = 0; + int matched = 0; + int useoldformat = 0; Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -2450,7 +2441,7 @@ MatchFileFormat( "-file option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_FILE_FORMAT", NULL); + "NOT_FILE_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2484,7 +2475,7 @@ MatchFileFormat( "-file option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_FILE_FORMAT", NULL); + "NOT_FILE_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2510,13 +2501,13 @@ MatchFileFormat( "image file format \"%s\" is not supported", formatString)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", - formatString, NULL); + formatString, (char *)NULL); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't recognize data in image file \"%s\"", fileName)); Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE", - "UNRECOGNIZED_DATA", NULL); + "UNRECOGNIZED_DATA", (char *)NULL); } return TCL_ERROR; } @@ -2590,7 +2581,7 @@ MatchStringFormat( "-data option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_DATA_FORMAT", NULL); + "NOT_DATA_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2617,7 +2608,7 @@ MatchStringFormat( "-data option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_DATA_FORMAT", NULL); + "NOT_DATA_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2636,12 +2627,12 @@ MatchStringFormat( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image format \"%s\" is not supported", formatString)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", - formatString, NULL); + formatString, (char *)NULL); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't recognize image data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "UNRECOGNIZED_DATA", NULL); + "UNRECOGNIZED_DATA", (char *)NULL); } return TCL_ERROR; } @@ -2678,7 +2669,7 @@ Tk_FindPhoto( const char *imageName) /* Name of the desired photo image. */ { const Tk_ImageType *typePtr; - ClientData clientData = + void *clientData = Tk_GetImageMasterData(interp, imageName, &typePtr); if ((typePtr == NULL) || (typePtr->name != tkPhotoImageType.name)) { @@ -2789,7 +2780,7 @@ Tk_PhotoPutBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -2806,7 +2797,7 @@ Tk_PhotoPutBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } goto errorExit; } @@ -3235,7 +3226,7 @@ Tk_PhotoPutZoomedBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -3251,7 +3242,7 @@ Tk_PhotoPutZoomedBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } goto errorExit; } @@ -3656,7 +3647,7 @@ Tk_PhotoExpand( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -3731,7 +3722,7 @@ Tk_PhotoSetSize( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -4074,7 +4065,7 @@ Tk_PhotoGetImage( static int ImgPhotoPostscript( - ClientData clientData, /* Handle for the photo image. */ + void *clientData, /* Handle for the photo image. */ Tcl_Interp *interp, /* Interpreter. */ TCL_UNUSED(Tk_Window), /* (unused) */ Tk_PostscriptInfo psInfo, /* Postscript info. */ diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 90503a6..60554c4 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -423,14 +423,14 @@ static void TkWmStackorderToplevelWrapperMap(TkWindow *winPtr, Display *display, Tcl_HashTable *table); static LRESULT CALLBACK TopLevelProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); -static void TopLevelEventProc(ClientData clientData, +static void TopLevelEventProc(void *clientData, XEvent *eventPtr); -static void TopLevelReqProc(ClientData dummy, Tk_Window tkwin); -static void UpdateGeometryInfo(ClientData clientData); +static void TopLevelReqProc(void *dummy, Tk_Window tkwin); +static void UpdateGeometryInfo(void *clientData); static void UpdateWrapper(TkWindow *winPtr); static LRESULT CALLBACK WmProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); -static void WmWaitVisibilityOrMapProc(ClientData clientData, +static void WmWaitVisibilityOrMapProc(void *clientData, XEvent *eventPtr); static BlockOfIconImagesPtr ReadIconOrCursorFromFile(Tcl_Interp *interp, Tcl_Obj* fileName, BOOL isIcon); @@ -1583,11 +1583,6 @@ ReadIconOrCursorFromFile( Tcl_Close(NULL, channel); return NULL; } - if (Tcl_SetChannelOption(interp, channel, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, channel); - return NULL; - } /* * Allocate memory for the resource structure @@ -1671,7 +1666,7 @@ ReadIconOrCursorFromFile( */ dwBytesRead = Tcl_Read(channel, (char *)lpIR->IconImages[i].lpBits, - (int) lpIDE[i].dwBytesInRes); + (int)lpIDE[i].dwBytesInRes); if (dwBytesRead != lpIDE[i].dwBytesInRes) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file: %s", Tcl_PosixError(interp))); @@ -2765,7 +2760,7 @@ TkWmSetClass( int Tk_WmObjCmd( - ClientData clientData, /* Main window associated with interpreter. */ + void *clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -3023,8 +3018,8 @@ WmAttributesCmd( WmInfo *wmPtr = winPtr->wmInfoPtr; LONG style, exStyle, styleBit, *stylePtr = NULL; const char *string; - int i, boolean; - int length; + int boolValue; + int i, length; int config_fullscreen = 0, updatewrapper = 0; int fullscreen_attr_changed = 0, fullscreen_attr = 0; @@ -3054,19 +3049,19 @@ WmAttributesCmd( Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj("-disabled", -1)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewBooleanObj((style & WS_DISABLED))); + Tcl_NewBooleanObj(style & WS_DISABLED)); Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj("-fullscreen", -1)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewBooleanObj((wmPtr->flags & WM_FULLSCREEN))); + Tcl_NewBooleanObj(wmPtr->flags & WM_FULLSCREEN)); Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj("-toolwindow", -1)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewBooleanObj((exStyle & WS_EX_TOOLWINDOW))); + Tcl_NewBooleanObj(exStyle & WS_EX_TOOLWINDOW)); Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj("-topmost", -1)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewBooleanObj((exStyle & WS_EX_TOPMOST))); + Tcl_NewBooleanObj(exStyle & WS_EX_TOPMOST)); Tcl_SetObjResult(interp, objPtr); return TCL_OK; } @@ -3199,7 +3194,7 @@ WmAttributesCmd( } } else { if ((i < objc-1) - && Tcl_GetBooleanFromObj(interp, objv[i+1], &boolean) + && Tcl_GetBooleanFromObj(interp, objv[i+1], &boolValue) != TCL_OK) { return TCL_ERROR; } @@ -3209,13 +3204,13 @@ WmAttributesCmd( wmPtr->flags & WM_FULLSCREEN)); } else { fullscreen_attr_changed = 1; - fullscreen_attr = boolean; + fullscreen_attr = boolValue; } config_fullscreen = 0; } else if (objc == 4) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj(*stylePtr & styleBit)); - } else if (boolean) { + } else if (boolValue) { *stylePtr |= styleBit; } else { *stylePtr &= ~styleBit; @@ -3313,7 +3308,7 @@ WmAttributesCmd( static int WmClientCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3358,7 +3353,7 @@ WmClientCmd( != 0) { XSetWMClientMachine(winPtr->display, winPtr->window, &textProp); - XFree((char *) textProp.value); + XFree((char *)textProp.value); } } return TCL_OK; @@ -3391,7 +3386,8 @@ WmColormapwindowsCmd( { WmInfo *wmPtr = winPtr->wmInfoPtr; TkWindow **cmapList, *winPtr2, **winPtr2Ptr = &winPtr2; - int i, windowObjc, gotToplevel; + int i, windowObjc; + int gotToplevel; Tcl_Obj **windowObjv, *resultObj; if ((objc != 3) && (objc != 4)) { @@ -3656,7 +3652,7 @@ static int WmForgetCmd( TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ - Tcl_Interp *interp, /* Current interpreter. */ + TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */ TCL_UNUSED(int), /* Number of arguments. */ TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */ { @@ -4296,7 +4292,8 @@ WmIconphotoCmd( TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */ Tk_PhotoHandle photo; Tk_PhotoImageBlock block; - int i, width, height, idx, bufferSize, startObj = 3; + int i; + int width, height, idx, bufferSize, startObj = 3; union {unsigned char *ptr; void *voidPtr;} bgraPixel; union {unsigned char *ptr; void *voidPtr;} bgraMask; BlockOfIconImagesPtr lpIR; @@ -4809,7 +4806,7 @@ WmOverrideredirectCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - int boolean, curValue; + int boolValue, curValue; XSetWindowAttributes atts; if ((objc != 3) && (objc != 4)) { @@ -4831,19 +4828,19 @@ WmOverrideredirectCmd( Tcl_SetObjResult(interp, Tcl_NewBooleanObj(curValue)); return TCL_OK; } - if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) { + if (Tcl_GetBooleanFromObj(interp, objv[3], &boolValue) != TCL_OK) { return TCL_ERROR; } - if (curValue != boolean) { + if (curValue != boolValue) { if (winPtr->flags & TK_EMBEDDED) { - SendMessageW(wmPtr->wrapper, TK_OVERRIDEREDIRECT, boolean, 0); + SendMessageW(wmPtr->wrapper, TK_OVERRIDEREDIRECT, boolValue, 0); } else { /* * Only do this if we are really changing value, because it causes * some funky stuff to occur. */ - atts.override_redirect = (boolean) ? True : False; + atts.override_redirect = boolValue ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); if (!(wmPtr->flags & (WM_NEVER_MAPPED)) @@ -5695,7 +5692,7 @@ WmUpdateGeom( static void WmWaitVisibilityOrMapProc( - ClientData clientData, /* Pointer to window. */ + void *clientData, /* Pointer to window. */ XEvent *eventPtr) /* Information about event. */ { TkWindow *winPtr = (TkWindow *)clientData; @@ -5911,7 +5908,7 @@ Tk_UnsetGrid( static void TopLevelEventProc( - ClientData clientData, /* Window for which event occurred. */ + void *clientData, /* Window for which event occurred. */ XEvent *eventPtr) /* Event that just happened. */ { TkWindow *winPtr = (TkWindow *)clientData; @@ -5998,7 +5995,7 @@ TopLevelReqProc( static void UpdateGeometryInfo( - ClientData clientData) /* Pointer to the window's record. */ + void *clientData) /* Pointer to the window's record. */ { int x, y; /* Position of border on desktop. */ int width, height; /* Size of client area. */ @@ -6673,7 +6670,7 @@ TkWmStackorderToplevelEnumProc( /*fprintf(stderr, "Looking up HWND %d\n", hwnd);*/ - hPtr = Tcl_FindHashEntry(pair->table, (char *) hwnd); + hPtr = Tcl_FindHashEntry(pair->table, (char *)hwnd); if (hPtr != NULL) { childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr); -- cgit v0.12 From 98d2bd8937c5c086172fac19356692b01fc0bcc9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 26 Jun 2024 10:58:29 +0000 Subject: Fix build (missing ')'). Some indenting --- generic/tkImgGIF.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 5cb43bb..33bf004 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -351,7 +351,7 @@ FileMatchGIF( int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here if the file is a valid raw GIF file. */ - TCL_UNUSED(Tcl_Interp *), /* not used */ + TCL_UNUSED(Tcl_Interp *)) { GIFImageConfig gifConf; @@ -1198,24 +1198,24 @@ ReadImage( } firstCode = append[code]; - /* - * Push the head of the code onto the stack. - */ + /* + * Push the head of the code onto the stack. + */ - *top++ = firstCode; + *top++ = firstCode; - if (maxCode < (1 << MAX_LWZ_BITS)) { + if (maxCode < (1 << MAX_LWZ_BITS)) { /* * If there's still room in our codes table, add a new entry. * Otherwise don't, and keep using the current table. - * See DEFERRED CLEAR CODE IN LZW COMPRESSION in the GIF89a - * specification. + * See DEFERRED CLEAR CODE IN LZW COMPRESSION in the GIF89a + * specification. */ prefix[maxCode] = oldCode; append[maxCode] = firstCode; maxCode++; - } + } /* * maxCode tells us the maximum code value we can accept. If @@ -1447,8 +1447,8 @@ Mread( size_t numChunks, /* number of chunks */ MFile *handle) /* mmdecode "file" handle */ { - int c; - int i, count = chunkSize * numChunks; + int i, c; + int count = chunkSize * numChunks; for (i=0; ifromData == INLINE_DATA_BINARY) { MFile *handle = (MFile *) chan; - if ((handle->length <= 0) || ((size_t)handle->length < hunk*count)) { + if ((handle->length <= 0) || ((size_t)handle->length < hunk * count)) { return -1; } memcpy(dst, handle->data, hunk * count); -- cgit v0.12 From 7037c4e3f8bf46f21bd3c18da0a39a67a871d26d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 26 Jun 2024 10:59:33 +0000 Subject: Sync nmakehelp.c with Tcl --- win/nmakehlp.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 4d95662..4fc9f7a 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -19,7 +19,6 @@ #pragma comment (lib, "kernel32.lib") #endif #include -#include /* * This library is required for x64 builds with _some_ versions of MSVC @@ -91,7 +90,7 @@ main( case 'c': if (argc != 3) { chars = snprintf(msg, sizeof(msg) - 1, - "usage: %s -c \n" + "usage: %s -c \n" "Tests for whether cl.exe supports an option\n" "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]); WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, @@ -319,11 +318,11 @@ CheckForCompilerFeature( */ return !(strstr(Out.buffer, "D4002") != NULL - || strstr(Err.buffer, "D4002") != NULL - || strstr(Out.buffer, "D9002") != NULL - || strstr(Err.buffer, "D9002") != NULL - || strstr(Out.buffer, "D2021") != NULL - || strstr(Err.buffer, "D2021") != NULL); + || strstr(Err.buffer, "D4002") != NULL + || strstr(Out.buffer, "D9002") != NULL + || strstr(Err.buffer, "D9002") != NULL + || strstr(Out.buffer, "D2021") != NULL + || strstr(Err.buffer, "D2021") != NULL); } static int @@ -601,9 +600,9 @@ list_free(list_item_t **listPtrPtr) * * Usage is something like: * nmakehlp -S << $** > $@ - * @PACKAGE_NAME@ $(PACKAGE_NAME) - * @PACKAGE_VERSION@ $(PACKAGE_VERSION) - * << + * @PACKAGE_NAME@ $(PACKAGE_NAME) + * @PACKAGE_VERSION@ $(PACKAGE_VERSION) + * << */ static int @@ -727,11 +726,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) int keylen, ret; WIN32_FIND_DATA finfo; - if (dir == NULL || keypath == NULL) + if (dir == NULL || keypath == NULL) { return 2; /* Have no real error reporting mechanism into nmake */ + } dirlen = strlen(dir); - if ((dirlen + 3) > sizeof(path)) + if ((dirlen + 3) > sizeof(path)) { return 2; + } strncpy(path, dir, dirlen); strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */ keylen = strlen(keypath); @@ -746,8 +747,9 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) #else hSearch = FindFirstFile(path, &finfo); #endif - if (hSearch == INVALID_HANDLE_VALUE) + if (hSearch == INVALID_HANDLE_VALUE) { return 1; /* Not found */ + } /* Loop through all subdirs checking if the keypath is under there */ ret = 1; /* Assume not found */ @@ -757,11 +759,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * We need to check it is a directory despite the * FindExSearchLimitToDirectories in the above call. See SDK docs */ - if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { continue; + } sublen = strlen(finfo.cFileName); - if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) + if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) { continue; /* Path does not fit, assume not matched */ + } strncpy(path+dirlen+1, finfo.cFileName, sublen); path[dirlen+1+sublen] = '\\'; strncpy(path+dirlen+1+sublen+1, keypath, keylen+1); @@ -781,13 +785,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * LocateDependency -- * * Locates a dependency for a package. - * keypath - a relative path within the package directory - * that is used to confirm it is the correct directory. + * keypath - a relative path within the package directory + * that is used to confirm it is the correct directory. * The search path for the package directory is currently only - * the parent and grandparent of the current working directory. - * If found, the command prints - * name_DIRPATH= - * and returns 0. If not found, does not print anything and returns 1. + * the parent and grandparent of the current working directory. + * If found, the command prints + * name_DIRPATH= + * and returns 0. If not found, does not print anything and returns 1. */ static int LocateDependency(const char *keypath) { @@ -797,8 +801,9 @@ static int LocateDependency(const char *keypath) for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) { ret = LocateDependencyHelper(paths[i], keypath); - if (ret == 0) + if (ret == 0) { return ret; + } } return ret; } -- cgit v0.12 From c9b34b133759197c64efea804480ca15824154f9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 30 Jun 2024 15:04:08 +0000 Subject: macos-11 is no longer available on GITHUB, so switch to macos-12 --- .github/workflows/mac-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 9fd297a..23c2238 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -13,7 +13,7 @@ env: ERROR_ON_FAILURES: 1 jobs: xcode: - runs-on: macos-11 + runs-on: macos-12 defaults: run: shell: bash @@ -57,7 +57,7 @@ jobs: fi timeout-minutes: 30 clang: - runs-on: macos-11 + runs-on: macos-12 strategy: matrix: symbols: -- cgit v0.12