diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2008-04-27 22:38:54 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2008-04-27 22:38:54 (GMT) |
commit | 4513cb9f431ea8c6b151913a016ec6c75bcac559 (patch) | |
tree | 681f7c2354a3726da3ab7da646d316c1275f540d /generic/tkOption.c | |
parent | 1876f5f7ee429456ad89540bcf659c092245bf1b (diff) | |
download | tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.zip tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.tar.gz tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.tar.bz2 |
Get rid of pre-C89-isms (esp. CONST vs const).
Diffstat (limited to 'generic/tkOption.c')
-rw-r--r-- | generic/tkOption.c | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/generic/tkOption.c b/generic/tkOption.c index 1fac8b4..06b67f9 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkOption.c,v 1.24 2007/12/13 15:24:16 dgp Exp $ + * RCS: @(#) $Id: tkOption.c,v 1.25 2008/04/27 22:38:56 dkf Exp $ */ #include "tkInt.h" @@ -248,8 +248,8 @@ void Tk_AddOption( Tk_Window tkwin, /* Window token; option will be associated * with main window for this window. */ - CONST char *name, /* Multi-element name of option. */ - CONST char *value, /* String value for option. */ + const char *name, /* Multi-element name of option. */ + const char *value, /* String value for option. */ int priority) /* Overall priority level to use for this * option, such as TK_USER_DEFAULT_PRIO or * TK_INTERACTIVE_PRIO. Must be between 0 and @@ -259,13 +259,13 @@ Tk_AddOption( register ElArray **arrayPtrPtr; register Element *elPtr; Element newEl; - register CONST char *p; - CONST char *field; + register const char *p; + const char *field; int count, firstField; ptrdiff_t length; #define TMP_SIZE 100 char tmp[TMP_SIZE+1]; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->mainPtr->optionRootPtr == NULL) { @@ -402,8 +402,8 @@ Tk_Uid Tk_GetOption( Tk_Window tkwin, /* Token for window that option is associated * with. */ - CONST char *name, /* Name of option. */ - CONST char *className) /* Class of option. NULL means there is no + const char *name, /* Name of option. */ + const char *className) /* Class of option. NULL means there is no * class for this option: just check for * name. */ { @@ -413,7 +413,7 @@ Tk_GetOption( register int count; StackLevel *levelPtr; int stackDepth[NUM_STACKS]; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -477,16 +477,16 @@ Tk_GetOption( */ for (elPtr = tsdPtr->stacks[EXACT_LEAF_NAME]->els, - count = stackDepth[EXACT_LEAF_NAME]; count > 0; - elPtr++, count--) { + count = stackDepth[EXACT_LEAF_NAME]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == nameId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; } } for (elPtr = tsdPtr->stacks[WILDCARD_LEAF_NAME]->els, - count = stackDepth[WILDCARD_LEAF_NAME]; count > 0; - elPtr++, count--) { + count = stackDepth[WILDCARD_LEAF_NAME]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == nameId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; @@ -496,16 +496,16 @@ Tk_GetOption( if (className != NULL) { classId = Tk_GetUid(className); for (elPtr = tsdPtr->stacks[EXACT_LEAF_CLASS]->els, - count = stackDepth[EXACT_LEAF_CLASS]; count > 0; - elPtr++, count--) { + count = stackDepth[EXACT_LEAF_CLASS]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == classId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; } } for (elPtr = tsdPtr->stacks[WILDCARD_LEAF_CLASS]->els, - count = stackDepth[WILDCARD_LEAF_CLASS]; count > 0; - elPtr++, count--) { + count = stackDepth[WILDCARD_LEAF_CLASS]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == classId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; @@ -535,7 +535,7 @@ Tk_GetOption( * Extract the masquerade class name from the name field. */ - classNameLength = (unsigned int)(masqName - name); + classNameLength = (unsigned) (masqName - name); masqClass = (char *) ckalloc(classNameLength + 1); strncpy(masqClass, name, classNameLength); masqClass[classNameLength] = '\0'; @@ -614,14 +614,14 @@ Tk_OptionObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of Tcl_Obj arguments. */ - Tcl_Obj *CONST objv[]) /* Tcl_Obj arguments. */ + Tcl_Obj *const objv[]) /* Tcl_Obj arguments. */ { - Tk_Window tkwin = (Tk_Window) clientData; + Tk_Window tkwin = clientData; int index, result; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - static CONST char *optionCmds[] = { + static const char *optionCmds[] = { "add", "clear", "get", "readfile", NULL }; @@ -644,6 +644,7 @@ Tk_OptionObjCmd( switch ((enum optionVals) index) { case OPTION_ADD: { int priority; + if ((objc != 4) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "pattern value ?priority?"); return TCL_ERROR; @@ -693,7 +694,7 @@ Tk_OptionObjCmd( value = Tk_GetOption(window, Tcl_GetString(objv[3]), Tcl_GetString(objv[4])); if (value != NULL) { - Tcl_SetResult(interp, (char *)value, TCL_STATIC); + Tcl_SetResult(interp, (char *) value, TCL_STATIC); } break; } @@ -743,7 +744,7 @@ void TkOptionDeadWindow( register TkWindow *winPtr) /* Window to be cleaned up. */ { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -799,7 +800,7 @@ TkOptionClassChanged( { int i, j, *basePtr; ElArray *arrayPtr; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->optionLevel == -1) { @@ -930,7 +931,6 @@ AddFromString( src = string; lineNum = 1; while (1) { - /* * Skip leading white space and empty lines and comment lines, and * check for the end of the spec. @@ -1073,7 +1073,7 @@ ReadOptionFile( * TK_INTERACTIVE_PRIO. Must be between 0 and * TK_MAX_PRIO. */ { - CONST char *realName; + const char *realName; char *buffer; int result, bufferSize; Tcl_Channel chan; @@ -1108,7 +1108,7 @@ ReadOptionFile( */ bufferSize = (int) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_END); - (void) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_SET); + Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_SET); if (bufferSize < 0) { Tcl_AppendResult(interp, "error seeking to end of file \"", @@ -1117,7 +1117,7 @@ ReadOptionFile( return TCL_ERROR; } - buffer = (char *) ckalloc((unsigned) bufferSize+1); + buffer = ckalloc((unsigned) bufferSize+1); bufferSize = Tcl_Read(chan, buffer, bufferSize); if (bufferSize < 0) { Tcl_AppendResult(interp, "error reading file \"", fileName, "\":", @@ -1153,9 +1153,8 @@ static ElArray * NewArray( int numEls) /* How many elements of space to allocate. */ { - register ElArray *arrayPtr; + register ElArray *arrayPtr = (ElArray *) ckalloc(EL_ARRAY_SIZE(numEls)); - arrayPtr = (ElArray *) ckalloc(EL_ARRAY_SIZE(numEls)); arrayPtr->arraySize = numEls; arrayPtr->numUsed = 0; arrayPtr->nextToUse = arrayPtr->els; @@ -1236,7 +1235,7 @@ SetupStacks( int level, i, *iPtr; register StackLevel *levelPtr; register ElArray *arrayPtr; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -1313,10 +1312,8 @@ SetupStacks( */ if (tsdPtr->curLevel >= tsdPtr->numLevels) { - StackLevel *newLevels; - - newLevels = (StackLevel *) ckalloc((unsigned) - (tsdPtr->numLevels * 2 * sizeof(StackLevel))); + StackLevel *newLevels = (StackLevel *) + ckalloc((unsigned) (tsdPtr->numLevels*2*sizeof(StackLevel))); memcpy(newLevels, tsdPtr->levels, tsdPtr->numLevels * sizeof(StackLevel)); ckfree((char *) tsdPtr->levels); @@ -1398,7 +1395,7 @@ ExtendStacks( { register int count; register Element *elPtr; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (elPtr = arrayPtr->els, count = arrayPtr->numUsed; @@ -1431,7 +1428,7 @@ static void OptionThreadExitProc( ClientData clientData) /* not used */ { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->initialized) { @@ -1469,7 +1466,7 @@ OptionInit( { int i; Tcl_Interp *interp; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Element *defaultMatchPtr = &tsdPtr->defaultMatch; @@ -1505,7 +1502,7 @@ OptionInit( mainPtr->optionRootPtr = NewArray(20); interp = Tcl_CreateInterp(); - (void) GetDefaultOptions(interp, mainPtr->winPtr); + GetDefaultOptions(interp, mainPtr->winPtr); Tcl_DeleteInterp(interp); } |