diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-10-01 11:04:19 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-10-01 11:04:19 (GMT) |
commit | 03a3a2d78e1c26683170d32685d3f4d3b9ed902d (patch) | |
tree | b364c65de0a09b2125ba867a1ba14c257532d3d3 /generic | |
parent | 48e066711f2f019314605b45c4b136118d9c1b45 (diff) | |
download | tcl-03a3a2d78e1c26683170d32685d3f4d3b9ed902d.zip tcl-03a3a2d78e1c26683170d32685d3f4d3b9ed902d.tar.gz tcl-03a3a2d78e1c26683170d32685d3f4d3b9ed902d.tar.bz2 |
Eliminate a few gcc compiler warnings, when using -Wwrite-strings (tested with the brand-new gcc 5.2.0)
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCmdAH.c | 8 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 6 | ||||
-rw-r--r-- | generic/tclExecute.c | 30 | ||||
-rw-r--r-- | generic/tclLiteral.c | 11 | ||||
-rw-r--r-- | generic/tclObj.c | 42 | ||||
-rw-r--r-- | generic/tclTest.c | 6 |
6 files changed, 53 insertions, 50 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 7f0df83..5484002 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -25,7 +25,7 @@ static int EncodingDirsObjCmd(ClientData dummy, Tcl_Obj *const objv[]); static int GetStatBuf(Tcl_Interp *interp, Tcl_Obj *pathPtr, Tcl_FSStatProc *statProc, Tcl_StatBuf *statPtr); -static char * GetTypeFromMode(int mode); +static const char * GetTypeFromMode(int mode); static int StoreStatData(Tcl_Interp *interp, Tcl_Obj *varName, Tcl_StatBuf *statPtr); @@ -1289,7 +1289,7 @@ Tcl_FileObjCmd( return TCL_ERROR; } if (objc == 2) { - char *separator = NULL; /* lint */ + const char *separator = NULL; /* lint */ switch (tclPlatform) { case TCL_PLATFORM_UNIX: @@ -1554,7 +1554,7 @@ StoreStatData( *---------------------------------------------------------------------- */ -static char * +static const char * GetTypeFromMode( int mode) { @@ -1757,7 +1757,7 @@ Tcl_ForeachObjCmd( maxj = 0; for (i=0 ; i<numLists ; i++) { - + vCopyList[i] = TclListObjCopy(interp, objv[1+i*2]); if (vCopyList[i] == NULL) { result = TCL_ERROR; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 70943e9..30586b1 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -991,7 +991,8 @@ Tcl_SplitObjCmd( { Tcl_UniChar ch; int len; - char *splitChars, *stringPtr, *end; + const char *splitChars; + char *stringPtr, *end; int splitCharLen, stringLen; Tcl_Obj *listPtr, *objPtr; @@ -1069,7 +1070,8 @@ Tcl_SplitObjCmd( TclNewStringObj(objPtr, stringPtr, end - stringPtr); Tcl_ListObjAppendElement(NULL, listPtr, objPtr); } else { - char *element, *p, *splitEnd; + char *element; + const char *p, *splitEnd; int splitLen; Tcl_UniChar splitChar; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 553abed..248b1b3 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -822,12 +822,12 @@ TclFinalizeExecution(void) } /* - * Auxiliary code to insure that GrowEvaluationStack always returns correctly + * Auxiliary code to insure that GrowEvaluationStack always returns correctly * aligned memory. * * WALLOCALIGN represents the alignment reqs in words, just as TCL_ALLOCALIGN * represents the reqs in bytes. This assumes that TCL_ALLOCALIGN is a - * multiple of the wordsize 'sizeof(Tcl_Obj *)'. + * multiple of the wordsize 'sizeof(Tcl_Obj *)'. */ #define WALLOCALIGN \ @@ -849,7 +849,7 @@ wordSkip( } /* - * Given a marker, compute where the following aligned memory starts. + * Given a marker, compute where the following aligned memory starts. */ #define MEMSTART(markerPtr) \ @@ -902,13 +902,13 @@ GrowEvaluationStack( if (needed + offset < 0) { /* - * Put a marker pointing to the previous marker in this stack, and + * Put a marker pointing to the previous marker in this stack, and * store it in esPtr as the current marker. Return a pointer to * the start of aligned memory. */ esPtr->markerPtr = tmpMarkerPtr; - memStart = tmpMarkerPtr + offset; + memStart = tmpMarkerPtr + offset; esPtr->tosPtr = memStart - 1; *esPtr->markerPtr = (Tcl_Obj *) markerPtr; return memStart; @@ -982,7 +982,7 @@ GrowEvaluationStack( esPtr->markerPtr = &esPtr->stackWords[0]; memStart = MEMSTART(esPtr->markerPtr); esPtr->tosPtr = memStart - 1; - + if (move) { memcpy(memStart, MEMSTART(markerPtr), moveWords*sizeof(Tcl_Obj *)); esPtr->tosPtr += moveWords; @@ -1486,19 +1486,19 @@ TclCompEvalObj( * Note: Type BC => ctx.data.eval.path is not used. * ctx.data.tebc.codePtr used instead */ - + TclGetSrcInfoForPc(ctxPtr); if (ctxPtr->type == TCL_LOCATION_SOURCE) { /* * The reference made by 'TclGetSrcInfoForPc' is * dead. */ - + Tcl_DecrRefCount(ctxPtr->data.eval.path); ctxPtr->data.eval.path = NULL; } } - + if (word < ctxPtr->nline) { /* * Note: We do not care if the line[word] is -1. This @@ -1510,15 +1510,15 @@ TclCompEvalObj( * test info-32.0 using literal of info-24.8 * (dict with ... vs set body ...). */ - + redo = ((eclPtr->type == TCL_LOCATION_SOURCE) && (eclPtr->start != ctxPtr->line[word])) || ((eclPtr->type == TCL_LOCATION_BC) && (ctxPtr->type == TCL_LOCATION_SOURCE)); } - + TclStackFree(interp, ctxPtr); - + if (redo) { goto recompileObj; } @@ -1778,7 +1778,7 @@ TclExecuteByteCode( int traceInstructions = (tclTraceExec == 3); char cmdNameBuf[21]; #endif - char *curInstName = NULL; + const char *curInstName = NULL; /* * The execution uses a unified stack: first the catch stack, immediately @@ -5802,9 +5802,9 @@ TclExecuteByteCode( /* * We refuse to accept exponent arguments that exceed * one mp_digit which means the max exponent value is - * 2**28-1 = 0x0fffffff = 268435455, which fits into + * 2**28-1 = 0x0fffffff = 268435455, which fits into * a signed 32 bit int which is within the range of the - * long int type. This means any numeric Tcl_Obj value + * long int type. This means any numeric Tcl_Obj value * not using TCL_NUMBER_LONG type must hold a value larger * than we accept. */ diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 6a617b0..fb7c28a 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -153,7 +153,7 @@ TclDeleteLiteralTable( * Find, or if necessary create, an object in the interpreter's literal * table that has a string representation matching the argument * string. If nsPtr!=NULL then only literals stored for the namespace are - * considered. + * considered. * * Results: * The literal object. If it was created in this call *newPtr is set to @@ -161,7 +161,7 @@ TclDeleteLiteralTable( * * Side effects: * Increments the ref count of the global LiteralEntry since the caller - * now holds a reference. + * now holds a reference. * If LITERAL_ON_HEAP is set in flags, this function is given ownership * of the string: if an object is created then its string representation * is set directly from string, otherwise the string is freed. Typically, @@ -186,7 +186,7 @@ TclCreateLiteral( LiteralEntry *globalPtr; int globalHash; Tcl_Obj *objPtr; - + /* * Is it in the interpreter's global literal table? */ @@ -709,7 +709,7 @@ ExpandLocalLiteralArray( if (currArrayPtr != newArrayPtr) { for (i=0 ; i<currElems ; i++) { if (newArrayPtr[i].nextPtr != NULL) { - newArrayPtr[i].nextPtr = newArrayPtr + newArrayPtr[i].nextPtr = newArrayPtr + (newArrayPtr[i].nextPtr - currArrayPtr); } } @@ -882,7 +882,8 @@ RebuildLiteralTable( register LiteralEntry *entryPtr; LiteralEntry **bucketPtr; char *bytes; - int oldSize, count, index, length; + unsigned int oldSize; + int count, index, length; oldSize = tablePtr->numBuckets; oldBuckets = tablePtr->buckets; diff --git a/generic/tclObj.c b/generic/tclObj.c index d278b1f..230842a 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -569,7 +569,7 @@ TclContinuationsEnter(Tcl_Obj* objPtr, Tcl_HashEntry* hPtr = Tcl_CreateHashEntry (tsdPtr->lineCLPtr, (char*) objPtr, &newEntry); - ContLineLoc* clLocPtr = + ContLineLoc* clLocPtr = (ContLineLoc*) ckalloc (sizeof(ContLineLoc) + num*sizeof(int)); if (!newEntry) { @@ -675,7 +675,7 @@ TclContinuationsEnterDerived(Tcl_Obj* objPtr, int start, int* clNext) num = wordCLLast - clNext; if (num) { int i; - ContLineLoc* clLocPtr = + ContLineLoc* clLocPtr = TclContinuationsEnter(objPtr, num, clNext); /* @@ -1371,10 +1371,10 @@ TclFreeObj( */ objPtr->refCount = -1; - /* Invalidate the string rep first so we can use the bytes value + /* Invalidate the string rep first so we can use the bytes value * for our pointer chain, and signal an obj deletion (as opposed - * to shimmering) with 'length == -1' */ - + * to shimmering) with 'length == -1' */ + TclInvalidateStringRep(objPtr); objPtr->length = -1; @@ -1436,13 +1436,13 @@ void TclFreeObj( register Tcl_Obj *objPtr) /* The object to be freed. */ { - /* Invalidate the string rep first so we can use the bytes value + /* Invalidate the string rep first so we can use the bytes value * for our pointer chain, and signal an obj deletion (as opposed - * to shimmering) with 'length == -1' */ + * to shimmering) with 'length == -1' */ TclInvalidateStringRep(objPtr); objPtr->length = -1; - + if (!objPtr->typePtr || !objPtr->typePtr->freeIntRepProc) { /* * objPtr can be freed safely, as it will not attempt to free any @@ -2799,7 +2799,7 @@ Tcl_GetLongFromObj( tooLarge: #endif if (interp != NULL) { - char *s = "integer value too large to represent"; + const char *s = "integer value too large to represent"; Tcl_Obj *msg = Tcl_NewStringObj(s, -1); Tcl_SetObjResult(interp, msg); @@ -3098,7 +3098,7 @@ Tcl_GetWideIntFromObj( } } if (interp != NULL) { - char *s = "integer value too large to represent"; + const char *s = "integer value too large to represent"; Tcl_Obj* msg = Tcl_NewStringObj(s, -1); Tcl_SetObjResult(interp, msg); @@ -4084,7 +4084,7 @@ Tcl_GetCommandFromObj( * is not deleted. * * If any check fails, then force another conversion to the command type, - * to discard the old rep and create a new one. + * to discard the old rep and create a new one. */ resPtr = (ResolvedCmdName *) objPtr->internalRep.twoPtrValue.ptr1; @@ -4094,15 +4094,15 @@ Tcl_GetCommandFromObj( || (cmdPtr->flags & CMD_IS_DELETED) || (interp != cmdPtr->nsPtr->interp) || (cmdPtr->nsPtr->flags & NS_DYING) - || ((resPtr->refNsPtr != NULL) && + || ((resPtr->refNsPtr != NULL) && (((refNsPtr = (Namespace *) TclGetCurrentNamespace(interp)) != resPtr->refNsPtr) || (resPtr->refNsId != refNsPtr->nsId) || (resPtr->refNsCmdEpoch != refNsPtr->cmdRefEpoch))) ) { - + result = tclCmdNameType.setFromAnyProc(interp, objPtr); - + resPtr = (ResolvedCmdName *) objPtr->internalRep.twoPtrValue.ptr1; if ((result == TCL_OK) && resPtr) { cmdPtr = resPtr->cmdPtr; @@ -4110,7 +4110,7 @@ Tcl_GetCommandFromObj( cmdPtr = NULL; } } - + return (Tcl_Command) cmdPtr; } @@ -4162,7 +4162,7 @@ TclSetCmdNameObj( if ((*name++ == ':') && (*name == ':')) { /* * The name is fully qualified: set the referring namespace to - * NULL. + * NULL. */ resPtr->refNsPtr = NULL; @@ -4172,7 +4172,7 @@ TclSetCmdNameObj( */ currNsPtr = iPtr->varFramePtr->nsPtr; - + resPtr->refNsPtr = currNsPtr; resPtr->refNsId = currNsPtr->nsId; resPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; @@ -4332,7 +4332,7 @@ SetCmdNameFromAny( /* * Reuse the old ResolvedCmdName struct instead of freeing it */ - + Command *oldCmdPtr = resPtr->cmdPtr; if (--oldCmdPtr->refCount == 0) { TclCleanupCommandMacro(oldCmdPtr); @@ -4349,8 +4349,8 @@ SetCmdNameFromAny( resPtr->cmdEpoch = cmdPtr->cmdEpoch; if ((*name++ == ':') && (*name == ':')) { /* - * The name is fully qualified: set the referring namespace to - * NULL. + * The name is fully qualified: set the referring namespace to + * NULL. */ resPtr->refNsPtr = NULL; @@ -4360,7 +4360,7 @@ SetCmdNameFromAny( */ currNsPtr = iPtr->varFramePtr->nsPtr; - + resPtr->refNsPtr = currNsPtr; resPtr->refNsId = currNsPtr->nsId; resPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; diff --git a/generic/tclTest.c b/generic/tclTest.c index 5b51baa..1d92ff5 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -909,7 +909,7 @@ TestasyncCmd( static int AsyncHandlerProc( - ClientData clientData, /* If of TestAsyncHandler structure. + ClientData clientData, /* If of TestAsyncHandler structure. * in global list. */ Tcl_Interp *interp, /* Interpreter in which command was * executed, or NULL. */ @@ -3606,7 +3606,7 @@ PrintParse( Tcl_Parse *parsePtr) /* Parse structure to print out. */ { Tcl_Obj *objPtr; - char *typeString; + const char *typeString; Tcl_Token *tokenPtr; int i; @@ -6518,7 +6518,7 @@ TestGetIndexFromObjStructObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - char *ary[] = { + const char *ary[] = { "a", "b", "c", "d", "e", "f", NULL, NULL }; int idx,target; |