diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-07-31 14:39:04 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-07-31 14:39:04 (GMT) |
commit | 57697b5b22a5851bca41ba3ec058f1de355ba5dc (patch) | |
tree | 6faf126294b1235b3307dcc394cab895489ceef6 /generic | |
parent | d4a4017589dd52fa8e9667df9d754fd62abd6bed (diff) | |
download | tk-57697b5b22a5851bca41ba3ec058f1de355ba5dc.zip tk-57697b5b22a5851bca41ba3ec058f1de355ba5dc.tar.gz tk-57697b5b22a5851bca41ba3ec058f1de355ba5dc.tar.bz2 |
minor improvements to flag handling
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkArgv.c | 4 | ||||
-rw-r--r-- | generic/tkBind.c | 6 | ||||
-rw-r--r-- | generic/tkCanvPs.c | 2 | ||||
-rw-r--r-- | generic/tkEvent.c | 2 | ||||
-rw-r--r-- | generic/tkFont.c | 29 | ||||
-rw-r--r-- | generic/tkFrame.c | 59 | ||||
-rw-r--r-- | generic/tkGrab.c | 4 | ||||
-rw-r--r-- | generic/tkImgPNG.c | 2 | ||||
-rw-r--r-- | generic/tkImgPhInstance.c | 19 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 8 | ||||
-rw-r--r-- | generic/tkPlace.c | 6 | ||||
-rw-r--r-- | generic/tkPointer.c | 2 | ||||
-rw-r--r-- | generic/tkScrollbar.c | 4 | ||||
-rw-r--r-- | generic/tkWindow.c | 30 | ||||
-rw-r--r-- | generic/ttk/ttkEntry.c | 4 | ||||
-rw-r--r-- | generic/ttk/ttkLayout.c | 8 |
16 files changed, 94 insertions, 95 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c index dbcfc7d..6c2c5c5 100644 --- a/generic/tkArgv.c +++ b/generic/tkArgv.c @@ -196,7 +196,7 @@ Tk_ParseArgv( if (argc == 0) { goto missingArg; } - *((const char **)infoPtr->dst) = argv[srcIndex]; + *((const char **) infoPtr->dst) = argv[srcIndex]; srcIndex++; argc--; break; @@ -204,7 +204,7 @@ Tk_ParseArgv( if (argc == 0) { goto missingArg; } - *((Tk_Uid *)infoPtr->dst) = Tk_GetUid(argv[srcIndex]); + *((Tk_Uid *) infoPtr->dst) = Tk_GetUid(argv[srcIndex]); srcIndex++; argc--; break; diff --git a/generic/tkBind.c b/generic/tkBind.c index 4029571..7126e24 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3935,7 +3935,7 @@ ParseEventDescription( eventMask = ButtonPressMask; } else if (eventFlags & KEY) { goto getKeysym; - } else if ((eventFlags & BUTTON) == 0) { + } else if (!(eventFlags & BUTTON)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "specified button \"%s\" for non-button event", field)); @@ -3959,7 +3959,7 @@ ParseEventDescription( if (eventFlags == 0) { patPtr->eventType = KeyPress; eventMask = KeyPressMask; - } else if ((eventFlags & KEY) == 0) { + } else if (!(eventFlags & KEY)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "specified keysym \"%s\" for non-key event", field)); Tcl_SetErrorCode(interp, "TK", "EVENT", "NON_KEY", NULL); @@ -4083,7 +4083,7 @@ GetPatternObj( */ if ((patPtr->eventType == KeyPress) - && ((psPtr->flags & PAT_NEARBY) == 0) + && !(psPtr->flags & PAT_NEARBY) && (patPtr->needMods == 0) && (patPtr->detail.keySym < 128) && isprint(UCHAR(patPtr->detail.keySym)) diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index fb5172e..6542864 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -386,7 +386,7 @@ TkCanvPostscriptCmd( result = TCL_ERROR; goto cleanup; } - if ((mode & TCL_WRITABLE) == 0) { + if (!(mode & TCL_WRITABLE)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "channel \"%s\" wasn't opened for writing", psInfo.channelName)); diff --git a/generic/tkEvent.c b/generic/tkEvent.c index dfa46ff..7dd2813 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -1336,7 +1336,7 @@ Tk_HandleEvent( } } else { for (handlerPtr = winPtr->handlerList; handlerPtr != NULL; ) { - if ((handlerPtr->mask & mask) != 0) { + if (handlerPtr->mask & mask) { ip.nextHandler = handlerPtr->nextPtr; handlerPtr->proc(handlerPtr->clientData, eventPtr); handlerPtr = ip.nextHandler; diff --git a/generic/tkFont.c b/generic/tkFont.c index 2d74356..4485df8 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -439,7 +439,7 @@ TkFontPkgFree( hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&fiPtr->namedTable); - if (fiPtr->updatePending != 0) { + if (fiPtr->updatePending) { Tcl_CancelIdleCall(TheWorldHasChanged, fiPtr); } ckfree(fiPtr); @@ -616,7 +616,7 @@ Tk_FontObjCmd( if (namedHashPtr != NULL) { nfPtr = Tcl_GetHashValue(namedHashPtr); } - if ((namedHashPtr == NULL) || (nfPtr->deletePending != 0)) { + if ((namedHashPtr == NULL) || nfPtr->deletePending) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "named font \"%s\" doesn't exist", string)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); @@ -688,7 +688,7 @@ Tk_FontObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "fontname ?fontname ...?"); return TCL_ERROR; } - for (i = 2; i < objc && result == TCL_OK; i++) { + for (i = 2; (i < objc) && (result == TCL_OK); i++) { string = Tcl_GetString(objv[i]); result = TkDeleteNamedFont(interp, tkwin, string); } @@ -794,7 +794,7 @@ Tk_FontObjCmd( while (namedHashPtr != NULL) { NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr); - if (nfPtr->deletePending == 0) { + if (!nfPtr->deletePending) { char *string = Tcl_GetHashKey(&fiPtr->namedTable, namedHashPtr); @@ -855,7 +855,7 @@ UpdateDependentFonts( fontPtr != NULL; fontPtr = fontPtr->nextPtr) { if (fontPtr->namedHashPtr == namedHashPtr) { TkpGetFontFromAttributes(fontPtr, tkwin, &nfPtr->fa); - if (fiPtr->updatePending == 0) { + if (!fiPtr->updatePending) { fiPtr->updatePending = 1; Tcl_DoWhenIdle(TheWorldHasChanged, fiPtr); } @@ -949,7 +949,7 @@ TkCreateNamedFont( namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew); if (!isNew) { nfPtr = Tcl_GetHashValue(namedHashPtr); - if (nfPtr->deletePending == 0) { + if (!nfPtr->deletePending) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "named font \"%s\" already exists", name)); @@ -1427,7 +1427,7 @@ Tk_FreeFont( nfPtr = Tcl_GetHashValue(fontPtr->namedHashPtr); nfPtr->refCount--; - if ((nfPtr->refCount == 0) && (nfPtr->deletePending != 0)) { + if ((nfPtr->refCount == 0) && nfPtr->deletePending) { Tcl_DeleteHashEntry(fontPtr->namedHashPtr); ckfree(nfPtr); } @@ -1755,7 +1755,7 @@ Tk_PostscriptFontName( slantString = NULL; if (fontPtr->fa.slant == TK_FS_ROMAN) { - ; + /* Do nothing */ } else if ((strcmp(family, "Helvetica") == 0) || (strcmp(family, "Courier") == 0) || (strcmp(family, "AvantGarde") == 0)) { @@ -2143,7 +2143,7 @@ Tk_ComputeTextLayout( * on the next line. Otherwise "Hello" and "Hello\n" are the same height. */ - if ((layoutPtr->numChunks > 0) && ((flags & TK_IGNORE_NEWLINES) == 0)) { + if ((layoutPtr->numChunks > 0) && !(flags & TK_IGNORE_NEWLINES)) { if (layoutPtr->chunks[layoutPtr->numChunks - 1].start[0] == '\n') { chunkPtr = NewChunk(&layoutPtr, &maxChunks, start, 0, curX, curX, baseline); @@ -2905,7 +2905,7 @@ Tk_IntersectTextLayout( result = 0; for (i = 0; i < layoutPtr->numChunks; i++) { - if ((chunkPtr->start[0] == '\n') || (chunkPtr->numBytes==0)) { + if ((chunkPtr->start[0] == '\n') || (chunkPtr->numBytes == 0)) { /* * Newline characters and empty chunks are not counted when * computing area intersection (but tab characters would still be @@ -3577,7 +3577,7 @@ ParseFontNameObj( } dash = strchr(string + 1, '-'); if ((dash != NULL) - && (!isspace(UCHAR(dash[-1])))) { /* INTL: ISO space */ + && !isspace(UCHAR(dash[-1]))) { /* INTL: ISO space */ goto xlfd; } @@ -3830,7 +3830,7 @@ TkFontParseXLFD( * parsed set of attributes)". */ - if ((i > XLFD_ADD_STYLE) && (FieldSpecified(field[XLFD_ADD_STYLE]))) { + if ((i > XLFD_ADD_STYLE) && FieldSpecified(field[XLFD_ADD_STYLE])) { if (atoi(field[XLFD_ADD_STYLE]) != 0) { for (j = XLFD_NUMFIELDS - 1; j >= XLFD_ADD_STYLE; j--) { field[j + 1] = field[j]; @@ -4228,12 +4228,11 @@ TkFontGetFirstTextLayout( Tk_Font *font, char *dst) { - TextLayout *layoutPtr; + TextLayout *layoutPtr = (TextLayout *) layout; LayoutChunk *chunkPtr; int numBytesInChunk; - layoutPtr = (TextLayout *) layout; - if ((layoutPtr==NULL) || (layoutPtr->numChunks==0) + if ((layoutPtr == NULL) || (layoutPtr->numChunks == 0) || (layoutPtr->chunks->numDisplayChars <= 0)) { dst[0] = '\0'; return 0; diff --git a/generic/tkFrame.c b/generic/tkFrame.c index f09369e..8bc44ce 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -334,8 +334,8 @@ static void MapFrame(ClientData clientData); static const Tk_ClassProcs frameClass = { sizeof(Tk_ClassProcs), /* size */ FrameWorldChanged, /* worldChangedProc */ - NULL, /* createProc */ - NULL /* modalProc */ + NULL, /* createProc */ + NULL /* modalProc */ }; /* @@ -465,7 +465,7 @@ CreateFrame( Tk_Window newWin; const char *className, *screenName, *visualName, *colormapName; const char *arg, *useOption; - int i, c, length, depth; + int i, length, depth; unsigned int mask; Colormap colormap; Visual *visual; @@ -496,20 +496,19 @@ CreateFrame( if (length < 2) { continue; } - c = arg[1]; - if ((c == 'c') && (length >= 3) + if ((arg[1] == 'c') && (length >= 3) && (strncmp(arg, "-class", (unsigned) length) == 0)) { className = Tcl_GetString(objv[i+1]); - } else if ((c == 'c') + } else if ((arg[1] == 'c') && (length >= 3) && (strncmp(arg, "-colormap", (unsigned) length) == 0)) { colormapName = Tcl_GetString(objv[i+1]); - } else if ((c == 's') && (type == TYPE_TOPLEVEL) + } else if ((arg[1] == 's') && (type == TYPE_TOPLEVEL) && (strncmp(arg, "-screen", (unsigned) length) == 0)) { screenName = Tcl_GetString(objv[i+1]); - } else if ((c == 'u') && (type == TYPE_TOPLEVEL) + } else if ((arg[1] == 'u') && (type == TYPE_TOPLEVEL) && (strncmp(arg, "-use", (unsigned) length) == 0)) { useOption = Tcl_GetString(objv[i+1]); - } else if ((c == 'v') + } else if ((arg[1] == 'v') && (strncmp(arg, "-visual", (unsigned) length) == 0)) { visualName = Tcl_GetString(objv[i+1]); } @@ -550,8 +549,8 @@ CreateFrame( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unable to create widget \"%s\"", Tcl_GetString(objv[1]))); - Tcl_SetErrorCode(interp, "TK", "APP_GONE", NULL); - newWin = NULL; + Tcl_SetErrorCode(interp, "TK", "APPLICATION_GONE", NULL); + return TCL_ERROR; } else { /* * We were called from Tk_Init; create a new application. @@ -561,15 +560,14 @@ CreateFrame( } if (newWin == NULL) { goto error; - } else { - /* - * Mark Tk frames as suitable candidates for [wm manage]. - */ + } - TkWindow *winPtr = (TkWindow *)newWin; + /* + * Mark Tk frames as suitable candidates for [wm manage]. + */ + + ((TkWindow *) newWin)->flags |= TK_WM_MANAGEABLE; - winPtr->flags |= TK_WM_MANAGEABLE; - } if (className == NULL) { className = Tk_GetOption(newWin, "class", "Class"); if (className == NULL) { @@ -580,10 +578,9 @@ CreateFrame( if (useOption == NULL) { useOption = Tk_GetOption(newWin, "use", "Use"); } - if ((useOption != NULL) && (*useOption != 0)) { - if (TkpUseWindow(interp, newWin, useOption) != TCL_OK) { - goto error; - } + if ((useOption != NULL) && (*useOption != 0) + && (TkpUseWindow(interp, newWin, useOption) != TCL_OK)) { + goto error; } if (visualName == NULL) { visualName = Tk_GetOption(newWin, "visual", "Visual"); @@ -633,12 +630,11 @@ CreateFrame( framePtr = ckalloc(sizeof(Frame)); memset(framePtr, 0, sizeof(Frame)); } - framePtr->tkwin = newWin; - framePtr->display = Tk_Display(newWin); - framePtr->interp = interp; - framePtr->widgetCmd = Tcl_CreateObjCommand(interp, - Tk_PathName(newWin), FrameWidgetObjCmd, framePtr, - FrameCmdDeletedProc); + framePtr->tkwin = newWin; + framePtr->display = Tk_Display(newWin); + framePtr->interp = interp; + framePtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(newWin), + FrameWidgetObjCmd, framePtr, FrameCmdDeletedProc); framePtr->optionTable = optionTable; framePtr->type = type; framePtr->colormap = colormap; @@ -668,16 +664,15 @@ CreateFrame( (ConfigureFrame(interp, framePtr, objc-2, objv+2) != TCL_OK)) { goto error; } - if ((framePtr->isContainer)) { - if (framePtr->useThis == NULL) { - TkpMakeContainer(framePtr->tkwin); - } else { + if (framePtr->isContainer) { + if (framePtr->useThis != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "windows cannot have both the -use and the -container" " option set", -1)); Tcl_SetErrorCode(interp, "TK", "FRAME", "CONTAINMENT", NULL); goto error; } + TkpMakeContainer(framePtr->tkwin); } if (type == TYPE_TOPLEVEL) { Tcl_DoWhenIdle(MapFrame, framePtr); diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 6a5fac6..2df5552 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -447,7 +447,7 @@ Tk_Grab( dispPtr->grabFlags &= ~(GRAB_GLOBAL|GRAB_TEMP_GLOBAL); XQueryPointer(dispPtr->display, winPtr->window, &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, &dummy6, &state); - if ((state & ALL_BUTTONS) != 0) { + if (state & ALL_BUTTONS) { dispPtr->grabFlags |= GRAB_TEMP_GLOBAL; goto setGlobalGrab; } @@ -859,7 +859,7 @@ TkPointerEvent( } } if (eventPtr->type == ButtonPress) { - if ((eventPtr->xbutton.state & ALL_BUTTONS) == 0) { + if (!(eventPtr->xbutton.state & ALL_BUTTONS)) { if (outsideGrabTree) { TkChangeEventWindow(eventPtr, dispPtr->grabWinPtr); Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD); diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index aff2496..b159c45 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -1964,7 +1964,7 @@ DecodeLine( */ if ((PNG_COLOR_PLTE != pngPtr->colorType) && - ((pngPtr->colorType & PNG_COLOR_ALPHA) == 0)) { + !(pngPtr->colorType & PNG_COLOR_ALPHA)) { unsigned char alpha; if (pngPtr->useTRNS) { diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 5429ee3..3097489 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -1068,8 +1068,7 @@ GetColorTable( * Allocate colors for this color table if necessary. */ - if ((colorPtr->numColors == 0) - && ((colorPtr->flags & BLACK_AND_WHITE) == 0)) { + if ((colorPtr->numColors == 0) && !(colorPtr->flags & BLACK_AND_WHITE)) { AllocateColors(colorPtr); } } @@ -1104,12 +1103,12 @@ FreeColorTable( } if (force) { - if ((colorPtr->flags & DISPOSE_PENDING) != 0) { + if (colorPtr->flags & DISPOSE_PENDING) { Tcl_CancelIdleCall(DisposeColorTable, colorPtr); colorPtr->flags &= ~DISPOSE_PENDING; } DisposeColorTable(colorPtr); - } else if ((colorPtr->flags & DISPOSE_PENDING) == 0) { + } else if (!(colorPtr->flags & DISPOSE_PENDING)) { Tcl_DoWhenIdle(DisposeColorTable, colorPtr); colorPtr->flags |= DISPOSE_PENDING; } @@ -1813,11 +1812,11 @@ TkImgDitherInstance( } c = ((c + 2056) >> 4) - 128; - if ((masterPtr->flags & COLOR_IMAGE) == 0) { - c += srcPtr[0]; - } else { + if (masterPtr->flags & COLOR_IMAGE) { c += (unsigned) (srcPtr[0] * 11 + srcPtr[1] * 16 + srcPtr[2] * 5 + 16) >> 5; + } else { + c += srcPtr[0]; } srcPtr += 4; @@ -1886,11 +1885,11 @@ TkImgDitherInstance( } c = ((c + 2056) >> 4) - 128; - if ((masterPtr->flags & COLOR_IMAGE) == 0) { - c += srcPtr[0]; - } else { + if (masterPtr->flags & COLOR_IMAGE) { c += (unsigned)(srcPtr[0] * 11 + srcPtr[1] * 16 + srcPtr[2] * 5 + 16) >> 5; + } else { + c += srcPtr[0]; } srcPtr += 4; diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 559268a..ce160a4 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -687,7 +687,7 @@ ImgPhotoCmd( * Fill in default values for unspecified parameters. */ - if (((options.options & OPT_FROM) == 0) || (options.fromX2 < 0)) { + if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { options.fromX2 = masterPtr->width; options.fromY2 = masterPtr->height; } @@ -833,7 +833,7 @@ ImgPhotoCmd( &imageHeight, &oldformat) == TCL_OK) { Tcl_Obj *format, *data; - if (((options.options & OPT_TO) == 0) || (options.toX2 < 0)) { + if (!(options.options & OPT_TO) || (options.toX2 < 0)) { options.toX2 = options.toX + imageWidth; options.toY2 = options.toY + imageHeight; } @@ -1056,7 +1056,7 @@ ImgPhotoCmd( Tcl_Close(NULL, chan); return TCL_ERROR; } - if (((options.options & OPT_FROM) == 0) || (options.fromX2 < 0)) { + if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { width = imageWidth - options.fromX; height = imageHeight - options.fromY; } else { @@ -1521,7 +1521,7 @@ ParseSubcommandOptions( * in the interpreter and return. */ - if ((allowedOptions & bit) == 0) { + if (!(allowedOptions & bit)) { goto unknownOrAmbiguousOption; } diff --git a/generic/tkPlace.c b/generic/tkPlace.c index caa7cc1..afba488 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -654,7 +654,7 @@ ConfigureSlave( slavePtr->flags |= CHILD_WIDTH; } - if (((mask & IN_MASK) == 0) && (slavePtr->masterPtr != NULL)) { + if (!(mask & IN_MASK) && (slavePtr->masterPtr != NULL)) { /* * If no -in option was passed and the slave is already placed then * just recompute the placement. @@ -1183,8 +1183,8 @@ PlaceRequestProc( Slave *slavePtr = clientData; Master *masterPtr; - if (((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) != 0) - && ((slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) != 0)) { + if ((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) + && (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) { return; } masterPtr = slavePtr->masterPtr; diff --git a/generic/tkPointer.c b/generic/tkPointer.c index eab6e48..451373d 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -286,7 +286,7 @@ Tk_UpdatePointer( tsdPtr->restrictWinPtr = winPtr; TkpSetCapture(tsdPtr->restrictWinPtr); - } else if ((tsdPtr->lastState & ALL_BUTTONS) == 0) { + } else if (!(tsdPtr->lastState & ALL_BUTTONS)) { /* * Mouse is in a non-button grab, so ensure the button * grab is inside the grab tree. diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index fb06093..2d91db6 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -687,10 +687,10 @@ void TkScrollbarEventuallyRedraw( TkScrollbar *scrollPtr) /* Information about widget. */ { - if ((scrollPtr->tkwin == NULL) || (!Tk_IsMapped(scrollPtr->tkwin))) { + if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(scrollPtr->tkwin)) { return; } - if ((scrollPtr->flags & REDRAW_PENDING) == 0) { + if (!(scrollPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(TkpDisplayScrollbar, scrollPtr); scrollPtr->flags |= REDRAW_PENDING; } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 4e39d6e..f4138b2 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -387,7 +387,7 @@ CreateTopLevelWindow( } else { dispPtr = GetScreen(interp, screenName, &screenId); if (dispPtr == NULL) { - return (Tk_Window) NULL; + return NULL; } } @@ -420,7 +420,7 @@ CreateTopLevelWindow( if (parent != NULL) { if (NameWindow(interp, winPtr, (TkWindow *) parent, name) != TCL_OK) { Tk_DestroyWindow((Tk_Window) winPtr); - return (Tk_Window) NULL; + return NULL; } } TkWmNewWindow(winPtr); @@ -803,7 +803,7 @@ NameWindow( length1 = strlen(parentPtr->pathName); length2 = strlen(name); - if ((length1+length2+2) <= FIXED_SIZE) { + if ((length1 + length2 + 2) <= FIXED_SIZE) { pathName = staticSpace; } else { pathName = ckalloc(length1 + length2 + 2); @@ -861,7 +861,7 @@ TkCreateMainWindow( const char *screenName, /* Name of screen on which to create window. * Empty or NULL string means use DISPLAY * environment variable. */ - const char *baseName) /* Base name for application; usually of the + const char *baseName) /* Base name for application; usually of the * form "prog instance". */ { Tk_Window tkwin; @@ -954,15 +954,20 @@ TkCreateMainWindow( isSafe = Tcl_IsSafe(interp); for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { - if ((cmdPtr->objProc == NULL)) { + if (cmdPtr->objProc == NULL) { Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs"); } + #if defined(__WIN32__) && !defined(STATIC_BUILD) if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->reserved9) { - /* We are running on Cygwin, so don't use the win32 dialogs */ + /* + * We are running on Cygwin, so don't use the win32 dialogs. + */ + continue; } -#endif +#endif /* __WIN32__ && !STATIC_BUILD */ + if (cmdPtr->flags & PASSMAINWINDOW) { clientData = tkwin; } else { @@ -1218,8 +1223,7 @@ Tk_CreateWindowFromPath( "can't create window: parent has been destroyed", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", NULL); return NULL; - } - if (((TkWindow *) parent)->flags & TK_CONTAINER) { + } else if (((TkWindow *) parent)->flags & TK_CONTAINER) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't create window: its parent has -container = yes", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", NULL); @@ -1538,7 +1542,7 @@ Tk_DestroyWindow( */ if ((winPtr->mainPtr->interp != NULL) && - (!Tcl_InterpDeleted(winPtr->mainPtr->interp))) { + !Tcl_InterpDeleted(winPtr->mainPtr->interp)) { for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { Tcl_CreateCommand(winPtr->mainPtr->interp, cmdPtr->name, TkDeadAppCmd, NULL, NULL); @@ -1623,7 +1627,7 @@ Tk_DestroyWindow( TkCloseDisplay(dispPtr); } -#endif +#endif /* !WIN32 && NOT_YET */ } } Tcl_EventuallyFree(winPtr, TCL_DYNAMIC); @@ -2446,8 +2450,8 @@ Tcl_Interp * Tk_Interp( Tk_Window tkwin) { - if (tkwin != NULL && ((TkWindow *)tkwin)->mainPtr != NULL) { - return ((TkWindow *)tkwin)->mainPtr->interp; + if (tkwin != NULL && ((TkWindow *) tkwin)->mainPtr != NULL) { + return ((TkWindow *) tkwin)->mainPtr->interp; } return NULL; } diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index c85751e..5d0a435 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1177,13 +1177,13 @@ static void EntryDisplay(void *clientData, Drawable d) textarea = Ttk_ClientRegion(entryPtr->core.layout, "textarea"); showCursor = - (entryPtr->core.flags & CURSOR_ON) != 0 + (entryPtr->core.flags & CURSOR_ON) && EntryEditable(entryPtr) && entryPtr->entry.insertPos >= leftIndex && entryPtr->entry.insertPos <= rightIndex ; showSelection = - (entryPtr->core.state & TTK_STATE_DISABLED) == 0 + !(entryPtr->core.state & TTK_STATE_DISABLED) && selFirst > -1 && selLast > leftIndex && selFirst <= rightIndex diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index 15ceaa8..de9d795 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -791,7 +791,7 @@ Tcl_Obj *Ttk_UnparseLayoutTemplate(Ttk_TemplateNode *node) int side = 0; unsigned sideFlags = flags & _TTK_MASK_PACK; - while ((sideFlags & TTK_PACK_LEFT) == 0) { + while (!(sideFlags & TTK_PACK_LEFT)) { ++side; sideFlags >>= 1; } @@ -800,9 +800,11 @@ Tcl_Obj *Ttk_UnparseLayoutTemplate(Ttk_TemplateNode *node) } } - /* In Ttk_ParseLayoutTemplate, default -sticky is "nsew", - * so always include this even if no sticky bits are set. + /* + * In Ttk_ParseLayoutTemplate, default -sticky is "nsew", so always + * include this even if no sticky bits are set. */ + APPENDSTR("-sticky"); APPENDOBJ(Ttk_NewStickyObj(flags & _TTK_MASK_STICK)); |