diff options
Diffstat (limited to 'generic/tkVisual.c')
-rw-r--r-- | generic/tkVisual.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/generic/tkVisual.c b/generic/tkVisual.c index 8b0c155..ec8be11 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.c @@ -20,12 +20,12 @@ */ typedef struct VisualDictionary { - const char *name; /* Textual name of class. */ + char *name; /* Textual name of class. */ int minLength; /* Minimum # characters that must be specified * for an unambiguous match. */ int class; /* X symbol for class. */ } VisualDictionary; -static const VisualDictionary visualNames[] = { +static VisualDictionary visualNames[] = { {"best", 1, 0}, {"directcolor", 2, DirectColor}, {"grayscale", 1, GrayScale}, @@ -86,7 +86,7 @@ Visual * Tk_GetVisual( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tk_Window tkwin, /* Window in which visual will be used. */ - const char *string, /* String describing visual. See manual entry + CONST char *string, /* String describing visual. See manual entry * for details. */ int *depthPtr, /* The depth of the returned visual is stored * here. */ @@ -101,8 +101,8 @@ Tk_GetVisual( Visual *visual; ptrdiff_t length; int c, numVisuals, prio, bestPrio, i; - const char *p; - const VisualDictionary *dictPtr; + CONST char *p; + VisualDictionary *dictPtr; TkColormap *cmapPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; @@ -173,9 +173,9 @@ Tk_GetVisual( */ if (Tcl_GetInt(interp, string, &visualId) == TCL_ERROR) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad X identifier for visual: \"%s\"", string)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "VISUALID", NULL); + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "bad X identifier for visual: \"", + string, "\"", NULL); return NULL; } template.visualid = visualId; @@ -202,16 +202,12 @@ Tk_GetVisual( } } if (template.class == -1) { - Tcl_Obj *msgObj = Tcl_ObjPrintf( - "unknown or ambiguous visual name \"%s\": class must be ", - string); - + Tcl_AppendResult(interp, "unknown or ambiguous visual name \"", + string, "\": class must be ", NULL); for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) { - Tcl_AppendPrintfToObj(msgObj, "%s, ", dictPtr->name); + Tcl_AppendResult(interp, dictPtr->name, ", ", NULL); } - Tcl_AppendToObj(msgObj, "or default", -1); - Tcl_SetObjResult(interp, msgObj); - Tcl_SetErrorCode(interp, "TK", "LOOKUP", "VISUAL", string, NULL); + Tcl_AppendResult(interp, "or default", NULL); return NULL; } while (isspace(UCHAR(*p))) { @@ -219,8 +215,10 @@ Tk_GetVisual( } if (*p == 0) { template.depth = 10000; - } else if (Tcl_GetInt(interp, p, &template.depth) != TCL_OK) { - return NULL; + } else { + if (Tcl_GetInt(interp, p, &template.depth) != TCL_OK) { + return NULL; + } } if (c == 'b') { mask = 0; @@ -239,9 +237,8 @@ Tk_GetVisual( visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &template, &numVisuals); if (visInfoList == NULL) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "couldn't find an appropriate visual", -1)); - Tcl_SetErrorCode(interp, "TK", "VISUAL", "INAPPROPRIATE", NULL); + Tcl_SetResult(interp, "couldn't find an appropriate visual", + TCL_STATIC); return NULL; } @@ -304,7 +301,6 @@ Tk_GetVisual( bestPtr = &visInfoList[i]; bestPrio = prio; } - CLANG_ASSERT(bestPtr); *depthPtr = bestPtr->depth; visual = bestPtr->visual; XFree((char *) visInfoList); @@ -328,7 +324,7 @@ Tk_GetVisual( goto done; } } - cmapPtr = ckalloc(sizeof(TkColormap)); + cmapPtr = (TkColormap *) ckalloc(sizeof(TkColormap)); cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), visual, AllocNone); @@ -370,7 +366,7 @@ Colormap Tk_GetColormap( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tk_Window tkwin, /* Window where colormap will be used. */ - const char *string) /* String that identifies colormap: either + CONST char *string) /* String that identifies colormap: either * "new" or the name of another window. */ { Colormap colormap; @@ -383,7 +379,7 @@ Tk_GetColormap( */ if (strcmp(string, "new") == 0) { - cmapPtr = ckalloc(sizeof(TkColormap)); + cmapPtr = (TkColormap *) ckalloc(sizeof(TkColormap)); cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), Tk_Visual(tkwin), AllocNone); @@ -406,15 +402,13 @@ Tk_GetColormap( return None; } if (Tk_Screen(other) != Tk_Screen(tkwin)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't use colormap for %s: not on same screen", string)); - Tcl_SetErrorCode(interp, "TK", "COLORMAP", "SCREEN", NULL); + Tcl_AppendResult(interp, "can't use colormap for ", string, + ": not on same screen", NULL); return None; } if (Tk_Visual(other) != Tk_Visual(tkwin)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't use colormap for %s: incompatible visuals", string)); - Tcl_SetErrorCode(interp, "TK", "COLORMAP", "INCOMPATIBLE", NULL); + Tcl_AppendResult(interp, "can't use colormap for ", string, + ": incompatible visuals", NULL); return None; } colormap = Tk_Colormap(other); @@ -484,7 +478,7 @@ Tk_FreeColormap( } else { prevPtr->nextPtr = cmapPtr->nextPtr; } - ckfree(cmapPtr); + ckfree((char *) cmapPtr); } return; } |