Index: generic/tk.h ================================================================== --- generic/tk.h +++ generic/tk.h @@ -230,10 +230,11 @@ #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) /* * The following structure and function types are used by TK_OPTION_CUSTOM Index: generic/tkButton.c ================================================================== --- generic/tkButton.c +++ generic/tkButton.c @@ -1091,44 +1091,14 @@ Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->activeBorder); } else { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->wrapLengthObj, &wrapLength); - if (wrapLength < 0) { - wrapLength = 0; - Tcl_DecrRefCount(butPtr->wrapLengthObj); - butPtr->wrapLengthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->wrapLengthObj); - } Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - borderWidth = 0; - Tcl_DecrRefCount(butPtr->borderWidthObj); - butPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->borderWidthObj); - } Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - highlightWidth = 0; - Tcl_DecrRefCount(butPtr->highlightWidthObj); - butPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->highlightWidthObj); - } Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &padX); - if (padX < 0) { - padX = 0; - Tcl_DecrRefCount(butPtr->padXObj); - butPtr->padXObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->padXObj); - } Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &padY); - if (padY < 0) { - padY = 0; - Tcl_DecrRefCount(butPtr->padYObj); - butPtr->padYObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->padYObj); - } if (butPtr->type >= TYPE_CHECK_BUTTON) { Tcl_Obj *valuePtr, *namePtr; if (butPtr->selVarNamePtr == NULL) { Index: generic/tkCanvas.c ================================================================== --- generic/tkCanvas.c +++ generic/tkCanvas.c @@ -2291,65 +2291,11 @@ Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, (Tcl_Obj *)canvasPtr->textInfo.reserved2, &canvasPtr->textInfo.insertWidth); Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, (Tcl_Obj *)canvasPtr->textInfo.reserved3, &canvasPtr->textInfo.selBorderWidth); Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->widthObj, &width); Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->xScrollIncrementObj, &xScrollIncrement); Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->yScrollIncrementObj, &yScrollIncrement); - if (borderWidth < 0) { - borderWidth = 0; - Tcl_DecrRefCount(canvasPtr->borderWidthObj); - canvasPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(canvasPtr->borderWidthObj); - } - if (height < 0) { - height = 0; - Tcl_DecrRefCount(canvasPtr->heightObj); - canvasPtr->heightObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(canvasPtr->heightObj); - } - if (highlightWidth < 0) { - highlightWidth = 0; - Tcl_DecrRefCount(canvasPtr->highlightWidthObj); - canvasPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(canvasPtr->highlightWidthObj); - } - if (width < 0) { - width = 0; - Tcl_DecrRefCount(canvasPtr->widthObj); - canvasPtr->widthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(canvasPtr->widthObj); - } - if (xScrollIncrement < 0) { - xScrollIncrement = 0; - Tcl_DecrRefCount(canvasPtr->xScrollIncrementObj); - canvasPtr->xScrollIncrementObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(canvasPtr->xScrollIncrementObj); - } - if (yScrollIncrement < 0) { - yScrollIncrement = 0; - Tcl_DecrRefCount(canvasPtr->yScrollIncrementObj); - canvasPtr->yScrollIncrementObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(canvasPtr->yScrollIncrementObj); - } canvasPtr->inset = borderWidth + highlightWidth; - if (canvasPtr->textInfo.insertBorderWidth < 0) { - canvasPtr->textInfo.insertBorderWidth = 0; - Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved1); - canvasPtr->textInfo.reserved1 = Tcl_NewIntObj(0); - Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved1); - } - if (canvasPtr->textInfo.insertWidth < 0) { - canvasPtr->textInfo.insertWidth = 0; - Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved2); - canvasPtr->textInfo.reserved2 = Tcl_NewIntObj(0); - Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved2); - } - if (canvasPtr->textInfo.selBorderWidth < 0) { - canvasPtr->textInfo.selBorderWidth = 0; - Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved3); - canvasPtr->textInfo.reserved3 = Tcl_NewIntObj(0); - Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved3); - } gcValues.function = GXcopy; gcValues.graphics_exposures = False; gcValues.foreground = Tk_3DBorderColor(canvasPtr->bgBorder)->pixel; newGC = Tk_GetGC(canvasPtr->tkwin, Index: generic/tkConfig.c ================================================================== --- generic/tkConfig.c +++ generic/tkConfig.c @@ -1019,15 +1019,19 @@ valuePtr = NULL; newPixels = INT_MIN; } else if (Tk_GetPixelsFromObj(nullOK ? NULL : interp, tkwin, valuePtr, &newPixels) != TCL_OK) { if (nullOK) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "expected screen distance or \"\" but got \"%.50s\"", Tcl_GetString(valuePtr))); + wrongPixel: + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "expected screen distance%s but got \"%.50s\"", + (nullOK ? " or \"\"": ""), Tcl_GetString(valuePtr))); Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL); } return TCL_ERROR; + } else if (!(optionPtr->specPtr->flags & TK_OPTION_NEG_OK) && (newPixels < 0)) { + goto wrongPixel; } if (internalPtr != NULL) { *((int *)oldInternalPtr) = *((int *)internalPtr); *((int *)internalPtr) = newPixels; } Index: generic/tkEntry.c ================================================================== --- generic/tkEntry.c +++ generic/tkEntry.c @@ -1188,44 +1188,14 @@ border = entryPtr->normalBorder; } Tk_SetBackgroundFromBorder(entryPtr->tkwin, border); Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - borderWidth = 0; - Tcl_DecrRefCount(entryPtr->borderWidthObj); - entryPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(entryPtr->borderWidthObj); - } Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - highlightWidth = 0; - Tcl_DecrRefCount(entryPtr->highlightWidthObj); - entryPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(entryPtr->highlightWidthObj); - } Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertBorderWidthObj, &insertBorderWidth); - if (insertBorderWidth < 0) { - insertBorderWidth = 0; - Tcl_DecrRefCount(entryPtr->insertBorderWidthObj); - entryPtr->insertBorderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(entryPtr->insertBorderWidthObj); - } Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertWidthObj, &insertWidth); - if (insertWidth < 0) { - insertWidth = 0; - Tcl_DecrRefCount(entryPtr->insertWidthObj); - entryPtr->insertWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(entryPtr->insertWidthObj); - } Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->selBorderWidthObj, &selBorderWidth); - if (selBorderWidth < 0) { - selBorderWidth = 0; - Tcl_DecrRefCount(entryPtr->selBorderWidthObj); - entryPtr->selBorderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(entryPtr->selBorderWidthObj); - } if (entryPtr->type == TK_SPINBOX) { if (sbPtr->fromValue > sbPtr->toValue) { /* * Swap -from and -to values. Index: generic/tkFrame.c ================================================================== --- generic/tkFrame.c +++ generic/tkFrame.c @@ -985,45 +985,15 @@ } else { Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None); } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->widthObj, &width); - if (width < 0) { - Tcl_DecrRefCount(framePtr->widthObj); - framePtr->widthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->widthObj); - } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->heightObj, &height); - if (height < 0) { - Tcl_DecrRefCount(framePtr->heightObj); - framePtr->heightObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->heightObj); - } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - Tcl_DecrRefCount(framePtr->borderWidthObj); - framePtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->borderWidthObj); - } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - Tcl_DecrRefCount(framePtr->highlightWidthObj); - framePtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->highlightWidthObj); - } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->padXObj, &padX); - if (padX < 0) { - Tcl_DecrRefCount(framePtr->padXObj); - framePtr->padXObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->padXObj); - } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->padYObj, &padY); - if (padY < 0) { - Tcl_DecrRefCount(framePtr->padYObj); - framePtr->padYObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->padYObj); - } /* * If a -labelwidget is specified, check that it is valid and set up * geometry management for it. */ Index: generic/tkListbox.c ================================================================== --- generic/tkListbox.c +++ generic/tkListbox.c @@ -1560,11 +1560,11 @@ { Tk_SavedOptions savedOptions; Tcl_Obj *oldListObj = NULL; Tcl_Obj *errorResult = NULL; int oldExport, error; - int borderWidth, selBorderWidth, highlightWidth; + int borderWidth, highlightWidth; oldExport = (listPtr->exportSelection) && (!Tcl_IsSafe(listPtr->interp)); if (listPtr->listVarNameObj != NULL) { Tcl_UntraceVar2(interp, Tcl_GetString(listPtr->listVarNameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, @@ -1598,30 +1598,11 @@ */ Tk_SetBackgroundFromBorder(listPtr->tkwin, listPtr->normalBorder); Tk_GetPixelsFromObj(NULL, listPtr->tkwin, listPtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - borderWidth = 0; - Tcl_DecrRefCount(listPtr->borderWidthObj); - listPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(listPtr->borderWidthObj); - } Tk_GetPixelsFromObj(NULL, listPtr->tkwin, listPtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - highlightWidth = 0; - Tcl_DecrRefCount(listPtr->highlightWidthObj); - listPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(listPtr->highlightWidthObj); - } - Tk_GetPixelsFromObj(NULL, listPtr->tkwin, listPtr->selBorderWidthObj, &selBorderWidth); - if (selBorderWidth < 0) { - selBorderWidth = 0; - Tcl_DecrRefCount(listPtr->selBorderWidthObj); - listPtr->selBorderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(listPtr->selBorderWidthObj); - } listPtr->inset = highlightWidth + borderWidth; /* * Claim the selection if we've suddenly started exporting it and * there is a selection to export and this interp is unsafe. Index: generic/tkMenubutton.c ================================================================== --- generic/tkMenubutton.c +++ generic/tkMenubutton.c @@ -481,12 +481,10 @@ { Tk_SavedOptions savedOptions; Tcl_Obj *errorResult = NULL; int error; Tk_Image image; - int borderWidth, highlightWidth; - int padX, padY; /* * Eliminate any existing trace on variables monitored by the menubutton. */ @@ -535,39 +533,10 @@ Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->activeBorder); } else { Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->normalBorder); } - Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->borderWidthObj, &borderWidth); - Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->highlightWidthObj, &highlightWidth); - Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->padXObj, &padX); - Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->padYObj, &padY); - if (borderWidth < 0) { - borderWidth = 0; - Tcl_DecrRefCount(mbPtr->borderWidthObj); - mbPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(mbPtr->borderWidthObj); - } - if (highlightWidth < 0) { - highlightWidth = 0; - Tcl_DecrRefCount(mbPtr->highlightWidthObj); - mbPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(mbPtr->highlightWidthObj); - } - if (padX < 0) { - padX = 0; - Tcl_DecrRefCount(mbPtr->padXObj); - mbPtr->padXObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(mbPtr->padXObj); - } - if (padY < 0) { - padY = 0; - Tcl_DecrRefCount(mbPtr->padYObj); - mbPtr->padYObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(mbPtr->padYObj); - } - /* * Get the image for the widget, if there is one. Allocate the new * image before freeing the old one, so that the reference count * doesn't go to zero and cause image data to be discarded. */ Index: generic/tkMessage.c ================================================================== --- generic/tkMessage.c +++ generic/tkMessage.c @@ -437,11 +437,10 @@ int objc, /* Number of valid entries in argv. */ Tcl_Obj *const objv[], /* Arguments. */ TCL_UNUSED(int)) /* Flags to pass to Tk_ConfigureWidget. */ { Tk_SavedOptions savedOptions; - int width, borderWidth, highlightWidth, padX, padY; /* * Eliminate any existing trace on a variable monitored by the message. */ @@ -478,55 +477,10 @@ Tcl_IncrRefCount(msgPtr->stringObj); } Tcl_TraceVar2(interp, Tcl_GetString(msgPtr->textVarNameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MessageTextVarProc, msgPtr); - } - - /* - * A few other options need special processing, such as setting the - * background from a 3-D border or handling special defaults that couldn't - * be specified to Tk_ConfigureWidget. - */ - - Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width); - if (width < 0) { - if (msgPtr->widthObj) { - Tcl_DecrRefCount(msgPtr->widthObj); - } - msgPtr->widthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(msgPtr->widthObj); - } - Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - if (msgPtr->borderWidthObj) { - Tcl_DecrRefCount(msgPtr->borderWidthObj); - } - msgPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(msgPtr->borderWidthObj); - } - Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - if (msgPtr->highlightWidthObj) { - Tcl_DecrRefCount(msgPtr->highlightWidthObj); - } - msgPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(msgPtr->highlightWidthObj); - } - if (msgPtr->padXObj) { - Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX); - if (padX < 0) { - Tcl_DecrRefCount(msgPtr->padXObj); - msgPtr->padXObj = NULL; - } - } - if (msgPtr->padYObj) { - Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY); - if (padY < 0) { - Tcl_DecrRefCount(msgPtr->padYObj); - msgPtr->padYObj = NULL; - } } Tk_FreeSavedOptions(&savedOptions); MessageWorldChanged(msgPtr); return TCL_OK; Index: generic/tkOldConfig.c ================================================================== --- generic/tkOldConfig.c +++ generic/tkOldConfig.c @@ -517,42 +517,46 @@ case TK_CONFIG_JOIN_STYLE: if (Tk_GetJoinStyle(interp, value, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; - case TK_CONFIG_PIXELS: { - int nullOK = specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1); + case TK_CONFIG_PIXELS: if (specPtr->specFlags & TK_CONFIG_OBJS) { int dummy; if (nullValue) { if (*(Tcl_Obj **)ptr != NULL) { Tcl_DecrRefCount(*(Tcl_Obj **)ptr); *(Tcl_Obj **)ptr = NULL; } - } else if (Tk_GetPixelsFromObj((nullOK ? NULL : interp), tkwin, arg, &dummy) + } else if (Tk_GetPixelsFromObj(((specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1)) ? NULL : interp), tkwin, arg, &dummy) != TCL_OK) { - wrongPixel: - if (interp && nullOK) { + if (interp && (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1))) { Tcl_AppendResult(interp, "expected screen distance or \"\" but got \"", Tcl_GetString(arg), "\"", (char *)NULL); } return TCL_ERROR; + } else if (!(specPtr->specFlags & TK_OPTION_NEG_OK) && (dummy < 0)) { + if (interp) { + Tcl_AppendResult(interp, "expected screen distance ", + (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1)) ? " or \"\"" : "", + "but got \"", Tcl_GetString(arg), "\"", (char *)NULL); + } + return TCL_ERROR; } else { Tcl_IncrRefCount(arg); if (*(Tcl_Obj **)ptr != NULL) { Tcl_DecrRefCount(*(Tcl_Obj **)ptr); } *(Tcl_Obj **)ptr = arg; } } else if (nullValue) { *(int *)ptr = INT_MIN; - } else if (Tk_GetPixelsFromObj((nullOK ? NULL : interp), tkwin, arg, (int *)ptr) + } else if (Tk_GetPixelsFromObj(interp, tkwin, arg, (int *)ptr) != TCL_OK) { - goto wrongPixel; + return TCL_ERROR; } break; - } case TK_CONFIG_MM: if (Tk_GetScreenMM(interp, tkwin, value, (double *)ptr) != TCL_OK) { return TCL_ERROR; } break; Index: generic/tkPanedWindow.c ================================================================== --- generic/tkPanedWindow.c +++ generic/tkPanedWindow.c @@ -919,15 +919,10 @@ int minSize; Tk_SetOptions(interp, pwPtr->panes[j], pwPtr->paneOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL); Tk_GetPixelsFromObj(NULL, tkwin, pwPtr->panes[j]->minSizeObj, &minSize); - if (minSize < 0) { - Tcl_DecrRefCount(pwPtr->panes[j]->minSizeObj); - pwPtr->panes[j]->minSizeObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(pwPtr->panes[j]->minSizeObj); - } found = 1; /* * If the pane is supposed to move, add it to the inserts * array now; otherwise, leave it where it is. @@ -985,15 +980,10 @@ panePtr->paneHeight = panePtr->height; } else { panePtr->paneHeight = Tk_ReqHeight(tkwin) + doubleBw; } Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->minSizeObj, &minSize); - if (minSize < 0) { - Tcl_DecrRefCount(panePtr->minSizeObj); - panePtr->minSizeObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(panePtr->minSizeObj); - } /* * Set up the geometry management callbacks for this pane. */ Index: generic/tkPlace.c ================================================================== --- generic/tkPlace.c +++ generic/tkPlace.c @@ -82,11 +82,11 @@ {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", TCL_INDEX_NONE, 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, NULL, offsetof(Content, heightObj), - offsetof(Content, height), TK_OPTION_NULL_OK, 0, 0}, + offsetof(Content, height), TK_OPTION_NULL_OK|TK_OPTION_NEG_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, NULL, offsetof(Content, relHeightObj), offsetof(Content, relHeight), TK_OPTION_NULL_OK, 0, 0}, @@ -96,15 +96,15 @@ {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0.0", TCL_INDEX_NONE, 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, NULL, offsetof(Content, widthObj), - offsetof(Content, width), TK_OPTION_NULL_OK, 0, 0}, + offsetof(Content, width), TK_OPTION_NULL_OK|TK_OPTION_NEG_OK, 0, 0}, {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Content, xObj), - offsetof(Content, x), 0, 0, 0}, + offsetof(Content, x), TK_OPTION_NEG_OK, 0, 0}, {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Content, yObj), - offsetof(Content, y), 0, 0, 0}, + offsetof(Content, y), TK_OPTION_NEG_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; /* * For each container window that has a content managed by the placer there is a Index: generic/tkScale.c ================================================================== --- generic/tkScale.c +++ generic/tkScale.c @@ -673,18 +673,10 @@ ComputeFormat(scalePtr, 1); Tk_SetBackgroundFromBorder(scalePtr->tkwin, scalePtr->bgBorder); Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - highlightWidth = 0; - if (scalePtr->highlightWidthObj) { - Tcl_DecrRefCount(scalePtr->highlightWidthObj); - } - scalePtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(scalePtr->highlightWidthObj); - } Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); scalePtr->inset = highlightWidth + borderWidth; break; } if (!error) { Index: generic/tkScrollbar.c ================================================================== --- generic/tkScrollbar.c +++ generic/tkScrollbar.c @@ -469,47 +469,15 @@ * already have values for some fields. */ Tcl_Size objc, /* Number of valid entries in argv. */ Tcl_Obj *const objv[], /* Arguments. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { - int width, borderWidth, highlightWidth, elementBorderWidth; - if (Tk_ConfigureWidget(interp, scrollPtr->tkwin, configSpecs, objc, objv, scrollPtr, flags) != TCL_OK) { return TCL_ERROR; } - /* - * A few options need special processing, such as setting the background - * from a 3-D border. - */ - - Tk_GetPixelsFromObj(NULL, scrollPtr->tkwin, scrollPtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - Tcl_DecrRefCount(scrollPtr->borderWidthObj); - scrollPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(scrollPtr->borderWidthObj); - } - Tk_GetPixelsFromObj(NULL, scrollPtr->tkwin, scrollPtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - Tcl_DecrRefCount(scrollPtr->highlightWidthObj); - scrollPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(scrollPtr->highlightWidthObj); - } - Tk_GetPixelsFromObj(NULL, scrollPtr->tkwin, scrollPtr->widthObj, &width); - if (width < 0) { - Tcl_DecrRefCount(scrollPtr->widthObj); - scrollPtr->widthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(scrollPtr->widthObj); - } - if (scrollPtr->elementBorderWidthObj) { - Tk_GetPixelsFromObj(NULL, scrollPtr->tkwin, scrollPtr->elementBorderWidthObj, &elementBorderWidth); - if (elementBorderWidth < 0) { - Tcl_DecrRefCount(scrollPtr->elementBorderWidthObj); - scrollPtr->elementBorderWidthObj = NULL; - } - } /* * Configure platform specific options. */ TkpConfigureScrollbar(scrollPtr); Index: generic/tkText.c ================================================================== --- generic/tkText.c +++ generic/tkText.c @@ -2203,56 +2203,17 @@ /* * Don't allow negative spacings. */ Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing1Obj, &spacing1); - if (spacing1 < 0) { - spacing1 = 0; - Tcl_DecrRefCount(textPtr->spacing1Obj); - textPtr->spacing1Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->spacing1Obj); - } Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing2Obj, &spacing2); - if (spacing2 < 0) { - spacing2 = 0; - Tcl_DecrRefCount(textPtr->spacing2Obj); - textPtr->spacing2Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->spacing2Obj); - } Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing3Obj, &spacing3); - if (spacing3 < 0) { - spacing3 = 0; - Tcl_DecrRefCount(textPtr->spacing3Obj); - textPtr->spacing3Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->spacing3Obj); - } Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->insertBorderWidthObj, &insertBorderWidth); - if (insertBorderWidth < 0) { - insertBorderWidth = 0; - Tcl_DecrRefCount(textPtr->insertBorderWidthObj); - textPtr->insertBorderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->insertBorderWidthObj); - } Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->insertWidthObj, &insertWidth); - if (insertWidth < 0) { - insertWidth = 0; - Tcl_DecrRefCount(textPtr->insertWidthObj); - textPtr->insertWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->insertWidthObj); - } if (textPtr->selBorderWidthObj) { Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->selBorderWidthObj, &selBorderWidth); } - if (selBorderWidth < 0) { - selBorderWidth = 0; - if (textPtr->selBorderWidthObj) { - Tcl_DecrRefCount(textPtr->selBorderWidthObj); - } - textPtr->selBorderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->selBorderWidthObj); - } - /* * Parse tab stops. */ Index: generic/tkTextDisp.c ================================================================== --- generic/tkTextDisp.c +++ generic/tkTextDisp.c @@ -5248,16 +5248,10 @@ Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padXObj, &padX); Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padYObj, &padY); Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->highlightWidthObj, &highlightWidth); - if (highlightWidth < 0) { - highlightWidth = 0; - Tcl_DecrRefCount(textPtr->highlightWidthObj); - textPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->highlightWidthObj); - } dInfoPtr->x = highlightWidth + borderWidth + padX; dInfoPtr->y = highlightWidth + borderWidth + padY; dInfoPtr->maxX = Tk_Width(textPtr->tkwin) - highlightWidth - borderWidth - padX; if (dInfoPtr->maxX <= dInfoPtr->x) { Index: generic/tkTextTag.c ================================================================== --- generic/tkTextTag.c +++ generic/tkTextTag.c @@ -40,11 +40,11 @@ {TK_OPTION_PIXELS, "-lmargin2", NULL, NULL, NULL, offsetof(TkTextTag, lMargin2Obj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0}, {TK_OPTION_BORDER, "-lmargincolor", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-offset", NULL, NULL, - NULL, offsetof(TkTextTag, offsetObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, + NULL, offsetof(TkTextTag, offsetObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK|TK_OPTION_NEG_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-overstrike", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrike), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-overstrikefg", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeColor), @@ -361,50 +361,10 @@ * -justify, require additional translation (this is needed * because we need to distinguish a particular value of an option * from "unspecified"). */ - if (tagPtr->borderWidthObj) { - int borderWidth; - Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - borderWidth = 0; - Tcl_DecrRefCount(tagPtr->borderWidthObj); - tagPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->borderWidthObj); - } - } - if (tagPtr->spacing1Obj) { - int spacing1; - Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing1Obj, &spacing1); - if (spacing1 < 0) { - spacing1 = 0; - Tcl_DecrRefCount(tagPtr->spacing1Obj); - tagPtr->spacing1Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->spacing1Obj); - } - } - if (tagPtr->spacing2Obj) { - int spacing2; - Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing2Obj, &spacing2); - if (spacing2 < 0) { - spacing2 = 0; - Tcl_DecrRefCount(tagPtr->spacing2Obj); - tagPtr->spacing2Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->spacing2Obj); - } - } - if (tagPtr->spacing3Obj) { - int spacing3; - Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->spacing3Obj, &spacing3); - if (spacing3 < 0) { - spacing3 = 0; - Tcl_DecrRefCount(tagPtr->spacing3Obj); - tagPtr->spacing3Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->spacing3Obj); - } - } if (tagPtr->tabArrayPtr != NULL) { ckfree(tagPtr->tabArrayPtr); tagPtr->tabArrayPtr = NULL; } if (tagPtr->tabStringPtr != NULL) { Index: tests/button.test ================================================================== --- tests/button.test +++ tests/button.test @@ -2667,15 +2667,15 @@ } -cleanup { destroy .c } -result {} test button-1.271 {configuration options: fallback to default} -setup { - checkbutton .c -borderwidth -2 -highlightthickness -2 -font {Helvetica -12 bold} + checkbutton .c -borderwidth 0 -highlightthickness 0 -font {Helvetica -12 bold} pack .c update } -body { - .c configure -padx -2 -pady -2 -wraplength -2 + .c configure -padx 0 -pady 0 -wraplength 0 list [.c cget -padx] [.c cget -pady] [.c cget -borderwidth] [.c cget -highlightthickness] [.c cget -wraplength] } -cleanup { destroy .c } -result {0 0 0 0 0} Index: tests/entry.test ================================================================== --- tests/entry.test +++ tests/entry.test @@ -318,11 +318,11 @@ } -body { .e configure -highlightthickness -2 .e cget -highlightthickness } -cleanup { destroy .e -} -result 0 +} -returnCodes error -result {expected screen distance but got "-2"} test entry-1.29 {configuration option: "highlightthickness" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e ; update idletasks update } -body { Index: tests/font.test ================================================================== --- tests/font.test +++ tests/font.test @@ -1695,11 +1695,11 @@ test font-27.2 {Tk_UnderlineTextLayout procedure: underline not visible} -body { .t.f config -text "000 00000" -wrap [expr $ax*7] -under 10 } -result {} test font-27.3 {Tk_UnderlineTextLayout procedure: underline is visible} -body { .t.f config -text "000 00000" -wrap [expr $ax*7] -under 5 - .t.f config -wrap -1 -underline {} + .t.f config -wrap 0 -underline {} } -result {} destroy .t.f Index: tests/listbox.test ================================================================== --- tests/listbox.test +++ tests/listbox.test @@ -201,11 +201,11 @@ test listbox-1.31 {configuration options} -body { .l configure -highlightthickness -2 list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness] } -cleanup { .l configure -highlightthickness [lindex [.l configure -highlightthickness] 3] -} -result {0 0} +} -returnCodes error -result {expected screen distance but got "-2"} test listbox-1.32.1 {configuration options} -setup { set res {} } -body { .l configure -justify left set res [list [lindex [.l configure -justify] 4] [.l cget -justify]] @@ -1240,11 +1240,11 @@ } -body { .l configure -highlightthickness -3 .l cget -highlightthickness } -cleanup { deleteWindows -} -result 0 +} -returnCodes error -result {expected screen distance but got "-3"} test listbox-4.3 {ConfigureListbox procedure} -setup { deleteWindows destroy .l listbox .l -setgrid 1 -width 25 -height 15 pack .l Index: tests/message.test ================================================================== --- tests/message.test +++ tests/message.test @@ -392,19 +392,19 @@ .m configure -width badValue } -cleanup { destroy .m } -returnCodes error -result {expected screen distance but got "badValue"} test message-1.39 {configuration options, fallback to default} -setup { - message .m -borderwidth -2 -highlightthickness -2 -font {Helvetica -12 bold} + message .m -borderwidth 0 -highlightthickness 0 -font {Helvetica -12 bold} pack .m update } -body { .m configure -padx -2 -pady -2 -width -2 list [.m cget -padx] [.m cget -pady] [.m cget -borderwidth] [.m cget -highlightthickness] [.m cget -width] } -cleanup { destroy .m -} -result {{} {} 0 0 0} +} -returnCodes error -result {expected screen distance or "" but got "-2"} test message-2.1 {Tk_MessageObjCmd procedure} -body { message } -returnCodes error -result {wrong # args: should be "message pathName ?-option value ...?"} Index: tests/panedwindow.test ================================================================== --- tests/panedwindow.test +++ tests/panedwindow.test @@ -1663,17 +1663,17 @@ # respecting minsizes. .p sash coord 0 } -cleanup { deleteWindows } -result [list 50 0] -test panedwindow-17.10 {MoveSash, move right, negative minsize becomes 0} -setup { +test panedwindow-17.10 {MoveSash, move right, zero minsize} -setup { deleteWindows } -body { panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 foreach w {.f1 .f2 .f3} c {red blue} { .p add [frame $w -height 20 -width 20 -bg $c] \ - -sticky nsew -minsize -50 + -sticky nsew -minsize 0 } .p sash place 0 50 0 # Get the new sash coord; it should have moved as far as possible, @@ -1798,17 +1798,17 @@ # respecting minsizes. .p sash coord 1 } -cleanup { deleteWindows } -result [list 42 0] -test panedwindow-17.18 {MoveSash, move left, negative minsize becomes 0} -setup { +test panedwindow-17.18 {MoveSash, move left, zero minsize} -setup { deleteWindows } -body { panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 foreach w {.f1 .f2 .f3} c {red blue green} { .p add [frame $w -height 20 -width 20 -bg $c] \ - -sticky nsew -minsize -50 + -sticky nsew -minsize 0 } .p sash place 1 10 0 # Get the new sash coord; it should have moved as far as possible, @@ -1985,18 +1985,18 @@ # respecting minsizes. .p sash coord 0 } -cleanup { deleteWindows } -result [list 0 50] -test panedwindow-18.10 {MoveSash, move right, negative minsize becomes 0} -setup { +test panedwindow-18.10 {MoveSash, move right, zero minsize} -setup { deleteWindows } -body { panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \ -orient vertical foreach w {.f1 .f2 .f3} c {red blue} { .p add [frame $w -height 20 -width 20 -bg $c] \ - -sticky nsew -minsize -50 + -sticky nsew -minsize 0 } .p sash place 0 0 50 # Get the new sash coord; it should have moved as far as possible, @@ -2128,18 +2128,18 @@ # respecting minsizes. .p sash coord 1 } -cleanup { deleteWindows } -result [list 0 42] -test panedwindow-18.18 {MoveSash, move up, negative minsize becomes 0} -setup { +test panedwindow-18.18 {MoveSash, move up, zero minsize} -setup { deleteWindows } -body { panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 \ -orient vertical foreach w {.f1 .f2 .f3} c {red blue green} { .p add [frame $w -height 20 -width 20 -bg $c] \ - -sticky nsew -minsize -50 + -sticky nsew -minsize 0 } .p sash place 1 0 10 # Get the new sash coord; it should have moved as far as possible, Index: tests/scrollbar.test ================================================================== --- tests/scrollbar.test +++ tests/scrollbar.test @@ -82,12 +82,11 @@ {-command "set x" {set x} {} {}} {-elementborderwidth 4 4 badValue {expected screen distance or "" but got "badValue"}} {-cursor arrow arrow badValue {bad cursor spec "badValue"}} {-highlightbackground #112233 #112233 ugly {unknown color name "ugly"}} {-highlightcolor #123456 #123456 bogus {unknown color name "bogus"}} - {-highlightthickness 6 6 bogus {expected screen distance but got "bogus"}} - {-highlightthickness -2 0 {} {}} + {-highlightthickness 6 6 -2 {expected screen distance but got "-2"}} {-jump true 1 silly {expected boolean value but got "silly"}} {-orient horizontal horizontal badValue {bad orientation "badValue": must be vertical or horizontal}} {-orient horizontal horizontal bogus {bad orientation "bogus": must be vertical or horizontal}} {-relief ridge ridge badValue {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}} Index: tests/spinbox.test ================================================================== --- tests/spinbox.test +++ tests/spinbox.test @@ -478,11 +478,11 @@ } -body { .e configure -highlightthickness -2 .e cget -highlightthickness } -cleanup { destroy .e -} -result 0 +} -returnCodes error -result {expected screen distance but got "-2"} test spinbox-1.41 {configuration option: "increment"} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken pack .e Index: tests/text.test ================================================================== --- tests/text.test +++ tests/text.test @@ -301,11 +301,11 @@ } -body { .t configure -highlightthickness -2 .t cget -highlightthickness } -cleanup { destroy .t -} -result 0 +} -returnCodes error -result {expected screen distance but got "-2"} test text-1.30 {configuration option: "highlightthickness"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t update } -body { @@ -595,11 +595,11 @@ } -body { .t configure -spacing1 -5 .t cget -spacing1 } -cleanup { destroy .t -} -result 0 +} -returnCodes error -result {expected screen distance but got "-5"} test text-1.60 {configuration option: "spacing1"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t update } -body { @@ -633,11 +633,11 @@ } -body { .t configure -spacing2 -1 .t cget -spacing2 } -cleanup { destroy .t -} -result 0 +} -returnCodes error -result {expected screen distance but got "-1"} test text-1.64 {configuration option: "spacing2"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t update } -body { @@ -671,11 +671,11 @@ } -body { .t configure -spacing3 -10 .t cget -spacing3 } -cleanup { destroy .t -} -result 0 +} -returnCodes error -result {expected screen distance but got "-10"} test text-1.68 {configuration option: "spacing3"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t update } -body { @@ -3310,27 +3310,27 @@ } -body { .t configure -spacing1 -2 -spacing2 1 -spacing3 1 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {0 1 1} +} -returnCodes {error} -result {expected screen distance but got "-2"} test text-14.3 {ConfigureText procedure} -setup { text .t } -body { .t configure -spacing1 1 -spacing2 -1 -spacing3 1 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {1 0 1} +} -returnCodes {error} -result {expected screen distance but got "-1"} test text-14.4 {ConfigureText procedure} -setup { text .t } -body { .t configure -spacing1 1 -spacing2 1 -spacing3 -3 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {1 1 0} +} -returnCodes {error} -result {expected screen distance but got "-3"} test text-14.5 {ConfigureText procedure} -setup { text .t } -body { .t configure -tabs {30 foo} } -cleanup {