From 19cb6769c6c765a88656be5ff4c87bb90a21503a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 30 Aug 2024 23:03:06 +0000 Subject: Fix typo's. Backport more usefull parts from 9.0 --- generic/tkFont.c | 10 +- generic/tkGrab.c | 10 +- generic/tkGrid.c | 64 ++-- generic/tkImgBmap.c | 16 +- generic/tkImgGIF.c | 52 +-- generic/tkImgListFormat.c | 782 +++++++++++++++++++++++----------------------- generic/tkPointer.c | 12 +- generic/tkScrollbar.c | 16 +- tests/button.test | 8 +- tests/canvText.test | 2 +- tests/entry.test | 2 +- tests/font.test | 22 +- tests/imgBmap.test | 2 +- tests/message.test | 2 +- tests/spinbox.test | 2 +- 15 files changed, 502 insertions(+), 500 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index bb0b34f..ecad770 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -633,7 +633,7 @@ Tk_FontObjCmd( } if ((namedHashPtr == NULL) || nfPtr->deletePending) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "named font \"%s\" doesn't exist", string)); + "named font \"%s\" does not exist", string)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); return TCL_ERROR; } @@ -1039,7 +1039,7 @@ TkDeleteNamedFont( if (namedHashPtr == NULL) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "named font \"%s\" doesn't exist", name)); + "named font \"%s\" does not exist", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", name, NULL); } return TCL_ERROR; @@ -3215,8 +3215,8 @@ TkIntersectAngledTextLayout( PointInQuadrilateral(cx, cy, rx[1], ry[1]) && PointInQuadrilateral(cx, cy, rx[2], ry[2]) && PointInQuadrilateral(cx, cy, rx[3], ry[3])) { - return 0; - } + return 0; + } } /* @@ -3754,7 +3754,7 @@ ParseFontNameObj( || (objc < 1)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "font \"%s\" doesn't exist", string)); + "font \"%s\" does not exist", string)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); } return TCL_ERROR; diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 5b7cbde..f131e83 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -524,24 +524,24 @@ Tk_Grab( if (grabResult == GrabNotViewable) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: window not viewable", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRAB", "UNVIEWABLE", NULL); + Tcl_SetErrorCode(interp, "TK", "GRAB", "UNVIEWABLE", (char *)NULL); } else if (grabResult == AlreadyGrabbed) { alreadyGrabbed: Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: another application has grab", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRAB", "GRABBED", NULL); + Tcl_SetErrorCode(interp, "TK", "GRAB", "GRABBED", (char *)NULL); } else if (grabResult == GrabFrozen) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: keyboard or pointer frozen", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRAB", "FROZEN", NULL); + Tcl_SetErrorCode(interp, "TK", "GRAB", "FROZEN", (char *)NULL); } else if (grabResult == GrabInvalidTime) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: invalid time", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRAB", "BAD_TIME", NULL); + Tcl_SetErrorCode(interp, "TK", "GRAB", "BAD_TIME", (char *)NULL); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "grab failed for unknown reason (code %d)", grabResult)); - Tcl_SetErrorCode(interp, "TK", "GRAB", "UNKNOWN", NULL); + Tcl_SetErrorCode(interp, "TK", "GRAB", "UNKNOWN", (char *)NULL); } return TCL_ERROR; } diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 078ae9e..c4ebef6 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -417,7 +417,7 @@ Tk_GridObjCmd( /* This should not happen */ Tcl_SetObjResult(interp, Tcl_NewStringObj("internal error in grid", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL); + Tcl_SetErrorCode(interp, "TK", "API_ABUSE", (char *)NULL); return TCL_ERROR; } @@ -1018,7 +1018,7 @@ GridRowColumnConfigureCommand( if (lObjc == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("no %s indices specified", (slotType == COLUMN) ? "column" : "row")); - Tcl_SetErrorCode(interp, "TK", "GRID", "NO_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "NO_INDEX", (char *)NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } @@ -1031,7 +1031,7 @@ GridRowColumnConfigureCommand( if (lObjc != 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "must specify a single element on retrieval", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRID", "USAGE", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "USAGE", (char *)NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } @@ -1039,7 +1039,7 @@ GridRowColumnConfigureCommand( Tcl_AppendResult(interp, " (when retrieving options only integer indices are " "allowed)", NULL); - Tcl_SetErrorCode(interp, "TK", "GRID", "INDEX_FORMAT", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "INDEX_FORMAT", (char *)NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } @@ -1144,14 +1144,14 @@ GridRowColumnConfigureCommand( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the window \"%s\" is not managed by \"%s\"", Tcl_GetString(lObjv[j]), Tcl_GetString(objv[2]))); - Tcl_SetErrorCode(interp, "TK", "GRID", "NOT_MANAGED", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "NOT_MANAGED", (char *)NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "illegal index \"%s\"", Tcl_GetString(lObjv[j]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID_INDEX", (char *)NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } @@ -1175,7 +1175,7 @@ GridRowColumnConfigureCommand( "\"%s\" is out of range", Tcl_GetString(lObjv[j]))); Tcl_SetErrorCode(interp, "TK", "GRID", "INDEX_RANGE", - NULL); + (char *)NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } @@ -1282,7 +1282,7 @@ GridRowColumnConfigureCommand( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid arg \"%s\": should be non-negative", Tcl_GetString(objv[i]))); - Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", (char *)NULL); return TCL_ERROR; } @@ -1388,7 +1388,7 @@ GridContentCommand( if (value < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%d is an invalid value: should NOT be < 0", value)); - Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", (char *)NULL); return TCL_ERROR; } if (index == CONTENT_COLUMN) { @@ -2553,8 +2553,8 @@ SetContentColumn( lastCol = ((newColumn >= 0) ? newColumn : 0) + newNumCols; if (lastCol >= MAX_ELEMENT) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("column out of bounds",-1)); - Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_COLUMN", NULL); + Tcl_SetObjResult(interp, Tcl_NewStringObj("column out of bounds", TCL_INDEX_NONE)); + Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_COLUMN", (char *)NULL); return TCL_ERROR; } @@ -2595,7 +2595,7 @@ SetContentRow( lastRow = ((newRow >= 0) ? newRow : 0) + newNumRows; if (lastRow >= MAX_ELEMENT) { Tcl_SetObjResult(interp, Tcl_NewStringObj("row out of bounds", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_ROW", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_ROW", (char *)NULL); return TCL_ERROR; } @@ -3034,7 +3034,7 @@ ConfigureContent( if (length > 1 && i == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument \"%s\": must be name of window", string)); - Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", (char *)NULL); return TCL_ERROR; } if (length > 1 && firstChar == '-') { @@ -3044,7 +3044,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unexpected parameter \"%s\" in configure list:" " should be window name or option", string)); - Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", (char *)NULL); return TCL_ERROR; } @@ -3052,7 +3052,7 @@ ConfigureContent( (prevChar == REL_SKIP) || (prevChar == REL_VERT))) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "must specify window before shortcut '-'", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", (char *)NULL); return TCL_ERROR; } @@ -3064,7 +3064,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid window shortcut, \"%s\" should be '-', 'x', or '^'", string)); - Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", (char *)NULL); return TCL_ERROR; } numWindows = i; @@ -3072,7 +3072,7 @@ ConfigureContent( if ((objc - numWindows) & 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra option or option with no value", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", (char *)NULL); return TCL_ERROR; } @@ -3101,7 +3101,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad row value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "POSITIVE_INT", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "POSITIVE_INT", (char *)NULL); return TCL_ERROR; } defaultRow = tmp; @@ -3167,7 +3167,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't manage \"%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 = GetGrid(content); @@ -3197,7 +3197,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad column value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", (char *)NULL); return TCL_ERROR; } if (SetContentColumn(interp, contentPtr, tmp, -1) != TCL_OK) { @@ -3210,7 +3210,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad columnspan value \"%s\": must be a positive integer", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", (char *)NULL); return TCL_ERROR; } if (SetContentColumn(interp, contentPtr, -1, tmp) != TCL_OK) { @@ -3225,7 +3225,7 @@ ConfigureContent( if (other == content) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "window can't be managed in itself", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", (char *)NULL); return TCL_ERROR; } positionGiven = 1; @@ -3240,7 +3240,7 @@ ConfigureContent( "bad stickyness value \"%s\": must be" " a string containing n, e, s, and/or w", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", (char *)NULL); return TCL_ERROR; } contentPtr->sticky = sticky; @@ -3252,7 +3252,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; @@ -3263,7 +3263,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; @@ -3286,7 +3286,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad row value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", (char *)NULL); return TCL_ERROR; } if (SetContentRow(interp, contentPtr, tmp, -1) != TCL_OK) { @@ -3299,7 +3299,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad rowspan value \"%s\": must be a positive integer", Tcl_GetString(objv[i+1]))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", (char *)NULL); return TCL_ERROR; } if (SetContentRow(interp, contentPtr, -1, tmp) != TCL_OK) { @@ -3370,7 +3370,7 @@ ConfigureContent( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't put \"%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); Unlink(contentPtr); return TCL_ERROR; } @@ -3386,7 +3386,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); Unlink(contentPtr); return TCL_ERROR; } @@ -3470,7 +3470,7 @@ ConfigureContent( if (containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't use '^', can't find container window", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", (char *)NULL); return TCL_ERROR; } @@ -3524,7 +3524,7 @@ ConfigureContent( if (!match) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't find content to extend with \"^\"", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", (char *)NULL); return TCL_ERROR; } } @@ -3532,7 +3532,7 @@ ConfigureContent( if (containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't determine container window", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); + Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", (char *)NULL); return TCL_ERROR; } SetGridSize(containerPtr); diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index c6f10b9..fca3e44 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -240,7 +240,7 @@ ImgBmapConfigureModel( int maskWidth, maskHeight, dummy1, dummy2; if (Tk_ConfigureWidget(modelPtr->interp, Tk_MainWindow(modelPtr->interp), - configSpecs, objc, (const char **) objv, (char *) modelPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + configSpecs, objc, (const char **)objv, (char *)modelPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { return TCL_ERROR; } @@ -269,9 +269,9 @@ ImgBmapConfigureModel( || (modelPtr->maskDataString != NULL)) { if (modelPtr->data == NULL) { Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj( - "cannot have mask without bitmap", TCL_INDEX_NONE)); + "cannot have a mask without a bitmap", TCL_INDEX_NONE)); Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP", - "NO_BITMAP", NULL); + "NO_BITMAP", (char *)NULL); return TCL_ERROR; } modelPtr->maskData = TkGetBitmapData(modelPtr->interp, @@ -287,7 +287,7 @@ ImgBmapConfigureModel( Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj( "bitmap and mask have different sizes", TCL_INDEX_NONE)); Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP", - "MASK_SIZE", NULL); + "MASK_SIZE", (char *)NULL); return TCL_ERROR; } } @@ -488,7 +488,7 @@ TkGetBitmapData( Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get bitmap data from a file in a safe interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", (char *)NULL); return NULL; } expandedFileName = Tcl_TranslateFileName(NULL, fileName, &buffer); @@ -593,7 +593,7 @@ TkGetBitmapData( "format error in bitmap data; looks like it's an" " obsolete X10 bitmap file", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "OBSOLETE", - NULL); + (char *)NULL); } goto errorCleanup; } @@ -637,7 +637,7 @@ TkGetBitmapData( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "format error in bitmap data", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "FORMAT", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "FORMAT", (char *)NULL); } errorCleanup: @@ -1210,7 +1210,7 @@ ImgBmapPostscript( Tcl_SetObjResult(interp, Tcl_NewStringObj( "unable to generate postscript for bitmaps larger than 60000" " pixels", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL); + Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", (char *)NULL); return TCL_ERROR; } diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 6e169fe..a04196d 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -469,7 +469,7 @@ FileReadGIF( "no value given for \"%s\" option", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "OPT_VALUE", - (char *) NULL); + (char *)NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[++i], &index) != TCL_OK) { @@ -485,14 +485,14 @@ FileReadGIF( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read GIF header from file \"%s\"", fileName)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "HEADER", - (char *) NULL); + (char *)NULL); return TCL_ERROR; } if ((fileWidth <= 0) || (fileHeight <= 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "GIF image file \"%s\" has dimension(s) <= 0", fileName)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BOGUS_SIZE", - (char *) NULL); + (char *)NULL); return TCL_ERROR; } @@ -507,7 +507,7 @@ FileReadGIF( Tcl_SetObjResult(interp, Tcl_NewStringObj( "GIF file truncated", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "TRUNCATED", - (char *) NULL); + (char *)NULL); return TCL_ERROR; } bitPixel = 2 << (buf[0] & 0x07); @@ -517,7 +517,7 @@ FileReadGIF( Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading color map", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", - (char *) NULL); + (char *)NULL); return TCL_ERROR; } } @@ -563,7 +563,7 @@ FileReadGIF( Tcl_SetObjResult(interp, Tcl_NewStringObj( "no image data for this index", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "NO_DATA", - (char *) NULL); + (char *)NULL); goto error; case GIF_EXTENSION: @@ -581,7 +581,7 @@ FileReadGIF( Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading extension in GIF image", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT", - (char *) NULL); + (char *)NULL); goto error; } continue; @@ -591,7 +591,7 @@ FileReadGIF( "couldn't read left/top/width/height in GIF image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "DIMENSIONS", - (char *) NULL); + (char *)NULL); goto error; } break; @@ -622,7 +622,7 @@ FileReadGIF( Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading color map", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", - "COLOR_MAP", (char *) NULL); + "COLOR_MAP", (char *)NULL); goto error; } } @@ -685,7 +685,7 @@ FileReadGIF( Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading color map", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", - (char *) NULL); + (char *)NULL); goto error; } } @@ -929,11 +929,11 @@ ReadOneByte( { unsigned char buf[2]; if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) { - /* - * Premature end of image. - */ + /* + * Premature end of image. + */ - Tcl_SetObjResult(interp, Tcl_NewStringObj( + Tcl_SetObjResult(interp, Tcl_NewStringObj( "premature end of image data", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END", NULL); return -1; @@ -1218,7 +1218,7 @@ DoExtension( break; case 0xfe: /* Comment Extension */ strcpy(extensionStreamName,"comment"); - /* copy the extension data below */ + /* copy the extension data below */ break; } /* Add extension to dict */ @@ -1349,7 +1349,7 @@ ReadImage( if (initialCodeSize > MAX_LWZ_BITS) { Tcl_SetObjResult(interp, Tcl_NewStringObj("malformed image", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "MALFORMED", - (char *) NULL); + (char *)NULL); return TCL_ERROR; } @@ -1468,24 +1468,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 @@ -1867,7 +1867,7 @@ Fread( Tcl_Channel chan) { if (hunk < 0 || count < 0) { - return -1; + return -1; } if (gifConfPtr->fromData == INLINE_DATA_BASE64) { @@ -2047,7 +2047,7 @@ CommonWriteGIF( if (state.num >= MAXCOLORMAPSIZE) { Tcl_SetObjResult(interp, Tcl_NewStringObj("too many colors", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLORFUL", - (char *) NULL); + (char *)NULL); return TCL_ERROR; } if (state.num<2) { diff --git a/generic/tkImgListFormat.c b/generic/tkImgListFormat.c index d2a674d..ab2e271 100644 --- a/generic/tkImgListFormat.c +++ b/generic/tkImgListFormat.c @@ -40,7 +40,7 @@ */ #define TK_PHOTO_ALLOC_FAILURE_MESSAGE \ - "not enough free memory for image buffer" + "not enough free memory for image buffer" /* @@ -87,11 +87,11 @@ static const char *const colorFormatNames[] = { struct FormatOptions { int options; /* Individual bits indicate which options were - * specified - see below. */ + * specified - see below. */ Tcl_Obj *formatName; /* Name specified without an option. */ enum ColorFormatType colorFormat; - /* The color format type given with the - * -colorformat option */ + /* The color format type given with the + * -colorformat option */ }; /* @@ -121,34 +121,34 @@ static const char *const formatOptionNames[] = { */ static int ParseFormatOptions(Tcl_Interp *interp, int allowedOptions, - Tcl_Size objc, Tcl_Obj *const objv[], Tcl_Size *indexPtr, - struct FormatOptions *optPtr); + Tcl_Size objc, Tcl_Obj *const objv[], Tcl_Size *indexPtr, + struct FormatOptions *optPtr); static Tcl_Obj *GetBadOptMsg(const char *badValue, int allowedOpts); static int StringMatchDef(Tcl_Obj *data, Tcl_Obj *formatString, - int *widthPtr, int *heightPtr, Tcl_Interp *interp); + int *widthPtr, int *heightPtr, Tcl_Interp *interp); static int StringReadDef(Tcl_Interp *interp, Tcl_Obj *data, - Tcl_Obj *formatString, Tk_PhotoHandle imageHandle, - int destX, int destY, int width, int height, - int srcX, int srcY); + Tcl_Obj *formatString, Tk_PhotoHandle imageHandle, + int destX, int destY, int width, int height, + int srcX, int srcY); static int StringWriteDef(Tcl_Interp *interp, - Tcl_Obj *formatString, - Tk_PhotoImageBlock *blockPtr); + Tcl_Obj *formatString, + Tk_PhotoImageBlock *blockPtr); static int ParseColor(Tcl_Interp *interp, Tcl_Obj *specObj, - Display *display, Colormap colormap, unsigned char *redPtr, - unsigned char *greenPtr, unsigned char *bluePtr, - unsigned char *alphaPtr); + Display *display, Colormap colormap, unsigned char *redPtr, + unsigned char *greenPtr, unsigned char *bluePtr, + unsigned char *alphaPtr); static int ParseColorAsList(const char *colorString, unsigned char *redPtr, - unsigned char *greenPtr, unsigned char *bluePtr, - unsigned char *alphaPtr); + unsigned char *greenPtr, unsigned char *bluePtr, + unsigned char *alphaPtr); static int ParseColorAsHex(Tcl_Interp *interp, const char *colorString, - int colorStrLen, Display *display, Colormap colormap, - unsigned char *redPtr, unsigned char *greenPtr, - unsigned char *bluePtr, unsigned char *alphaPtr); + int colorStrLen, Display *display, Colormap colormap, + unsigned char *redPtr, unsigned char *greenPtr, + unsigned char *bluePtr, unsigned char *alphaPtr); static int ParseColorAsStandard(Tcl_Interp *interp, - const char *colorString, int colorStrLen, - Display *display, Colormap colormap, - unsigned char *redPtr, unsigned char *greenPtr, - unsigned char *bluePtr, unsigned char *alphaPtr); + const char *colorString, int colorStrLen, + Display *display, Colormap colormap, + unsigned char *redPtr, unsigned char *greenPtr, + unsigned char *bluePtr, unsigned char *alphaPtr); /* * The format record for the default image handler @@ -189,14 +189,14 @@ static int ParseFormatOptions( Tcl_Interp *interp, /* For error messages */ int allowedOptions, /* Bitfield specifying which options are - * to be considered allowed */ + * to be considered allowed */ Tcl_Size objc, /* Number of elements in argv[] */ Tcl_Obj *const objv[], /* The arguments to parse */ Tcl_Size *indexPtr, /* Index giving the first element to - * parse. The value is updated to the - * index where parsing ended */ + * parse. The value is updated to the + * index where parsing ended */ struct FormatOptions *optPtr) /* Parsed option values are written to - * this struct */ + * this struct */ { Tcl_Size optIndex, index; @@ -212,76 +212,76 @@ ParseFormatOptions( optPtr->formatName = NULL; optPtr->colorFormat = COLORFORMAT_RGB2; for (index = *indexPtr; index < objc; *indexPtr = ++index) { - int optionExists; - - /* - * The first value can be the format handler's name. It goes to - * optPtr->name. - */ - option = Tcl_GetString(objv[index]); - if (option[0] != '-') { - if (first) { - optPtr->formatName = objv[index]; - first = 0; - continue; - } else { - break; - } - } - first = 0; - - /* - * Check if option is known and allowed - */ - - optionExists = 1; - if (Tcl_GetIndexFromObj(NULL, objv[index], formatOptionNames, - "format option", 0, &optIndex) != TCL_OK) { - optionExists = 0; - } - if (!optionExists || !((1 << optIndex) & allowedOptions)) { - Tcl_SetObjResult(interp, GetBadOptMsg(Tcl_GetString(objv[index]), - allowedOptions)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL); - return TCL_ERROR; - } - - /* - * Option-specific checks - */ - - switch (1 << optIndex) { - case OPT_COLORFORMAT: - *indexPtr = ++index; - if (index >= objc) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("the \"%s\" option " - "requires a value", Tcl_GetString(objv[index - 1]))); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "MISSING_VALUE", NULL); - return TCL_ERROR; - } - if (Tcl_GetIndexFromObj(NULL, objv[index], colorFormatNames, "", - TCL_EXACT, &typeIndex) != TCL_OK - || (typeIndex != COLORFORMAT_LIST - && typeIndex != COLORFORMAT_RGB2 - && typeIndex != COLORFORMAT_RGBA2) ) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad color format " - "\"%s\": must be rgb, rgba, or list", - Tcl_GetString(objv[index]))); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "BAD_COLOR_FORMAT", NULL); - return TCL_ERROR; - } - optPtr->colorFormat = (enum ColorFormatType)typeIndex; - break; - default: - Tcl_Panic("ParseFormatOptions: unexpected switch fallthrough"); - } - - /* - * Add option to bitfield in optPtr - */ - optPtr->options |= (1 << optIndex); + int optionExists; + + /* + * The first value can be the format handler's name. It goes to + * optPtr->name. + */ + option = Tcl_GetString(objv[index]); + if (option[0] != '-') { + if (first) { + optPtr->formatName = objv[index]; + first = 0; + continue; + } else { + break; + } + } + first = 0; + + /* + * Check if option is known and allowed + */ + + optionExists = 1; + if (Tcl_GetIndexFromObj(NULL, objv[index], formatOptionNames, + "format option", 0, &optIndex) != TCL_OK) { + optionExists = 0; + } + if (!optionExists || !((1 << optIndex) & allowedOptions)) { + Tcl_SetObjResult(interp, GetBadOptMsg(Tcl_GetString(objv[index]), + allowedOptions)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", (char *)NULL); + return TCL_ERROR; + } + + /* + * Option-specific checks + */ + + switch (1 << optIndex) { + case OPT_COLORFORMAT: + *indexPtr = ++index; + if (index >= objc) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf("the \"%s\" option " + "requires a value", Tcl_GetString(objv[index - 1]))); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "MISSING_VALUE", (char *)NULL); + return TCL_ERROR; + } + if (Tcl_GetIndexFromObj(NULL, objv[index], colorFormatNames, "", + TCL_EXACT, &typeIndex) != TCL_OK + || (typeIndex != COLORFORMAT_LIST + && typeIndex != COLORFORMAT_RGB2 + && typeIndex != COLORFORMAT_RGBA2) ) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad color format " + "\"%s\": must be rgb, rgba, or list", + Tcl_GetString(objv[index]))); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "BAD_COLOR_FORMAT", (char *)NULL); + return TCL_ERROR; + } + optPtr->colorFormat = (enum ColorFormatType)typeIndex; + break; + default: + Tcl_Panic("ParseFormatOptions: unexpected switch fallthrough"); + } + + /* + * Add option to bitfield in optPtr + */ + optPtr->options |= (1 << optIndex); } return TCL_OK; @@ -311,29 +311,29 @@ GetBadOptMsg( Tcl_Obj *resObj = Tcl_ObjPrintf("bad format option \"%s\": ", badValue); if (allowedOpts == 0) { - Tcl_AppendToObj(resObj, "no options allowed", TCL_INDEX_NONE); + Tcl_AppendToObj(resObj, "no options allowed", TCL_INDEX_NONE); } else { - Tcl_AppendToObj(resObj, "must be ", TCL_INDEX_NONE); - bit = 1; - for (i = 0; formatOptionNames[i] != NULL; i++) { - if (allowedOpts & bit) { - if (allowedOpts & (bit -1)) { - /* - * not the first option - */ - if (allowedOpts & ~((bit << 1) - 1)) { - /* - * not the last option - */ - Tcl_AppendToObj(resObj, ", ", TCL_INDEX_NONE); - } else { - Tcl_AppendToObj(resObj, ", or ", TCL_INDEX_NONE); - } - } - Tcl_AppendToObj(resObj, formatOptionNames[i], TCL_INDEX_NONE); - } - bit <<=1; - } + Tcl_AppendToObj(resObj, "must be ", TCL_INDEX_NONE); + bit = 1; + for (i = 0; formatOptionNames[i] != NULL; i++) { + if (allowedOpts & bit) { + if (allowedOpts & (bit -1)) { + /* + * not the first option + */ + if (allowedOpts & ~((bit << 1) - 1)) { + /* + * not the last option + */ + Tcl_AppendToObj(resObj, ", ", TCL_INDEX_NONE); + } else { + Tcl_AppendToObj(resObj, ", or ", TCL_INDEX_NONE); + } + } + Tcl_AppendToObj(resObj, formatOptionNames[i], TCL_INDEX_NONE); + } + bit <<=1; + } } return resObj; } @@ -377,34 +377,34 @@ StringMatchDef( */ if (Tcl_ListObjGetElements(interp, data, &rowCount, &rowListPtr) - != TCL_OK) { - return 0; + != TCL_OK) { + return 0; } if (rowCount == 0) { - /* - * empty list is valid data - */ + /* + * empty list is valid data + */ - *widthPtr = 0; - *heightPtr = 0; - return 1; + *widthPtr = 0; + *heightPtr = 0; + return 1; } colCount = -1; for (y = 0; y < rowCount; y++) { - if (Tcl_ListObjLength(interp, rowListPtr[y], &curColCount) != TCL_OK) { - return 0; - } - if (colCount < 0) { - colCount = curColCount; - } else if (curColCount != colCount) { - if (interp != NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid row # %" TCL_SIZE_MODIFIER "d: " - "all rows must have the same number of elements", y)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "INVALID_DATA", NULL); - } - return 0; - } + if (Tcl_ListObjLength(interp, rowListPtr[y], &curColCount) != TCL_OK) { + return 0; + } + if (colCount < 0) { + colCount = curColCount; + } else if (curColCount != colCount) { + if (interp != NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid row # %" TCL_SIZE_MODIFIER "d: " + "all rows must have the same number of elements", y)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "INVALID_DATA", (char *)NULL); + } + return 0; + } } /* @@ -413,16 +413,16 @@ StringMatchDef( * pixel for validity. */ if (Tcl_ListObjIndex(interp, rowListPtr[0], 0, &pixelData) != TCL_OK) { - return 0; + return 0; } (void)Tcl_GetString(pixelData); if (pixelData->length > TK_PHOTO_MAX_COLOR_LENGTH) { - return 0; + return 0; } if (ParseColor(interp, pixelData, Tk_Display(Tk_MainWindow(interp)), - Tk_Colormap(Tk_MainWindow(interp)), &dummy, &dummy, &dummy, &dummy) - != TCL_OK) { - return 0; + Tk_Colormap(Tk_MainWindow(interp)), &dummy, &dummy, &dummy, &dummy) + != TCL_OK) { + return 0; } /* @@ -464,10 +464,10 @@ StringReadDef( Tcl_Obj *formatString, /* value of the -format option */ Tk_PhotoHandle imageHandle, /* write data to this image */ int destX, int destY, /* start writing data at this point - * in destination image*/ + * in destination image*/ int width, int height, /* dimensions of area to write to */ int srcX, int srcY) /* start reading source data at these - * coordinates */ + * coordinates */ { Tcl_Obj **rowListPtr, **colListPtr; Tcl_Obj **objv; @@ -488,21 +488,21 @@ StringReadDef( memset(&opts, 0, sizeof(opts)); if (formatString != NULL) { - if (Tcl_ListObjGetElements(interp, formatString, &objc, &objv) - != TCL_OK) { - return TCL_ERROR; - } - optIndex = 0; - if (ParseFormatOptions(interp, 0, objc, objv, &optIndex, &opts) - != TCL_OK) { - return TCL_ERROR; - } - if (optIndex < objc) { - Tcl_SetObjResult(interp, - GetBadOptMsg(Tcl_GetString(objv[optIndex]), 0)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL); - return TCL_ERROR; - } + if (Tcl_ListObjGetElements(interp, formatString, &objc, &objv) + != TCL_OK) { + return TCL_ERROR; + } + optIndex = 0; + if (ParseFormatOptions(interp, 0, objc, objv, &optIndex, &opts) + != TCL_OK) { + return TCL_ERROR; + } + if (optIndex < objc) { + Tcl_SetObjResult(interp, + GetBadOptMsg(Tcl_GetString(objv[optIndex]), 0)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", (char *)NULL); + return TCL_ERROR; + } } /* @@ -510,24 +510,24 @@ StringReadDef( */ if (Tcl_ListObjGetElements(interp, data, &rowCount, &rowListPtr) - != TCL_OK ) { - return TCL_ERROR; + != TCL_OK ) { + return TCL_ERROR; } if ( rowCount > 0 && Tcl_ListObjLength(interp, rowListPtr[0], &colCount) - != TCL_OK) { - return TCL_ERROR; + != TCL_OK) { + return TCL_ERROR; } if (width <= 0 || height <= 0 || rowCount == 0 || colCount == 0) { - /* - * No changes with zero sized input or zero sized output region - */ + /* + * No changes with zero sized input or zero sized output region + */ - return TCL_OK; + return TCL_OK; } if (srcX < 0 || srcY < 0 || srcX >= rowCount || srcY >= colCount) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("source coordinates out of range")); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_ObjPrintf("source coordinates out of range")); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", (char *)NULL); + return TCL_ERROR; } /* @@ -536,11 +536,11 @@ StringReadDef( */ if (colCount > (int)(UINT_MAX / 4 / rowCount)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "photo image dimensions exceed Tcl memory limits")); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "OVERFLOW", NULL); - return TCL_OK; + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "photo image dimensions exceed Tcl memory limits")); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "OVERFLOW", (char *)NULL); + return TCL_OK; } /* @@ -557,39 +557,39 @@ StringReadDef( srcBlock.offset[3] = 3; srcBlock.pixelPtr = (unsigned char *)attemptckalloc(srcBlock.pitch * srcBlock.height); if (srcBlock.pixelPtr == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf(TK_PHOTO_ALLOC_FAILURE_MESSAGE)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_ObjPrintf(TK_PHOTO_ALLOC_FAILURE_MESSAGE)); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); + return TCL_ERROR; } curPixelPtr = srcBlock.pixelPtr; display = Tk_Display(Tk_MainWindow(interp)); colormap = Tk_Colormap(Tk_MainWindow(interp)); for (y = srcY; y < rowCount; y++) { - /* - * We don't test the length of row, as that's been done in - * ImgStringMatch() - */ - - if (Tcl_ListObjGetElements(interp, rowListPtr[y], &curColCount, - &colListPtr) != TCL_OK) { - goto errorExit; - } - for (x = srcX; x < colCount; x++) { - if (ParseColor(interp, colListPtr[x], display, colormap, - curPixelPtr, curPixelPtr + 1, curPixelPtr + 2, - curPixelPtr + 3) != TCL_OK) { - goto errorExit; - } - curPixelPtr += 4; - } + /* + * We don't test the length of row, as that's been done in + * ImgStringMatch() + */ + + if (Tcl_ListObjGetElements(interp, rowListPtr[y], &curColCount, + &colListPtr) != TCL_OK) { + goto errorExit; + } + for (x = srcX; x < colCount; x++) { + if (ParseColor(interp, colListPtr[x], display, colormap, + curPixelPtr, curPixelPtr + 1, curPixelPtr + 2, + curPixelPtr + 3) != TCL_OK) { + goto errorExit; + } + curPixelPtr += 4; + } } /* * Write image data to destHandle */ if (Tk_PhotoPutBlock(interp, imageHandle, &srcBlock, destX, destY, - width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) { - goto errorExit; + width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) { + goto errorExit; } ckfree(srcBlock.pixelPtr); @@ -635,20 +635,20 @@ StringWriteDef( * Parse format suboptions */ if (Tcl_ListObjGetElements(interp, formatString, &objc, &objv) - != TCL_OK) { - return TCL_ERROR; + != TCL_OK) { + return TCL_ERROR; } allowedOpts = OPT_COLORFORMAT; optIndex = 0; if (ParseFormatOptions(interp, allowedOpts, objc, objv, &optIndex, &opts) - != TCL_OK) { - return TCL_ERROR; + != TCL_OK) { + return TCL_ERROR; } if (optIndex < objc) { - Tcl_SetObjResult(interp, - GetBadOptMsg(Tcl_GetString(objv[optIndex]), allowedOpts)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL); - return TCL_ERROR; + Tcl_SetObjResult(interp, + GetBadOptMsg(Tcl_GetString(objv[optIndex]), allowedOpts)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", (char *)NULL); + return TCL_ERROR; } greenOffset = blockPtr->offset[1] - blockPtr->offset[0]; @@ -660,84 +660,84 @@ StringWriteDef( */ if (blockPtr->offset[3] < 0) { - hasAlpha = 0; - alphaOffset = 0; + hasAlpha = 0; + alphaOffset = 0; } else { - hasAlpha = 1; - alphaOffset = blockPtr->offset[3] - blockPtr->offset[0]; + hasAlpha = 1; + alphaOffset = blockPtr->offset[3] - blockPtr->offset[0]; } if ((blockPtr->width > 0) && (blockPtr->height > 0)) { - int row, col; - Tcl_DString data, line; - char colorBuf[11]; - unsigned char *pixelPtr; - unsigned char alphaVal = 255; - - Tcl_DStringInit(&data); - for (row=0; rowheight; row++) { - pixelPtr = blockPtr->pixelPtr + blockPtr->offset[0] - + row * blockPtr->pitch; - Tcl_DStringInit(&line); - for (col=0; colwidth; col++) { - if (hasAlpha) { - alphaVal = pixelPtr[alphaOffset]; - } - - /* - * We don't build lines as a list for #RGBA and #RGB. Since - * these color formats look like comments, the first element - * of the list would get quoted with an additional {} . - * While this is not a problem if the data is used as - * a list, it would cause problems if someone decides to parse - * it as a string (and it looks kinda strange) - */ - - switch (opts.colorFormat) { - case COLORFORMAT_RGB2: - snprintf(colorBuf, sizeof(colorBuf), "#%02x%02x%02x ", pixelPtr[0], - pixelPtr[greenOffset], pixelPtr[blueOffset]); - Tcl_DStringAppend(&line, colorBuf, TCL_INDEX_NONE); - break; - case COLORFORMAT_RGBA2: - snprintf(colorBuf, sizeof(colorBuf), "#%02x%02x%02x%02x ", - pixelPtr[0], pixelPtr[greenOffset], - pixelPtr[blueOffset], alphaVal); - Tcl_DStringAppend(&line, colorBuf, TCL_INDEX_NONE); - break; - case COLORFORMAT_LIST: - Tcl_DStringStartSublist(&line); - snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[0]); - Tcl_DStringAppendElement(&line, colorBuf); - snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[greenOffset]); - Tcl_DStringAppendElement(&line, colorBuf); - snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[blueOffset]); - Tcl_DStringAppendElement(&line, colorBuf); - snprintf(colorBuf, sizeof(colorBuf), "%d", alphaVal); - Tcl_DStringAppendElement(&line, colorBuf); - Tcl_DStringEndSublist(&line); - break; - default: - Tcl_Panic("unexpected switch fallthrough"); - } - pixelPtr += blockPtr->pixelSize; - } - if (opts.colorFormat != COLORFORMAT_LIST) { - /* - * For the #XXX formats, we need to remove the last - * whitespace. - */ - - *(Tcl_DStringValue(&line) + Tcl_DStringLength(&line) - 1) - = '\0'; - } - Tcl_DStringAppendElement(&data, Tcl_DStringValue(&line)); - Tcl_DStringFree(&line); - } - result = Tcl_NewStringObj(Tcl_DStringValue(&data), TCL_INDEX_NONE); - Tcl_DStringFree(&data); + int row, col; + Tcl_DString data, line; + char colorBuf[11]; + unsigned char *pixelPtr; + unsigned char alphaVal = 255; + + Tcl_DStringInit(&data); + for (row=0; rowheight; row++) { + pixelPtr = blockPtr->pixelPtr + blockPtr->offset[0] + + row * blockPtr->pitch; + Tcl_DStringInit(&line); + for (col=0; colwidth; col++) { + if (hasAlpha) { + alphaVal = pixelPtr[alphaOffset]; + } + + /* + * We don't build lines as a list for #RGBA and #RGB. Since + * these color formats look like comments, the first element + * of the list would get quoted with an additional {} . + * While this is not a problem if the data is used as + * a list, it would cause problems if someone decides to parse + * it as a string (and it looks kinda strange) + */ + + switch (opts.colorFormat) { + case COLORFORMAT_RGB2: + snprintf(colorBuf, sizeof(colorBuf), "#%02x%02x%02x ", pixelPtr[0], + pixelPtr[greenOffset], pixelPtr[blueOffset]); + Tcl_DStringAppend(&line, colorBuf, TCL_INDEX_NONE); + break; + case COLORFORMAT_RGBA2: + snprintf(colorBuf, sizeof(colorBuf), "#%02x%02x%02x%02x ", + pixelPtr[0], pixelPtr[greenOffset], + pixelPtr[blueOffset], alphaVal); + Tcl_DStringAppend(&line, colorBuf, TCL_INDEX_NONE); + break; + case COLORFORMAT_LIST: + Tcl_DStringStartSublist(&line); + snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[0]); + Tcl_DStringAppendElement(&line, colorBuf); + snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[greenOffset]); + Tcl_DStringAppendElement(&line, colorBuf); + snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[blueOffset]); + Tcl_DStringAppendElement(&line, colorBuf); + snprintf(colorBuf, sizeof(colorBuf), "%d", alphaVal); + Tcl_DStringAppendElement(&line, colorBuf); + Tcl_DStringEndSublist(&line); + break; + default: + Tcl_Panic("unexpected switch fallthrough"); + } + pixelPtr += blockPtr->pixelSize; + } + if (opts.colorFormat != COLORFORMAT_LIST) { + /* + * For the #XXX formats, we need to remove the last + * whitespace. + */ + + *(Tcl_DStringValue(&line) + Tcl_DStringLength(&line) - 1) + = '\0'; + } + Tcl_DStringAppendElement(&data, Tcl_DStringValue(&line)); + Tcl_DStringFree(&line); + } + result = Tcl_NewStringObj(Tcl_DStringValue(&data), TCL_INDEX_NONE); + Tcl_DStringFree(&data); } else { - result = Tcl_NewObj(); + result = Tcl_NewObj(); } Tcl_SetObjResult(interp, result); @@ -770,7 +770,7 @@ ParseColor( Tcl_Interp *interp, /* error messages go there */ Tcl_Obj *specObj, /* the color data to parse */ Display *display, /* display of main window, needed to parse - * standard Tk colors */ + * standard Tk colors */ Colormap colormap, /* colormap of current display */ unsigned char *redPtr, /* the result is written to these pointers */ unsigned char *greenPtr, @@ -787,23 +787,23 @@ ParseColor( specString = Tcl_GetStringFromObj(specObj, &length); if (length == 0) { - /* Empty string */ - *redPtr = *greenPtr = *bluePtr = *alphaPtr = 0; - return TCL_OK; + /* Empty string */ + *redPtr = *greenPtr = *bluePtr = *alphaPtr = 0; + return TCL_OK; } if (length > TK_PHOTO_MAX_COLOR_LENGTH) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid color")); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "INVALID_COLOR", NULL); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid color")); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "INVALID_COLOR", (char *)NULL); + return TCL_ERROR; } if (specString[0] == '#') { - return ParseColorAsHex(interp, specString, length, display, - colormap, redPtr, greenPtr, bluePtr, alphaPtr); + return ParseColorAsHex(interp, specString, length, display, + colormap, redPtr, greenPtr, bluePtr, alphaPtr); } if (ParseColorAsList(specString, - redPtr, greenPtr, bluePtr, alphaPtr) == TCL_OK) { - return TCL_OK; + redPtr, greenPtr, bluePtr, alphaPtr) == TCL_OK) { + return TCL_OK; } /* @@ -813,7 +813,7 @@ ParseColor( Tcl_ResetResult(interp); return ParseColorAsStandard(interp, specString, length, display, - colormap, redPtr, greenPtr, bluePtr, alphaPtr); + colormap, redPtr, greenPtr, bluePtr, alphaPtr); } @@ -863,24 +863,24 @@ ParseColorAsList( */ while(isspace(UCHAR(*curPos))) { - ++curPos; + ++curPos; } while (i < 4 && *curPos != '\0') { - values[i] = strtol(curPos, (char **)&curPos, 0); - if (values[i] < 0 || values[i] > 255) { - return TCL_ERROR; - } - while(isspace(UCHAR(*curPos))) { - ++curPos; - } - ++i; + values[i] = strtol(curPos, (char **)&curPos, 0); + if (values[i] < 0 || values[i] > 255) { + return TCL_ERROR; + } + while(isspace(UCHAR(*curPos))) { + ++curPos; + } + ++i; } if (i < 3 || *curPos != '\0') { - return TCL_ERROR; + return TCL_ERROR; } if (i < 4) { - values[3] = 255; + values[3] = 255; } *redPtr = (unsigned char) values[0]; @@ -897,7 +897,7 @@ ParseColorAsList( * ParseColorAsHex -- * * This function extracts color and alpha values from a string - * starting with '#', followed by hex digits. It undestands both + * starting with '#', followed by hex digits. It understands both * the #RGBA form and the #RBG (with optional suffix) * * Results: @@ -927,39 +927,39 @@ ParseColorAsHex( unsigned long int colorValue = 0; if (colorStrLen - 1 != 4 && colorStrLen - 1 != 8) { - return ParseColorAsStandard(interp, colorString, colorStrLen, - display, colormap, redPtr, greenPtr, bluePtr, alphaPtr); + return ParseColorAsStandard(interp, colorString, colorStrLen, + display, colormap, redPtr, greenPtr, bluePtr, alphaPtr); } for (i = 1; i < colorStrLen; i++) { - if (!isxdigit(UCHAR(colorString[i]))) { - /* - * There still is a chance that this is a Tk color with - * an alpha suffix - */ - - return ParseColorAsStandard(interp, colorString, colorStrLen, - display, colormap, redPtr, greenPtr, bluePtr, alphaPtr); - } + if (!isxdigit(UCHAR(colorString[i]))) { + /* + * There still is a chance that this is a Tk color with + * an alpha suffix + */ + + return ParseColorAsStandard(interp, colorString, colorStrLen, + display, colormap, redPtr, greenPtr, bluePtr, alphaPtr); + } } colorValue = strtoul(colorString + 1, NULL, 16); switch (colorStrLen - 1) { case 4: - /* #RGBA format */ - *redPtr = (unsigned char) ((colorValue >> 12) * 0x11); - *greenPtr = (unsigned char) (((colorValue >> 8) & 0xf) * 0x11); - *bluePtr = (unsigned char) (((colorValue >> 4) & 0xf) * 0x11); - *alphaPtr = (unsigned char) ((colorValue & 0xf) * 0x11); - return TCL_OK; + /* #RGBA format */ + *redPtr = (unsigned char) ((colorValue >> 12) * 0x11); + *greenPtr = (unsigned char) (((colorValue >> 8) & 0xf) * 0x11); + *bluePtr = (unsigned char) (((colorValue >> 4) & 0xf) * 0x11); + *alphaPtr = (unsigned char) ((colorValue & 0xf) * 0x11); + return TCL_OK; case 8: - /* #RRGGBBAA format */ - *redPtr = (unsigned char) (colorValue >> 24); - *greenPtr = (unsigned char) ((colorValue >> 16) & 0xff); - *bluePtr = (unsigned char) ((colorValue >> 8) & 0xff); - *alphaPtr = (unsigned char) (colorValue & 0xff); - return TCL_OK; + /* #RRGGBBAA format */ + *redPtr = (unsigned char) (colorValue >> 24); + *greenPtr = (unsigned char) ((colorValue >> 16) & 0xff); + *bluePtr = (unsigned char) ((colorValue >> 8) & 0xff); + *alphaPtr = (unsigned char) (colorValue & 0xff); + return TCL_OK; default: - Tcl_Panic("unexpected switch fallthrough"); + Tcl_Panic("unexpected switch fallthrough"); } /* Shouldn't get here */ @@ -971,7 +971,7 @@ ParseColorAsHex( * * ParseColorAsStandard -- * - * This function tries to split a color stirng in a color and a + * This function tries to split a color string in a color and a * suffix part and to extract color and alpha values from them. The * color part is treated as regular Tk color. * @@ -1010,31 +1010,31 @@ ParseColorAsStandard( */ if ((suffixString = strrchr(specString, '@')) == NULL - && ((suffixString = strrchr(specString, '#')) == NULL - || suffixString == specString)) { - suffixString = specString + specStrLen; - colorString = specString; + && ((suffixString = strrchr(specString, '#')) == NULL + || suffixString == specString)) { + suffixString = specString + specStrLen; + colorString = specString; } else { - strncpy(colorBuffer, specString, suffixString - specString); - colorBuffer[suffixString - specString] = '\0'; - colorString = (const char*)colorBuffer; + strncpy(colorBuffer, specString, suffixString - specString); + colorBuffer[suffixString - specString] = '\0'; + colorString = (const char*)colorBuffer; } /* * Try to parse as standard Tk color. * * We don't use Tk_GetColor() et al. here, as those functions - * migth return a color that does not exaxtly match the given name + * might return a color that does not exactly match the given name * if the colormap is full. Also, we don't really want the color to be * added to the colormap. */ if ( ! TkParseColor(display, colormap, colorString, &parsedColor)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "invalid color name \"%s\"", specString)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "INVALID_COLOR", NULL); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid color name \"%s\"", specString)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "INVALID_COLOR", (char *)NULL); + return TCL_ERROR; } /* @@ -1043,54 +1043,54 @@ ParseColorAsStandard( switch (suffixString[0]) { case '\0': - suffixAlpha = 255; - break; + suffixAlpha = 255; + break; case '@': - if (Tcl_GetDouble(NULL, suffixString + 1, &fracAlpha) != TCL_OK) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid alpha " - "suffix \"%s\": expected floating-point value", - suffixString)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "INVALID COLOR", NULL); - return TCL_ERROR; - } - if (fracAlpha < 0 || fracAlpha > 1) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid alpha suffix" - " \"%s\": value must be in the range from 0 to 1", - suffixString)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "INVALID_COLOR", NULL); - return TCL_ERROR; - } - suffixAlpha = (unsigned int) floor(fracAlpha * 255 + 0.5); - break; + if (Tcl_GetDouble(NULL, suffixString + 1, &fracAlpha) != TCL_OK) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid alpha " + "suffix \"%s\": expected floating-point value", + suffixString)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "INVALID COLOR", (char *)NULL); + return TCL_ERROR; + } + if (fracAlpha < 0 || fracAlpha > 1) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid alpha suffix" + " \"%s\": value must be in the range from 0 to 1", + suffixString)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "INVALID_COLOR", (char *)NULL); + return TCL_ERROR; + } + suffixAlpha = (unsigned int) floor(fracAlpha * 255 + 0.5); + break; case '#': - if (strlen(suffixString + 1) < 1 || strlen(suffixString + 1)> 2) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "invalid alpha suffix \"%s\"", suffixString)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "INVALID_COLOR", NULL); - return TCL_ERROR; - } - for (i = 1; i <= (int)strlen(suffixString + 1); i++) { - if ( ! isxdigit(UCHAR(suffixString[i]))) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "invalid alpha suffix \"%s\": expected hex digit", - suffixString)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "INVALID_COLOR", NULL); - return TCL_ERROR; - } - } - if (strlen(suffixString + 1) == 1) { - sscanf(suffixString, "#%1x", &suffixAlpha); - suffixAlpha *= 0x11; - } else { - sscanf(suffixString, "#%2x", &suffixAlpha); - } - break; + if (strlen(suffixString + 1) < 1 || strlen(suffixString + 1)> 2) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid alpha suffix \"%s\"", suffixString)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "INVALID_COLOR", (char *)NULL); + return TCL_ERROR; + } + for (i = 1; i <= (int)strlen(suffixString + 1); i++) { + if ( ! isxdigit(UCHAR(suffixString[i]))) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid alpha suffix \"%s\": expected hex digit", + suffixString)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", + "INVALID_COLOR", (char *)NULL); + return TCL_ERROR; + } + } + if (strlen(suffixString + 1) == 1) { + sscanf(suffixString, "#%1x", &suffixAlpha); + suffixAlpha *= 0x11; + } else { + sscanf(suffixString, "#%2x", &suffixAlpha); + } + break; default: - Tcl_Panic("unexpected switch fallthrough"); + Tcl_Panic("unexpected switch fallthrough"); } *redPtr = (unsigned char) (parsedColor.red >> 8); diff --git a/generic/tkPointer.c b/generic/tkPointer.c index 2fbdedf..1bc8411 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -512,14 +512,14 @@ TkPointerDeadWindow( } if (!(tsdPtr->restrictWinPtr || tsdPtr->grabWinPtr)) { - /* - * Release mouse capture only if the dead window is the capturing - * window. - */ + /* + * Release mouse capture only if the dead window is the capturing + * window. + */ - if (winPtr == (TkWindow *)TkpGetCapture()) { + if (winPtr == (TkWindow *)TkpGetCapture()) { TkpSetCapture(NULL); - } + } } } diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index ec94418..01d8c77 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -228,12 +228,12 @@ ScrollbarWidgetObjCmd( int result = TCL_OK, cmdIndex, length; Tcl_Size len; static const char *const commandNames[] = { - "activate", "cget", "configure", "delta", "fraction", - "get", "identify", "set", NULL + "activate", "cget", "configure", "delta", "fraction", + "get", "identify", "set", NULL }; enum command { - COMMAND_ACTIVATE, COMMAND_CGET, COMMAND_CONFIGURE, COMMAND_DELTA, - COMMAND_FRACTION, COMMAND_GET, COMMAND_IDENTIFY, COMMAND_SET + COMMAND_ACTIVATE, COMMAND_CGET, COMMAND_CONFIGURE, COMMAND_DELTA, + COMMAND_FRACTION, COMMAND_GET, COMMAND_IDENTIFY, COMMAND_SET }; if (objc < 2) { @@ -531,7 +531,7 @@ ConfigureScrollbar( int flags) /* Flags to pass to Tk_ConfigureWidget. */ { if (Tk_ConfigureWidget(interp, scrollPtr->tkwin, configSpecs, objc, - (const char **)objv, (char *) scrollPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + (const char **)objv, (char *)scrollPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { return TCL_ERROR; } @@ -541,17 +541,19 @@ ConfigureScrollbar( */ if (scrollPtr->command != NULL) { - scrollPtr->commandSize = (int) strlen(scrollPtr->command); + scrollPtr->commandSize = (int) strlen(scrollPtr->command); } else { scrollPtr->commandSize = 0; } if (scrollPtr->highlightWidth < 0) { scrollPtr->highlightWidth = 0; } + if (scrollPtr->borderWidth < 0) { + scrollPtr->borderWidth = 0; + } if (scrollPtr->elementBorderWidth < 0) { scrollPtr->elementBorderWidth = -1; } - /* * Configure platform specific options. */ diff --git a/tests/button.test b/tests/button.test index 323e2de..a51b997 100644 --- a/tests/button.test +++ b/tests/button.test @@ -1020,7 +1020,7 @@ test button-1.104 {configuration option: "activebackground" for label} -setup { .l configure -font {} } -cleanup { destroy .l -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test button-1.105 {configuration option: "font" for button} -setup { button .b -borderwidth 2 -highlightthickness 2 pack .b @@ -1039,7 +1039,7 @@ test button-1.106 {configuration option: "activebackground" for button} -setup { .b configure -font {} } -cleanup { destroy .b -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test button-1.107 {configuration option: "font" for checkbutton} -setup { checkbutton .c -borderwidth 2 -highlightthickness 2 pack .c @@ -1058,7 +1058,7 @@ test button-1.108 {configuration option: "activebackground" for checkbutton} -se .c configure -font {} } -cleanup { destroy .c -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test button-1.109 {configuration option: "font" for radiobutton} -setup { radiobutton .r -borderwidth 2 -highlightthickness 2 pack .r @@ -1077,7 +1077,7 @@ test button-1.110 {configuration option: "activebackground" for radiobutton} -se .r configure -font {} } -cleanup { destroy .r -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test button-1.111 {configuration option: "foreground" for label} -setup { label .l -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} diff --git a/tests/canvText.test b/tests/canvText.test index da41395..1263ad4 100644 --- a/tests/canvText.test +++ b/tests/canvText.test @@ -44,7 +44,7 @@ test canvText-1.6 {configuration options: good value for "font"} -body { } -result {{Times 40} {Times 40}} test canvasText-1.7 {configuration options: bad value for "font"} -body { .c itemconfigure test -font {} -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test canvText-1.8 {configuration options: good value for "justify"} -body { .c itemconfigure test -justify left list [lindex [.c itemconfigure test -justify] 4] [.c itemcget test -justify] diff --git a/tests/entry.test b/tests/entry.test index f1803c9..b413291 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -241,7 +241,7 @@ test entry-1.20 {configuration option: "font" for entry} -setup { .e configure -font {} } -cleanup { destroy .e -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test entry-1.21 {configuration option: "foreground" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} diff --git a/tests/font.test b/tests/font.test index eadb794..922f8fb 100644 --- a/tests/font.test +++ b/tests/font.test @@ -97,7 +97,7 @@ test font-2.1 {TkFontPkgFree} -setup { lappend x [foo eval {catch {font families} msg; set msg}] } -cleanup { interp delete foo -} -result {{named font "wiggles" doesn't exist} {cannot invoke "font" command: application has been destroyed}} +} -result {{named font "wiggles" does not exist} {cannot invoke "font" command: application has been destroyed}} test font-3.1 {font command: general} -body { @@ -133,7 +133,7 @@ test font-4.6 {font command: actual: arguments} -body { test font-4.7 {font command: actual: arguments} -constraints noExceed -body { # (tkfont == NULL) font actual "\{xyz" -} -returnCodes error -result "font \"{xyz\" doesn't exist" +} -returnCodes error -result "font \"{xyz\" does not exist" test font-4.8 {font command: actual: all attributes} -body { # not (objc > 3) so objPtr = NULL lindex [font actual {-family times}] 0 @@ -173,7 +173,7 @@ test font-5.1 {font command: configure} -body { test font-5.2 {font command: configure: non-existent font} -body { # (namedHashPtr == NULL) font configure xyz -} -returnCodes error -result {named font "xyz" doesn't exist} +} -returnCodes error -result {named font "xyz" does not exist} test font-5.3 {font command: configure: "deleted" font} -setup { destroy .t.f catch {font delete xyz} @@ -187,7 +187,7 @@ test font-5.3 {font command: configure: "deleted" font} -setup { font configure xyz } -cleanup { destroy .t.f -} -returnCodes error -result {named font "xyz" doesn't exist} +} -returnCodes error -result {named font "xyz" does not exist} test font-5.4 {font command: configure: get all options} -setup { catch {font delete xyz} } -body { @@ -330,7 +330,7 @@ test font-7.4 {font command: delete: non-existent} -setup { } -body { # (namedHashPtr == NULL) font delete xyz -} -returnCodes error -result {named font "xyz" doesn't exist} +} -returnCodes error -result {named font "xyz" does not exist} test font-7.5 {font command: delete: mark for later deletion} -setup { destroy .t.f catch {font delete xyz} @@ -345,7 +345,7 @@ test font-7.5 {font command: delete: mark for later deletion} -setup { font configure xyz } -cleanup { destroy .t.f -} -returnCodes error -result {named font "xyz" doesn't exist} +} -returnCodes error -result {named font "xyz" does not exist} test font-7.6 {font command: delete: mark for later deletion} -setup { destroy .t.f catch {font delete xyz} @@ -405,7 +405,7 @@ test font-9.3 {font command: measure: arguments} -body { test font-9.4 {font command: measure: arguments} -constraints noExceed -body { # (tkfont == NULL) font measure "\{xyz" abc -} -returnCodes error -result "font \"{xyz\" doesn't exist" +} -returnCodes error -result "font \"{xyz\" does not exist" test font-9.5 {font command: measure} -body { # Tk_TextWidth() expr {[font measure $fixed "abcdefg"] == [font measure $fixed "a"]*7 } @@ -443,7 +443,7 @@ test font-10.5 {font command: metrics: arguments} -body { test font-10.6 {font command: metrics: bad font} -constraints noExceed -body { # (tkfont == NULL) font metrics "\{xyz" -} -returnCodes error -result "font \"{xyz\" doesn't exist" +} -returnCodes error -result "font \"{xyz\" does not exist" test font-10.7 {font command: metrics: get all metrics} -setup { catch {unset a} } -body { @@ -707,7 +707,7 @@ test font-15.9 {Tk_AllocFontFromObj procedure: get attribute font} -setup { test font-15.10 {Tk_AllocFontFromObj procedure: no match} -constraints noExceed -body { # (ParseFontNameObj() != TCL_OK) font actual "\{xyz" -} -returnCodes error -result "font \"{xyz\" doesn't exist" +} -returnCodes error -result "font \"{xyz\" does not exist" test font-15.11 {Tk_AllocFontFromObj procedure: get attribute font} -body { # not (ParseFontNameObj() != TCL_OK) lindex [font actual {plan 9}] 0 @@ -2254,10 +2254,10 @@ test font-38.6 {ParseFontNameObj procedure: begins with *} -body { } -result [font actual {times 0} -family] test font-38.7 {ParseFontNameObj procedure: arguments} -constraints noExceed -body { font actual "\{xyz" -} -returnCodes error -result "font \"{xyz\" doesn't exist" +} -returnCodes error -result "font \"{xyz\" does not exist" test font-38.8 {ParseFontNameObj procedure: arguments} -constraints noExceed -body { font actual "" -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test font-38.9 {ParseFontNameObj procedure: arguments} -body { font actual {times 20 xyz xyz} } -returnCodes error -result {unknown font style "xyz"} diff --git a/tests/imgBmap.test b/tests/imgBmap.test index 9aaf674..c498c90 100644 --- a/tests/imgBmap.test +++ b/tests/imgBmap.test @@ -157,7 +157,7 @@ test imageBmap-3.3 {ImgBmapConfigureModel procedure, memory de-allocation} -body test imageBmap-3.4 {ImgBmapConfigureModel procedure} -body { image create bitmap i1 i1 configure -maskdata $data2 -} -returnCodes error -result {cannot have mask without bitmap} +} -returnCodes error -result {cannot have a mask without a bitmap} test imageBmap-3.5 {ImgBmapConfigureModel procedure} -body { image create bitmap i1 -data $data1 -maskdata { #define foo_width 8 diff --git a/tests/message.test b/tests/message.test index 0b86177..df89c30 100644 --- a/tests/message.test +++ b/tests/message.test @@ -190,7 +190,7 @@ test message-1.18 {configuration option: "font"} -setup { .m configure -font {} } -cleanup { destroy .m -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test message-1.19 {configuration option: "-foreground"} -setup { message .m -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} diff --git a/tests/spinbox.test b/tests/spinbox.test index 4060c96..e5ba78c 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -338,7 +338,7 @@ test spinbox-1.27 {configuration option: "font" for spinbox} -setup { .e configure -font {} } -cleanup { destroy .e -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test spinbox-1.28 {configuration option: "foreground"} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -- cgit v0.12 From 2fd74cf1288e7c6a8f43e04b9ec6e642a5e9647c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 30 Aug 2024 23:05:14 +0000 Subject: two more --- tests/unixFont.test | 2 +- tests/winFont.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unixFont.test b/tests/unixFont.test index e11b795..08757cd 100644 --- a/tests/unixFont.test +++ b/tests/unixFont.test @@ -71,7 +71,7 @@ proc getsize {} { test unixfont-1.1 {TkpGetNativeFont procedure: not native} {x11 noExceed} { list [catch {font measure {} xyz} msg] $msg -} {1 {font "" doesn't exist}} +} {1 {font "" does not exist}} test unixfont-1.2 {TkpGetNativeFont procedure: native} {x11 failsOnUbuntu} { font measure fixed 0 } 6 diff --git a/tests/winFont.test b/tests/winFont.test index 03096f6..0f80e8c 100644 --- a/tests/winFont.test +++ b/tests/winFont.test @@ -21,7 +21,7 @@ test winfont-1.1 {TkpGetNativeFont procedure: not native} -constraints { } -body { catch {font delete xyz} font measure {} xyz -} -returnCodes error -result {font "" doesn't exist} +} -returnCodes error -result {font "" does not exist} test winfont-1.2 {TkpGetNativeFont procedure: native} -constraints win -body { font measure ansifixed 0 font measure ansi 0 -- cgit v0.12 From 8685a0c21a281fa3d40718cb68d9bcd5363c5c1c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 1 Sep 2024 00:24:31 +0000 Subject: Remove (apparent) unneeded Tk_GetUid() calls --- generic/tkImgPhoto.c | 4 ++-- macosx/tkMacOSXWm.c | 54 ++++++++++++++++++++++++++-------------------------- unix/tkUnix3d.c | 2 +- win/tkWin3d.c | 11 +++++------ win/tkWinWm.c | 2 +- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 8ae2dca..374e259 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -1743,7 +1743,7 @@ ParseSubcommandOptions( } *optIndexPtr = ++index; optPtr->background = Tk_GetColor(interp, Tk_MainWindow(interp), - Tk_GetUid(Tcl_GetString(objv[index]))); + Tcl_GetString(objv[index])); if (!optPtr->background) { return TCL_ERROR; } @@ -2043,7 +2043,7 @@ ImgPhotoConfigureModel( */ if (Tk_ConfigureWidget(interp, Tk_MainWindow(interp), configSpecs, - objc, (const char **)objv, (char *) modelPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + objc, (const char **)objv, (char *)modelPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { goto errorExit; } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 2f134f7..ae7d982 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -112,7 +112,7 @@ static const struct { .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, .flags = WM_TOPMOST, - .styleMask = 0}, + .styleMask = 0}, [kSheetWindowClass] = { .validAttrs = kWindowResizableAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute | @@ -621,7 +621,7 @@ static void placeAsTab(TKWindow *macWindow) { #endif - (NSSize)windowWillResize:(NSWindow *)sender - toSize:(NSSize)frameSize + toSize:(NSSize)frameSize { NSRect currentFrame = [sender frame]; TkWindow *winPtr = TkMacOSXGetTkWindow(sender); @@ -1223,9 +1223,9 @@ TkWmDeadWindow( if (deadNSWindow && !Tk_IsEmbedded(winPtr)) { NSWindow *parent = [deadNSWindow parentWindow]; [deadNSWindow setTkWindow:None]; - if (winPtr->window) { - ((MacDrawable *)winPtr->window)->view = nil; - } + if (winPtr->window) { + ((MacDrawable *)winPtr->window)->view = nil; + } wmPtr->window = NULL; if (parent) { @@ -1749,7 +1749,7 @@ WmSetAttribute( } else if (![macWindow isKindOfClass: [NSPanel class]] && styleMaskBits[index].allowed == NSWindowClass_panel) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "styleMask bit \"%s\" can only be used with an NSPanel", + "styleMask bit \"%s\" can only be used with an NSPanel", styleMaskBits[index].bitname)); Tcl_SetErrorCode(interp, "TK", "INVALID_STYLEMASK_BIT", NULL); return TCL_ERROR; @@ -1794,15 +1794,15 @@ WmSetAttribute( fprintf(stderr, "Current styleMask: %lx\n", [macWindow styleMask]); fprintf(stderr, "Setting styleMask to %lx\n", styleMaskValue); #endif - macWindow.styleMask = (unsigned long) styleMaskValue; + macWindow.styleMask = (unsigned long) styleMaskValue; NSRect newFrame = [macWindow frame]; int heightDiff = newFrame.size.height - oldFrame.size.height; int newHeight = heightDiff < 0 ? newFrame.size.height : newFrame.size.height - heightDiff; [(TKWindow *)macWindow tkLayoutChanged]; if (heightDiff) { - //Calling XMoveResizeWindow twice is a hack to force a relayout - //of the window. + // Calling XMoveResizeWindow twice is a hack to force a relayout + // of the window. XMoveResizeWindow(winPtr->display, winPtr->window, winPtr->changes.x, winPtr->changes.y, newFrame.size.width, newHeight - 1); @@ -2544,16 +2544,16 @@ WmForgetCmd( TkWmDeadWindow(winPtr); RemapWindows(winPtr, (MacDrawable *)winPtr->parentPtr->window); - /* - * Make sure wm no longer manages this window - */ - Tk_ManageGeometry(frameWin, NULL, NULL); + /* + * Make sure wm no longer manages this window + */ + Tk_ManageGeometry(frameWin, NULL, NULL); winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); /* - * Flags (above) must be cleared before calling TkMapTopFrame (below). - */ + * Flags (above) must be cleared before calling TkMapTopFrame (below). + */ TkMapTopFrame(frameWin); } else { @@ -2962,7 +2962,7 @@ WmIconbitmapCmd( wmPtr->hints.flags &= ~IconPixmapHint; } } else { - pixmap = Tk_GetBitmap(interp, (Tk_Window)winPtr, Tk_GetUid(str)); + pixmap = Tk_GetBitmap(interp, (Tk_Window)winPtr, str); if (pixmap == None) { return TCL_ERROR; } @@ -4311,12 +4311,12 @@ WmTransientCmd( RemoveTransient(winPtr); containerPtr = (TkWindow*) container; while (!Tk_TopWinHierarchy(containerPtr)) { - /* - * Ensure that the container window is actually a Tk toplevel. - */ + /* + * Ensure that the container window is actually a Tk toplevel. + */ - containerPtr = containerPtr->parentPtr; - } + containerPtr = containerPtr->parentPtr; + } Tk_MakeWindowExist((Tk_Window)containerPtr); if (wmPtr->iconFor != NULL) { @@ -5216,7 +5216,7 @@ Tk_GetRootCoords( */ winPtr = otherPtr; - continue; + continue; } winPtr = winPtr->parentPtr; } @@ -6240,7 +6240,7 @@ TkUnsupported1ObjCmd( case TKMWS_APPEARANCE: if ([NSApp macOSVersion] < 100900) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "Window appearances did not exist until OSX 10.9.", TCL_INDEX_NONE)); + "Window appearances did not exist until OSX 10.9.", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "APPEARANCE", NULL); return TCL_ERROR; } @@ -6794,7 +6794,7 @@ TkMacOSXMakeRealWindowExist( } if ((styleMask & (NSTexturedBackgroundWindowMask|NSHUDWindowMask)) && !(styleMask & NSDocModalWindowMask)) { - /* + /* * Workaround for [Bug 2824538]: Textured windows are draggable from * opaque content. */ @@ -7568,9 +7568,9 @@ ApplyContainerOverrideChanges( wmPtr->attributes &= ~kWindowNoActivatesAttribute; if ([NSApp macOSVersion] == 100600) { styleMask = NSTitledWindowMask | - NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSResizableWindowMask; + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask; } else { styleMask |= NSTitledWindowMask; } diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index f977624..55e58c3 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -446,7 +446,7 @@ TkpGetShadows( if (borderPtr->shadow == None) { borderPtr->shadow = Tk_GetBitmap(NULL, tkwin, - Tk_GetUid("gray50")); + "gray50"); if (borderPtr->shadow == None) { Tcl_Panic("TkpGetShadows couldn't allocate bitmap for border"); } diff --git a/win/tkWin3d.c b/win/tkWin3d.c index 2c2181b..c5dfeb4 100644 --- a/win/tkWin3d.c +++ b/win/tkWin3d.c @@ -350,17 +350,17 @@ TkpGetShadows( if ((TkWinIndexOfColor(borderPtr->bgColorPtr) == COLOR_3DFACE) || (TkWinIndexOfColor(borderPtr->bgColorPtr) == COLOR_WINDOW)) { borderPtr->darkColorPtr = Tk_GetColor(NULL, tkwin, - Tk_GetUid("SystemButtonShadow")); + "SystemButtonShadow"); gcValues.foreground = borderPtr->darkColorPtr->pixel; borderPtr->darkGC = Tk_GetGC(tkwin, GCForeground, &gcValues); borderPtr->lightColorPtr = Tk_GetColor(NULL, tkwin, - Tk_GetUid("SystemButtonHighlight")); + "SystemButtonHighlight"); gcValues.foreground = borderPtr->lightColorPtr->pixel; borderPtr->lightGC = Tk_GetGC(tkwin, GCForeground, &gcValues); ((WinBorder*)borderPtr)->dark2ColorPtr = Tk_GetColor(NULL, tkwin, - Tk_GetUid("System3dDarkShadow")); + "System3dDarkShadow"); ((WinBorder*)borderPtr)->light2ColorPtr = Tk_GetColor(NULL, tkwin, - Tk_GetUid("System3dLight")); + "System3dLight"); return; } darkColor.red = 0; @@ -466,8 +466,7 @@ TkpGetShadows( } if (borderPtr->shadow == None) { - borderPtr->shadow = Tk_GetBitmap((Tcl_Interp *) NULL, tkwin, - Tk_GetUid("gray50")); + borderPtr->shadow = Tk_GetBitmap(NULL, tkwin, "gray50"); if (borderPtr->shadow == None) { Tcl_Panic("TkpGetShadows couldn't allocate bitmap for border"); } diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 5a26143..8aef4fa 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -3080,7 +3080,7 @@ WmAttributesCmd( } } else { XColor *cPtr = - Tk_GetColor(interp, tkwin, Tk_GetUid(crefstr)); + Tk_GetColor(interp, tkwin, crefstr); if (cPtr == NULL) { return TCL_ERROR; } -- cgit v0.12 From 2f747aeed4a544be0d517f7e7ac3e9cf15570c2d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 1 Sep 2024 18:51:34 +0000 Subject: Rename DEF_TEXT_INACTIVE_SELECT_COLOR to DEF_TEXT_INACTIVE_SELECT_BG_COLOR in the text widget code. --- generic/tkText.c | 2 +- macosx/tkMacOSXDefault.h | 2 +- unix/tkUnixDefault.h | 2 +- win/tkWinDefault.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 013874b..0b643dd 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -159,7 +159,7 @@ static const Tk_OptionSpec optionSpecs[] = { Tk_Offset(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_BORDER, "-inactiveselectbackground","inactiveSelectBackground", "Foreground", - DEF_TEXT_INACTIVE_SELECT_COLOR, + DEF_TEXT_INACTIVE_SELECT_BG_COLOR, -1, Tk_Offset(TkText, inactiveSelBorder), TK_OPTION_NULL_OK, DEF_TEXT_SELECT_MONO, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index e126742..0fa94ec 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -515,7 +515,7 @@ #define DEF_TEXT_PADX "1" #define DEF_TEXT_PADY "1" #define DEF_TEXT_RELIEF "flat" -#define DEF_TEXT_INACTIVE_SELECT_COLOR INACTIVE_SELECT_BG +#define DEF_TEXT_INACTIVE_SELECT_BG_COLOR INACTIVE_SELECT_BG #define DEF_TEXT_SELECT_COLOR SELECT_BG #define DEF_TEXT_SELECT_MONO BLACK #define DEF_TEXT_SELECT_BD_COLOR "1" diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index a3d50b6..89fed8b 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -486,7 +486,7 @@ #define DEF_TEXT_PADX "1" #define DEF_TEXT_PADY "1" #define DEF_TEXT_RELIEF "sunken" -#define DEF_TEXT_INACTIVE_SELECT_COLOR SELECT_BG +#define DEF_TEXT_INACTIVE_SELECT_BG_COLOR SELECT_BG #define DEF_TEXT_SELECT_COLOR SELECT_BG #define DEF_TEXT_SELECT_MONO BLACK #define DEF_TEXT_SELECT_BD_COLOR "0" diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index b03cbd7..f8a8fec 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -490,7 +490,7 @@ #define DEF_TEXT_PADX "1" #define DEF_TEXT_PADY "1" #define DEF_TEXT_RELIEF "sunken" -#define DEF_TEXT_INACTIVE_SELECT_COLOR NULL +#define DEF_TEXT_INACTIVE_SELECT_BG_COLOR NULL #define DEF_TEXT_SELECT_COLOR SELECT_BG #define DEF_TEXT_SELECT_MONO BLACK #define DEF_TEXT_SELECT_BD_COLOR "0" -- cgit v0.12 From 3fec8cb9880cf52be2f6434f4f18bb91bfd63609 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 1 Sep 2024 19:29:07 +0000 Subject: Missing "const" in documentation for Tk_Get3DBorder/Tk_GetColor/Tk_GetCursor --- doc/3DBorder.3 | 2 +- doc/GetColor.3 | 2 +- doc/GetCursor.3 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/3DBorder.3 b/doc/3DBorder.3 index f589e66..de03645 100644 --- a/doc/3DBorder.3 +++ b/doc/3DBorder.3 @@ -67,7 +67,7 @@ must be the window for which the border was allocated). Pointer to value whose value describes color corresponding to background (flat areas). Illuminated edges will be brighter than this and shadowed edges will be darker than this. -.AP char *colorName in +.AP const char *colorName in Same as \fIobjPtr\fR except value is supplied as a string rather than a value. .AP Drawable drawable in diff --git a/doc/GetColor.3 b/doc/GetColor.3 index 15254aa..0905d4e 100644 --- a/doc/GetColor.3 +++ b/doc/GetColor.3 @@ -44,7 +44,7 @@ Token for window in which color will be used. .AP Tcl_Obj *objPtr in/out String value describes desired color; internal rep will be modified to cache pointer to corresponding (XColor *). -.AP char *name in +.AP const char *name in Same as \fIobjPtr\fR except description of color is passed as a string and resulting (XColor *) is not cached. .AP XColor *prefPtr in diff --git a/doc/GetCursor.3 b/doc/GetCursor.3 index 403c05e..fdf773b 100644 --- a/doc/GetCursor.3 +++ b/doc/GetCursor.3 @@ -41,7 +41,7 @@ Token for window in which the cursor will be used. .AP Tcl_Obj *objPtr in/out Description of cursor; see below for possible values. Internal rep will be modified to cache pointer to corresponding Tk_Cursor. -.AP char *name in +.AP const char *name in Same as \fIobjPtr\fR except description of cursor is passed as a string and resulting Tk_Cursor is not cached. .AP "const char" *source in -- cgit v0.12 From 462bdd414eaf42d777fc25c16423c42ebfb7ff97 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 1 Sep 2024 20:35:00 +0000 Subject: Backport documentation improvements from 8.7/9.0 --- doc/3DBorder.3 | 49 ++++++++++++++++++++++--------------------------- doc/GetColor.3 | 21 ++++++++++++--------- doc/GetCursor.3 | 23 ++++++++++++++--------- doc/GetRelief.3 | 11 +++++------ 4 files changed, 53 insertions(+), 51 deletions(-) diff --git a/doc/3DBorder.3 b/doc/3DBorder.3 index de03645..122a8ea 100644 --- a/doc/3DBorder.3 +++ b/doc/3DBorder.3 @@ -13,49 +13,43 @@ Tk_Alloc3DBorderFromObj, Tk_Get3DBorder, Tk_Get3DBorderFromObj, Tk_Draw3DRectang .SH SYNOPSIS .nf \fB#include \fR -.sp + Tk_3DBorder -\fBTk_Alloc3DBorderFromObj(\fIinterp, tkwin, objPtr\fB)\fR +\fBTk_Alloc3DBorderFromObj\fR(\fIinterp, tkwin, objPtr\fR) .sp Tk_3DBorder -\fBTk_Get3DBorder(\fIinterp, tkwin, colorName\fB)\fR +\fBTk_Get3DBorder\fR(\fIinterp, tkwin, colorName\fR) .sp Tk_3DBorder -\fBTk_Get3DBorderFromObj(\fItkwin, objPtr\fB)\fR +\fBTk_Get3DBorderFromObj\fR(\fItkwin, objPtr\fR) .sp -void -\fBTk_Draw3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR +\fBTk_Draw3DRectangle\fR(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fR) .sp -void -\fBTk_Fill3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR +\fBTk_Fill3DRectangle\fR(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fR) .sp -void -\fBTk_Draw3DPolygon(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fB)\fR +\fBTk_Draw3DPolygon\fR(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fR) .sp -void -\fBTk_Fill3DPolygon(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fB)\fR +\fBTk_Fill3DPolygon\fR(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fR) .sp -void -\fBTk_3DVerticalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftBevel, relief\fB)\fR +\fBTk_3DVerticalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftBevel, relief\fR) .sp -void -\fBTk_3DHorizontalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftIn, rightIn, topBevel, relief\fB)\fR +\fBTk_3DHorizontalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftIn, rightIn, topBevel, relief\fR) .sp -void -\fBTk_SetBackgroundFromBorder(\fItkwin, border\fB)\fR +\fBTk_SetBackgroundFromBorder\fR(\fItkwin, border\fR) .sp const char * -\fBTk_NameOf3DBorder(\fIborder\fB)\fR +\fBTk_NameOf3DBorder\fR(\fIborder\fR) .sp XColor * -\fBTk_3DBorderColor(\fIborder\fB)\fR +\fBTk_3DBorderColor\fR(\fIborder\fR) .sp GC * -\fBTk_3DBorderGC(\fItkwin, border, which\fB)\fR +\fBTk_3DBorderGC\fR(\fItkwin, border, which\fR) .sp -\fBTk_Free3DBorderFromObj(\fItkwin, objPtr\fB)\fR +\fBTk_Free3DBorderFromObj\fR(\fItkwin, objPtr\fR) .sp -\fBTk_Free3DBorder(\fIborder\fB)\fR +\fBTk_Free3DBorder\fR(\fIborder\fR) +.fi .SH ARGUMENTS .AS "Tk_3DBorder" borderWidth .AP Tcl_Interp *interp in @@ -67,7 +61,7 @@ must be the window for which the border was allocated). Pointer to value whose value describes color corresponding to background (flat areas). Illuminated edges will be brighter than this and shadowed edges will be darker than this. -.AP const char *colorName in +.AP "const char" *colorName in Same as \fIobjPtr\fR except value is supplied as a string rather than a value. .AP Drawable drawable in @@ -192,8 +186,8 @@ which of several three-dimensional effects is desired: \fBTK_RELIEF_RAISED\fR means that the interior of the rectangle should appear raised relative to the exterior of the rectangle, and \fBTK_RELIEF_SUNKEN\fR means that the interior should appear depressed. -\fBTK_RELIEF_GROOVE\fR and \fBTK_RELIEF_RIDGE\fR mean that there should appear to be -a groove or ridge around the exterior of the rectangle. +\fBTK_RELIEF_GROOVE\fR and \fBTK_RELIEF_RIDGE\fR mean that there should +appear to be a groove or ridge around the exterior of the rectangle. .PP \fBTk_Fill3DRectangle\fR is somewhat like \fBTk_Draw3DRectangle\fR except that it first fills the rectangular area with the background color @@ -291,4 +285,5 @@ There should be exactly one call to \fBTk_Free3DBorderFromObj\fR or \fBTk_Free3DBorder\fR for each call to \fBTk_Alloc3DBorderFromObj\fR or \fBTk_Get3DBorder\fR. .SH KEYWORDS -3D, background, border, color, depressed, illumination, value, polygon, raised, shadow, three-dimensional effect +3D, background, border, color, depressed, illumination, value, polygon, +raised, shadow, three-dimensional effect diff --git a/doc/GetColor.3 b/doc/GetColor.3 index 0905d4e..4dce903 100644 --- a/doc/GetColor.3 +++ b/doc/GetColor.3 @@ -15,26 +15,27 @@ Tk_AllocColorFromObj, Tk_GetColor, Tk_GetColorFromObj, Tk_GetColorByValue, Tk_Na \fB#include \fR .sp XColor * -\fBTk_AllocColorFromObj(\fIinterp, tkwin, objPtr\fB)\fR +\fBTk_AllocColorFromObj\fR(\fIinterp, tkwin, objPtr\fR) .sp XColor * -\fBTk_GetColor(\fIinterp, tkwin, name\fB)\fR +\fBTk_GetColor\fR(\fIinterp, tkwin, name\fR) .sp XColor * -\fBTk_GetColorFromObj(\fItkwin, objPtr\fB)\fR +\fBTk_GetColorFromObj\fR(\fItkwin, objPtr\fR) .sp XColor * -\fBTk_GetColorByValue(\fItkwin, prefPtr\fB)\fR +\fBTk_GetColorByValue\fR(\fItkwin, prefPtr\fR) .sp const char * -\fBTk_NameOfColor(\fIcolorPtr\fB)\fR +\fBTk_NameOfColor\fR(\fIcolorPtr\fR) .sp GC -\fBTk_GCForColor(\fIcolorPtr, drawable\fB)\fR +\fBTk_GCForColor\fR(\fIcolorPtr, drawable\fR) .sp -\fBTk_FreeColorFromObj(\fItkwin, objPtr\fB)\fR +\fBTk_FreeColorFromObj\fR(\fItkwin, objPtr\fR) .sp -\fBTk_FreeColor(\fIcolorPtr\fB)\fR +\fBTk_FreeColor\fR(\fIcolorPtr\fR) +.fi .SH ARGUMENTS .AS "Tcl_Interp" *colorPtr .AP Tcl_Interp *interp in @@ -44,7 +45,7 @@ Token for window in which color will be used. .AP Tcl_Obj *objPtr in/out String value describes desired color; internal rep will be modified to cache pointer to corresponding (XColor *). -.AP const char *name in +.AP "const char" *name in Same as \fIobjPtr\fR except description of color is passed as a string and resulting (XColor *) is not cached. .AP XColor *prefPtr in @@ -71,6 +72,7 @@ in a particular window. The desired color is specified with a value whose string value must have one of the following forms: .TP 20 \fIcolorname\fR +. Any of the valid textual names for a color defined in the server's color database file, such as \fBred\fR or \fBPeachPuff\fR. .TP 20 @@ -81,6 +83,7 @@ server's color database file, such as \fBred\fR or \fBPeachPuff\fR. \fB#\fIRRRGGGBBB\fR .TP 20 \fB#\fIRRRRGGGGBBBB\fR +. A numeric specification of the red, green, and blue intensities to use to display the color. Each \fIR\fR, \fIG\fR, or \fIB\fR represents a single hexadecimal digit. The four forms permit diff --git a/doc/GetCursor.3 b/doc/GetCursor.3 index fdf773b..1428fb7 100644 --- a/doc/GetCursor.3 +++ b/doc/GetCursor.3 @@ -15,23 +15,24 @@ Tk_AllocCursorFromObj, Tk_GetCursor, Tk_GetCursorFromObj, Tk_GetCursorFromData, \fB#include \fR .sp Tk_Cursor -\fBTk_AllocCursorFromObj(\fIinterp, tkwin, objPtr\fB)\fR +\fBTk_AllocCursorFromObj\fR(\fIinterp, tkwin, objPtr\fR) .sp Tk_Cursor -\fBTk_GetCursor(\fIinterp, tkwin, name\fB)\fR +\fBTk_GetCursor\fR(\fIinterp, tkwin, name\fR) .sp Tk_Cursor -\fBTk_GetCursorFromObj(\fItkwin, objPtr\fB)\fR +\fBTk_GetCursorFromObj\fR(\fItkwin, objPtr\fR) .sp Tk_Cursor -\fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR +\fBTk_GetCursorFromData\fR(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fR) .sp const char * -\fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR +\fBTk_NameOfCursor\fR(\fIdisplay, cursor\fR) .sp -\fBTk_FreeCursorFromObj(\fItkwin, objPtr\fB)\fR +\fBTk_FreeCursorFromObj\fR(\fItkwin, objPtr\fR) .sp -\fBTk_FreeCursor(\fIdisplay, cursor\fB)\fR +\fBTk_FreeCursor\fR(\fIdisplay, cursor\fR) +.fi .SH ARGUMENTS .AS "unsigned long" *pixelPtr .AP Tcl_Interp *interp in @@ -41,7 +42,7 @@ Token for window in which the cursor will be used. .AP Tcl_Obj *objPtr in/out Description of cursor; see below for possible values. Internal rep will be modified to cache pointer to corresponding Tk_Cursor. -.AP const char *name in +.AP "const char" *name in Same as \fIobjPtr\fR except description of cursor is passed as a string and resulting Tk_Cursor is not cached. .AP "const char" *source in @@ -87,6 +88,7 @@ if \fIinterp\fR is not NULL. \fIObjPtr\fR must contain a standard Tcl list with one of the following forms: .TP \fIname\fR\0[\fIfgColor\fR\0[\fIbgColor\fR]] +. \fIName\fR is the name of a cursor in the standard X cursor cursor, i.e., any of the names defined in \fBcursorcursor.h\fR, without the \fBXC_\fR. Some example values are \fBX_cursor\fR, \fBhand2\fR, @@ -115,6 +117,7 @@ in preference to black and white cursors. .RE .TP \fB@\fIsourceName\0maskName\0fgColor\0bgColor\fR +. In this form, \fIsourceName\fR and \fImaskName\fR are the names of files describing cursors for the cursor's source bits and mask. Each file must be in standard X11 cursor format. @@ -124,12 +127,14 @@ cursor, in any of the forms acceptable to \fBTk_GetColor\fR. This form of the command will not work on Macintosh or Windows computers. .TP \fB@\fIsourceName\0fgColor\fR +. This form is similar to the one above, except that the source is used as mask also. This means that the cursor's background is transparent. This form of the command will not work on Macintosh or Windows computers. .TP \fB@\fIsourceName\fR +. This form only works on Windows, and will load a Windows system cursor (\fB.ani\fR or \fB.cur\fR) from the file specified in \fIsourceName\fR. @@ -196,7 +201,7 @@ argument that was passed to \fBTk_GetCursor\fR to create the cursor. If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR, or by any other mechanism, then the return value is a hexadecimal string giving the X identifier for the cursor. -Note: the string returned by \fBTk_NameOfCursor\fR is +Note that the string returned by \fBTk_NameOfCursor\fR is only guaranteed to persist until the next call to \fBTk_NameOfCursor\fR. Also, this call is not portable except for cursors returned by \fBTk_GetCursor\fR. diff --git a/doc/GetRelief.3 b/doc/GetRelief.3 index 5979662..d9ecb13 100644 --- a/doc/GetRelief.3 +++ b/doc/GetRelief.3 @@ -15,13 +15,14 @@ Tk_GetReliefFromObj, Tk_GetRelief, Tk_NameOfRelief \- translate between strings \fB#include \fR .sp int -\fBTk_GetReliefFromObj(\fIinterp, objPtr, reliefPtr\fB)\fR +\fBTk_GetReliefFromObj\fR(\fIinterp, objPtr, reliefPtr\fR) .sp int -\fBTk_GetRelief(\fIinterp, name, reliefPtr\fB)\fR +\fBTk_GetRelief\fR(\fIinterp, name, reliefPtr\fR) .sp const char * -\fBTk_NameOfRelief(\fIrelief\fB)\fR +\fBTk_NameOfRelief\fR(\fIrelief\fR) +.fi .SH ARGUMENTS .AS "Tcl_Interp" *reliefPtr .AP Tcl_Interp *interp in @@ -37,14 +38,12 @@ or .QW \fBsunken\fR (or any unique abbreviation thereof on input); the internal rep will be modified to cache corresponding relief value. -.AP char *string in +.AP "const char" *name in Same as \fIobjPtr\fR except description of relief is passed as a string. .AP int *reliefPtr out Pointer to location in which to store relief value corresponding to \fIobjPtr\fR or \fIname\fR. -.AP "const char" *name -Name of the relief. .AP int relief in Relief value (one of \fBTK_RELIEF_FLAT\fR, \fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, \fBTK_RELIEF_GROOVE\fR, \fBTK_RELIEF_SOLID\fR, -- cgit v0.12 From a32f271e085255f83c0122e58c78a5095959fa40 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 1 Sep 2024 21:15:38 +0000 Subject: Fix [0189a9ae39]: Use of Tk_Uid in Tk API. Also change Tk_GetCursorFromData(), so it doesn't need Tk_Uid's any more --- generic/tk.decls | 8 ++++---- generic/tk3d.c | 2 +- generic/tkColor.c | 2 +- generic/tkCursor.c | 10 +++++----- generic/tkDecls.h | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/generic/tk.decls b/generic/tk.decls index d1b5ffb..c776715 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -334,7 +334,7 @@ declare 79 { } declare 80 { Tk_3DBorder Tk_Get3DBorder(Tcl_Interp *interp, Tk_Window tkwin, - Tk_Uid colorName) + const char *colorName) } declare 81 { void Tk_GetAllBindings(Tcl_Interp *interp, @@ -363,7 +363,7 @@ declare 87 { int Tk_GetCapStyle(Tcl_Interp *interp, const char *str, int *capPtr) } declare 88 { - XColor *Tk_GetColor(Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid name) + XColor *Tk_GetColor(Tcl_Interp *interp, Tk_Window tkwin, const char *name) } declare 89 { XColor *Tk_GetColorByValue(Tk_Window tkwin, XColor *colorPtr) @@ -374,13 +374,13 @@ declare 90 { } declare 91 { Tk_Cursor Tk_GetCursor(Tcl_Interp *interp, Tk_Window tkwin, - Tk_Uid str) + const char *str) } declare 92 { Tk_Cursor Tk_GetCursorFromData(Tcl_Interp *interp, Tk_Window tkwin, const char *source, const char *mask, int width, int height, int xHot, int yHot, - Tk_Uid fg, Tk_Uid bg) + const char *fg, const char *bg) } declare 93 { Tk_Font Tk_GetFont(Tcl_Interp *interp, diff --git a/generic/tk3d.c b/generic/tk3d.c index 8082f0c..343759e 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -184,7 +184,7 @@ Tk_Get3DBorder( Tcl_Interp *interp, /* Place to store an error message. */ Tk_Window tkwin, /* Token for window in which border will be * drawn. */ - Tk_Uid colorName) /* String giving name of color for window + const char *colorName) /* String giving name of color for window * background. */ { Tcl_HashEntry *hashPtr; diff --git a/generic/tkColor.c b/generic/tkColor.c index baff5e7..9dc63b4 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -190,7 +190,7 @@ Tk_GetColor( Tcl_Interp *interp, /* Place to leave error message if color can't * be found. */ Tk_Window tkwin, /* Window in which color will be used. */ - Tk_Uid name) /* Name of color to be allocated (in form + const char *name) /* Name of color to be allocated (in form * suitable for passing to XParseColor). */ { Tcl_HashEntry *nameHashPtr; diff --git a/generic/tkCursor.c b/generic/tkCursor.c index 1bed0c4..f2d3af0 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -190,7 +190,7 @@ Tk_Cursor Tk_GetCursor( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tk_Window tkwin, /* Window in which cursor will be used. */ - Tk_Uid string) /* Description of cursor. See manual entry for + const char *string) /* Description of cursor. See manual entry for * details on legal syntax. */ { TkCursor *cursorPtr = TkcGetCursor(interp, tkwin, string); @@ -321,8 +321,8 @@ Tk_GetCursorFromData( const char *mask, /* Bitmap data for cursor mask. */ int width, int height, /* Dimensions of cursor. */ int xHot, int yHot, /* Location of hot-spot in cursor. */ - Tk_Uid fg, /* Foreground color for cursor. */ - Tk_Uid bg) /* Background color for cursor. */ + const char *fg, /* Foreground color for cursor. */ + const char *bg) /* Background color for cursor. */ { DataKey dataKey; Tcl_HashEntry *dataHashPtr; @@ -341,8 +341,8 @@ Tk_GetCursorFromData( dataKey.height = height; dataKey.xHot = xHot; dataKey.yHot = yHot; - dataKey.fg = fg; - dataKey.bg = bg; + dataKey.fg = Tk_GetUid(fg); + dataKey.bg = Tk_GetUid(bg); dataKey.display = Tk_Display(tkwin); dataHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorDataTable, (char *) &dataKey, &isNew); diff --git a/generic/tkDecls.h b/generic/tkDecls.h index 8695993..3c87821 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -296,7 +296,7 @@ EXTERN void Tk_GeometryRequest(Tk_Window tkwin, int reqWidth, int reqHeight); /* 80 */ EXTERN Tk_3DBorder Tk_Get3DBorder(Tcl_Interp *interp, Tk_Window tkwin, - Tk_Uid colorName); + const char *colorName); /* 81 */ EXTERN void Tk_GetAllBindings(Tcl_Interp *interp, Tk_BindingTable bindingTable, void *object); @@ -321,7 +321,7 @@ EXTERN int Tk_GetCapStyle(Tcl_Interp *interp, const char *str, int *capPtr); /* 88 */ EXTERN XColor * Tk_GetColor(Tcl_Interp *interp, Tk_Window tkwin, - Tk_Uid name); + const char *name); /* 89 */ EXTERN XColor * Tk_GetColorByValue(Tk_Window tkwin, XColor *colorPtr); /* 90 */ @@ -329,12 +329,12 @@ EXTERN Colormap Tk_GetColormap(Tcl_Interp *interp, Tk_Window tkwin, const char *str); /* 91 */ EXTERN Tk_Cursor Tk_GetCursor(Tcl_Interp *interp, Tk_Window tkwin, - Tk_Uid str); + const char *str); /* 92 */ EXTERN Tk_Cursor Tk_GetCursorFromData(Tcl_Interp *interp, Tk_Window tkwin, const char *source, const char *mask, int width, int height, - int xHot, int yHot, Tk_Uid fg, Tk_Uid bg); + int xHot, int yHot, const char *fg, const char *bg); /* 93 */ EXTERN Tk_Font Tk_GetFont(Tcl_Interp *interp, Tk_Window tkwin, const char *str); @@ -979,7 +979,7 @@ typedef struct TkStubs { void (*reserved77)(void); GC (*tk_GCForColor) (XColor *colorPtr, Drawable drawable); /* 78 */ void (*tk_GeometryRequest) (Tk_Window tkwin, int reqWidth, int reqHeight); /* 79 */ - Tk_3DBorder (*tk_Get3DBorder) (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid colorName); /* 80 */ + Tk_3DBorder (*tk_Get3DBorder) (Tcl_Interp *interp, Tk_Window tkwin, const char *colorName); /* 80 */ void (*tk_GetAllBindings) (Tcl_Interp *interp, Tk_BindingTable bindingTable, void *object); /* 81 */ int (*tk_GetAnchor) (Tcl_Interp *interp, const char *str, Tk_Anchor *anchorPtr); /* 82 */ const char * (*tk_GetAtomName) (Tk_Window tkwin, Atom atom); /* 83 */ @@ -987,7 +987,7 @@ typedef struct TkStubs { Pixmap (*tk_GetBitmap) (Tcl_Interp *interp, Tk_Window tkwin, const char *str); /* 85 */ Pixmap (*tk_GetBitmapFromData) (Tcl_Interp *interp, Tk_Window tkwin, const void *source, int width, int height); /* 86 */ int (*tk_GetCapStyle) (Tcl_Interp *interp, const char *str, int *capPtr); /* 87 */ - XColor * (*tk_GetColor) (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid name); /* 88 */ + XColor * (*tk_GetColor) (Tcl_Interp *interp, Tk_Window tkwin, const char *name); /* 88 */ XColor * (*tk_GetColorByValue) (Tk_Window tkwin, XColor *colorPtr); /* 89 */ Colormap (*tk_GetColormap) (Tcl_Interp *interp, Tk_Window tkwin, const char *str); /* 90 */ Tk_Cursor (*tk_GetCursor) (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid str); /* 91 */ -- cgit v0.12