summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-03-05 14:34:03 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-03-05 14:34:03 (GMT)
commitb501910778714de837dc4367698256e996737e9b (patch)
treef2dc6d4861ea238a538f41c4306249dad1ac3ea5 /generic
parentf7a64b3a111891d5f7f79ce94bbb37abedd30176 (diff)
downloadtcl-b501910778714de837dc4367698256e996737e9b.zip
tcl-b501910778714de837dc4367698256e996737e9b.tar.gz
tcl-b501910778714de837dc4367698256e996737e9b.tar.bz2
Code Audit results:
* use do { ... } while (0) in macros * avoid shadowing one local variable with another * use clearer 'foo.bar++;' instead of '++foo.bar;' where result not required (i.e., semantically equivalent) * follow Engineering Manual rules on spacing and declarations
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c144
-rw-r--r--generic/tclBinary.c30
-rw-r--r--generic/tclClock.c19
-rw-r--r--generic/tclCmdAH.c3
-rw-r--r--generic/tclCmdIL.c9
-rw-r--r--generic/tclCmdMZ.c8
-rw-r--r--generic/tclCompCmds.c8
-rw-r--r--generic/tclCompCmdsSZ.c8
-rw-r--r--generic/tclCompExpr.c18
-rw-r--r--generic/tclCompile.c3
-rw-r--r--generic/tclDictObj.c4
-rw-r--r--generic/tclEnsemble.c28
-rw-r--r--generic/tclEnv.c5
-rw-r--r--generic/tclFileName.c9
-rw-r--r--generic/tclIORTrans.c19
-rw-r--r--generic/tclIOUtil.c4
-rw-r--r--generic/tclIndexObj.c83
-rw-r--r--generic/tclInt.h242
-rw-r--r--generic/tclInterp.c18
-rw-r--r--generic/tclLoad.c14
-rw-r--r--generic/tclNamesp.c13
-rw-r--r--generic/tclOO.c5
-rw-r--r--generic/tclParse.c6
-rw-r--r--generic/tclPathObj.c44
-rw-r--r--generic/tclProc.c12
-rw-r--r--generic/tclScan.c14
-rwxr-xr-xgeneric/tclStrToD.c36
-rw-r--r--generic/tclStringObj.c8
-rwxr-xr-xgeneric/tclThreadAlloc.c30
-rw-r--r--generic/tclUtil.c25
-rw-r--r--generic/tclVar.c19
-rw-r--r--generic/tclZlib.c65
32 files changed, 490 insertions, 463 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index fde9b1b..b9282ae 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.447 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.448 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -1310,6 +1310,7 @@ DeleteInterpProc(
Tcl_HashSearch search;
Tcl_HashTable *hTablePtr;
ResolverScheme *resPtr, *nextResPtr;
+ int i;
/*
* Punt if there is an error in the Tcl_Release/Tcl_Preserve matchup.
@@ -1503,89 +1504,87 @@ DeleteInterpProc(
* contents.
*/
- {
- Tcl_HashEntry *hPtr;
- Tcl_HashSearch hSearch;
- int i;
-
- for (hPtr = Tcl_FirstHashEntry(iPtr->linePBodyPtr, &hSearch);
- hPtr != NULL;
- hPtr = Tcl_NextHashEntry(&hSearch)) {
- CmdFrame *cfPtr = Tcl_GetHashValue(hPtr);
+ for (hPtr = Tcl_FirstHashEntry(iPtr->linePBodyPtr, &search);
+ hPtr != NULL;
+ hPtr = Tcl_NextHashEntry(&search)) {
+ CmdFrame *cfPtr = Tcl_GetHashValue(hPtr);
- if (cfPtr->type == TCL_LOCATION_SOURCE) {
- Tcl_DecrRefCount(cfPtr->data.eval.path);
- }
- ckfree((char *) cfPtr->line);
- ckfree((char *) cfPtr);
- Tcl_DeleteHashEntry(hPtr);
+ if (cfPtr->type == TCL_LOCATION_SOURCE) {
+ Tcl_DecrRefCount(cfPtr->data.eval.path);
}
- Tcl_DeleteHashTable(iPtr->linePBodyPtr);
- ckfree((char *) iPtr->linePBodyPtr);
- iPtr->linePBodyPtr = NULL;
+ ckfree((char *) cfPtr->line);
+ ckfree((char *) cfPtr);
+ Tcl_DeleteHashEntry(hPtr);
+ }
+ Tcl_DeleteHashTable(iPtr->linePBodyPtr);
+ ckfree((char *) iPtr->linePBodyPtr);
+ iPtr->linePBodyPtr = NULL;
- /*
- * See also tclCompile.c, TclCleanupByteCode
- */
+ /*
+ * See also tclCompile.c, TclCleanupByteCode
+ */
- for (hPtr = Tcl_FirstHashEntry(iPtr->lineBCPtr, &hSearch);
- hPtr != NULL;
- hPtr = Tcl_NextHashEntry(&hSearch)) {
- ExtCmdLoc *eclPtr = Tcl_GetHashValue(hPtr);
+ for (hPtr = Tcl_FirstHashEntry(iPtr->lineBCPtr, &search);
+ hPtr != NULL;
+ hPtr = Tcl_NextHashEntry(&search)) {
+ ExtCmdLoc *eclPtr = Tcl_GetHashValue(hPtr);
- if (eclPtr->type == TCL_LOCATION_SOURCE) {
- Tcl_DecrRefCount(eclPtr->path);
- }
- for (i=0; i< eclPtr->nuloc; i++) {
- ckfree((char *) eclPtr->loc[i].line);
- }
+ if (eclPtr->type == TCL_LOCATION_SOURCE) {
+ Tcl_DecrRefCount(eclPtr->path);
+ }
+ for (i=0; i< eclPtr->nuloc; i++) {
+ ckfree((char *) eclPtr->loc[i].line);
+ }
- if (eclPtr->loc != NULL) {
- ckfree((char *) eclPtr->loc);
- }
+ if (eclPtr->loc != NULL) {
+ ckfree((char *) eclPtr->loc);
+ }
- Tcl_DeleteHashTable(&eclPtr->litInfo);
+ Tcl_DeleteHashTable(&eclPtr->litInfo);
- ckfree((char *) eclPtr);
- Tcl_DeleteHashEntry(hPtr);
- }
- Tcl_DeleteHashTable(iPtr->lineBCPtr);
- ckfree((char *) iPtr->lineBCPtr);
- iPtr->lineBCPtr = NULL;
+ ckfree((char *) eclPtr);
+ Tcl_DeleteHashEntry(hPtr);
+ }
+ Tcl_DeleteHashTable(iPtr->lineBCPtr);
+ ckfree((char *) iPtr->lineBCPtr);
+ iPtr->lineBCPtr = NULL;
+
+ /*
+ * Location stack for uplevel/eval/... scripts which were passed through
+ * proc arguments. Actually we track all arguments as we do not and cannot
+ * know which arguments will be used as scripts and which will not.
+ */
+ if (iPtr->lineLAPtr->numEntries) {
/*
- * Location stack for uplevel/eval/... scripts which were passed
- * through proc arguments. Actually we track all arguments as we do
- * not and cannot know which arguments will be used as scripts and
- * which will not.
+ * When the interp goes away we have nothing on the stack, so there
+ * are no arguments, so this table has to be empty.
*/
- if (iPtr->lineLAPtr->numEntries) {
- /*
- * When the interp goes away we have nothing on the stack, so
- * there are no arguments, so this table has to be empty.
- */
+ Tcl_Panic("Argument location tracking table not empty");
+ }
- Tcl_Panic("Argument location tracking table not empty");
- }
+ Tcl_DeleteHashTable(iPtr->lineLAPtr);
+ ckfree((char *) iPtr->lineLAPtr);
+ iPtr->lineLAPtr = NULL;
- Tcl_DeleteHashTable(iPtr->lineLAPtr);
- ckfree((char *) iPtr->lineLAPtr);
- iPtr->lineLAPtr = NULL;
+ if (iPtr->lineLABCPtr->numEntries) {
+ /*
+ * When the interp goes away we have nothing on the stack, so there
+ * are no arguments, so this table has to be empty.
+ */
- if (iPtr->lineLABCPtr->numEntries) {
- /*
- * When the interp goes away we have nothing on the stack, so
- * there are no arguments, so this table has to be empty.
- */
+ Tcl_Panic("Argument location tracking table not empty");
+ }
- Tcl_Panic("Argument location tracking table not empty");
- }
+ Tcl_DeleteHashTable(iPtr->lineLABCPtr);
+ ckfree((char *) iPtr->lineLABCPtr);
+ iPtr->lineLABCPtr = NULL;
- Tcl_DeleteHashTable(iPtr->lineLABCPtr);
- ckfree((char *) iPtr->lineLABCPtr);
- iPtr->lineLABCPtr = NULL;
- }
+ /*
+ * Squelch the tables of traces on variables and searches over arrays in
+ * the in the interpreter.
+ */
Tcl_DeleteHashTable(&iPtr->varTraces);
Tcl_DeleteHashTable(&iPtr->varSearches);
@@ -7423,12 +7422,17 @@ ExprAbsFunc(
goto unChanged;
} else if (l == (long)0) {
const char *string = objv[1]->bytes;
+
if (!string) {
- /* There is no string representation, so internal one is correct */
+ /*
+ * There is no string representation, so internal one is
+ * correct.
+ */
+
goto unChanged;
}
while (isspace(UCHAR(*string))) {
- ++string;
+ string++;
}
if (*string != '-') {
goto unChanged;
@@ -7927,7 +7931,7 @@ MathFuncWrongNumArgs(
const char *tail = name + strlen(name);
while (tail > name+1) {
- --tail;
+ tail--;
if (*tail == ':' && tail[-1] == ':') {
name = tail+1;
break;
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 042cbed..62f8f46 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBinary.c,v 1.59 2009/12/29 01:43:23 patthoyts Exp $
+ * RCS: @(#) $Id: tclBinary.c,v 1.60 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -1303,7 +1303,6 @@ BinaryScanCmd(
case 'H': {
char *dest;
unsigned char *src;
- int i;
static const char hexdigit[] = "0123456789abcdef";
if (arg >= objc) {
@@ -2303,13 +2302,15 @@ BinaryDecodeHex(
value |= (c & 0xf);
} else {
value <<= 4;
- ++cut;
+ cut++;
}
}
*cursor++ = UCHAR(value);
value = 0;
}
- if (cut > size) cut = size;
+ if (cut > size) {
+ cut = size;
+ }
Tcl_SetByteArrayLength(resultObj, cursor - begin - cut);
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
@@ -2344,7 +2345,7 @@ BinaryDecodeHex(
#define OUTPUT(c) \
do { \
*cursor++ = (c); \
- ++outindex; \
+ outindex++; \
if (maxlen > 0 && cursor != limit) { \
if (outindex == maxlen) { \
memcpy(cursor, wrapchar, wrapcharlen); \
@@ -2505,10 +2506,12 @@ BinaryDecodeUu(
continue;
}
} else {
- ++cut;
+ cut++;
}
}
- if (cut>3) cut=3;
+ if (cut > 3) {
+ cut = 3;
+ }
*cursor++ = (((d[0] - 0x20) & 0x3f) << 2)
| (((d[1] - 0x20) & 0x3f) >> 4);
*cursor++ = (((d[1] - 0x20) & 0x3f) << 4)
@@ -2516,7 +2519,9 @@ BinaryDecodeUu(
*cursor++ = (((d[2] - 0x20) & 0x3f) << 6)
| (((d[3] - 0x20) & 0x3f));
}
- if (cut > size) cut = size;
+ if (cut > size) {
+ cut = size;
+ }
Tcl_SetByteArrayLength(resultObj, cursor - begin - cut);
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
@@ -2584,7 +2589,6 @@ BinaryDecode64(
size = ((count + 3) & ~3) * 3 / 4;
begin = cursor = Tcl_SetByteArrayLength(resultObj, size);
while (data < dataend) {
- int i;
unsigned long value = 0;
for (i=0 ; i<4 ; i++) {
@@ -2604,7 +2608,7 @@ BinaryDecode64(
} else if (c == '=') {
value <<= 6;
if (cut < 2) {
- ++cut;
+ cut++;
}
} else {
if (strict || !isspace(c)) {
@@ -2615,14 +2619,16 @@ BinaryDecode64(
}
} else {
value <<= 6;
- ++cut;
+ cut++;
}
}
*cursor++ = UCHAR((value >> 16) & 0xff);
*cursor++ = UCHAR((value >> 8) & 0xff);
*cursor++ = UCHAR(value & 0xff);
}
- if (cut > size) cut = size;
+ if (cut > size) {
+ cut = size;
+ }
Tcl_SetByteArrayLength(resultObj, cursor - begin - cut);
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 6c87db0..7519da8 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclClock.c,v 1.74 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclClock.c,v 1.75 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -796,8 +796,7 @@ ConvertLocalToUTCUsingTable(
if (nHave == 8) {
Tcl_Panic("loop in ConvertLocalToUTCUsingTable");
}
- have[nHave] = fields->tzOffset;
- ++nHave;
+ have[nHave++] = fields->tzOffset;
}
fields->seconds = fields->localSeconds - fields->tzOffset;
}
@@ -844,7 +843,7 @@ ConvertLocalToUTCUsingC(
secondOfDay = (int)(jsec % SECONDS_PER_DAY);
if (secondOfDay < 0) {
secondOfDay += SECONDS_PER_DAY;
- --fields->julianDay;
+ fields->julianDay--;
}
GetGregorianEraYearDay(fields, changeover);
GetMonthDay(fields);
@@ -1257,7 +1256,7 @@ GetGregorianEraYearDay(
day %= FOUR_CENTURIES;
if (day < 0) {
day += FOUR_CENTURIES;
- --n;
+ n--;
}
year += 400 * n;
@@ -1295,7 +1294,7 @@ GetGregorianEraYearDay(
day %= FOUR_YEARS;
if (day < 0) {
day += FOUR_YEARS;
- --n;
+ n--;
}
year += 4 * n;
@@ -1476,15 +1475,15 @@ GetJulianDayFromEraYearMonthDay(
ym1o4 = ym1 / 4;
if (ym1 % 4 < 0) {
- --ym1o4;
+ ym1o4--;
}
ym1o100 = ym1 / 100;
if (ym1 % 100 < 0) {
- --ym1o100;
+ ym1o100--;
}
ym1o400 = ym1 / 400;
if (ym1 % 400 < 0) {
- --ym1o400;
+ ym1o400--;
}
fields->julianDay = JDAY_1_JAN_1_CE_GREGORIAN - 1
+ fields->dayOfMonth
@@ -2022,7 +2021,7 @@ ClockDeleteCmdProc(
ClockClientData *data = clientData;
int i;
- --data->refCount;
+ data->refCount--;
if (data->refCount == 0) {
for (i = 0; i < LIT__END; ++i) {
Tcl_DecrRefCount(data->literals[i]);
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 4edfdec..6456bd5 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdAH.c,v 1.123 2009/12/28 12:55:48 dkf Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.124 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -1121,7 +1121,6 @@ Tcl_FileObjCmd(
}
case FCMD_LINK: {
Tcl_Obj *contents;
- int index;
if (objc < 3 || objc > 5) {
Tcl_WrongNumArgs(interp, 2, objv, "?-linktype? linkname ?target?");
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 85f9696..d063014 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdIL.c,v 1.179 2010/02/28 21:15:11 dkf Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.180 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -3610,7 +3610,7 @@ Tcl_LsortObjCmd(
sortInfo.isIncreasing = 1;
break;
case LSORT_INDEX: {
- Tcl_Obj **indices;
+ Tcl_Obj **indexv;
/* === START SPECIAL CASE ===
*
@@ -3634,7 +3634,7 @@ Tcl_LsortObjCmd(
*/
if (TclListObjGetElements(interp, objv[i+1], &sortInfo.indexc,
- &indices) != TCL_OK) {
+ &indexv) != TCL_OK) {
return TCL_ERROR;
}
/* === END SPECIAL CASE === */
@@ -3661,7 +3661,7 @@ Tcl_LsortObjCmd(
*/
for (j=0 ; j<sortInfo.indexc ; j++) {
- if (TclGetIntForIndexM(interp, indices[j], SORTIDX_END,
+ if (TclGetIntForIndexM(interp, indexv[j], SORTIDX_END,
&sortInfo.indexv[j]) != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (-index option item number %d)", j));
@@ -3922,7 +3922,6 @@ Tcl_LsortObjCmd(
if (sortInfo.resultCode == TCL_OK) {
List *listRepPtr;
Tcl_Obj **newArray, *objPtr;
- int i;
resultPtr = Tcl_NewListObj(sortInfo.numElements * groupSize, NULL);
listRepPtr = resultPtr->internalRep.twoPtrValue.ptr1;
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 84fbe1b..eb6bb7f 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.203 2010/03/02 08:47:35 dkf Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.204 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -2513,7 +2513,7 @@ StringEqualCmd(
if (i+1 >= objc-2) {
goto str_cmp_args;
}
- ++i;
+ i++;
if (TclGetIntFromObj(interp, objv[i], &reqlength) != TCL_OK) {
return TCL_ERROR;
}
@@ -2660,7 +2660,7 @@ StringCmpCmd(
if (i+1 >= objc-2) {
goto str_cmp_args;
}
- ++i;
+ i++;
if (TclGetIntFromObj(interp, objv[i], &reqlength) != TCL_OK) {
return TCL_ERROR;
}
@@ -3927,7 +3927,7 @@ TclNRSwitchObjCmd(
static int
SwitchPostProc(
ClientData data[], /* Data passed from Tcl_NRAddCallback above */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int result) /* Result to return*/
{
/* Unpack the preserved data */
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 3a564ff..e96c196 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmds.c,v 1.167 2010/02/26 14:38:36 dkf Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.168 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -4028,9 +4028,9 @@ PushVarName(
*/
if (varTokenPtr[n].size == 1) {
- --n;
+ n--;
} else {
- --varTokenPtr[n].size;
+ varTokenPtr[n].size--;
removedParen = n;
}
@@ -4131,7 +4131,7 @@ PushVarName(
}
if (removedParen) {
- ++varTokenPtr[removedParen].size;
+ varTokenPtr[removedParen].size++;
}
if (allocedTokens) {
TclStackFree(interp, elemTokenPtr);
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 88954ed..fb34f66 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmdsSZ.c,v 1.1 2010/02/26 14:38:36 dkf Exp $
+ * RCS: @(#) $Id: tclCompCmdsSZ.c,v 1.2 2010/03/05 14:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -2790,9 +2790,9 @@ PushVarName(
*/
if (varTokenPtr[n].size == 1) {
- --n;
+ n--;
} else {
- --varTokenPtr[n].size;
+ varTokenPtr[n].size--;
removedParen = n;
}
@@ -2893,7 +2893,7 @@ PushVarName(
}
if (removedParen) {
- ++varTokenPtr[removedParen].size;
+ varTokenPtr[removedParen].size++;
}
if (allocedTokens) {
TclStackFree(interp, elemTokenPtr);
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 0b06d15..8bfd116 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompExpr.c,v 1.103 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.104 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1477,7 +1477,7 @@ ConvertTreeToTokens(
/* Skip any white space that comes before the literal */
scanned = TclParseAllWhiteSpace(start, numBytes);
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
/*
@@ -1498,7 +1498,7 @@ ConvertTreeToTokens(
subExprTokenPtr[1].numComponents = 0;
parsePtr->numTokens += 2;
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
break;
@@ -1550,7 +1550,7 @@ ConvertTreeToTokens(
}
scanned = tokenPtr->start + tokenPtr->size - start;
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
tokenPtr += toCopy;
break;
@@ -1566,7 +1566,7 @@ ConvertTreeToTokens(
*/
scanned = TclParseAllWhiteSpace(start, numBytes);
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
/*
@@ -1641,7 +1641,7 @@ ConvertTreeToTokens(
/* Skip any white space that comes before the operator */
scanned = TclParseAllWhiteSpace(start, numBytes);
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
/*
@@ -1672,7 +1672,7 @@ ConvertTreeToTokens(
break;
}
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
break;
@@ -1693,10 +1693,10 @@ ConvertTreeToTokens(
/* Skip past matching close paren. */
scanned = TclParseAllWhiteSpace(start, numBytes);
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
scanned = ParseLexeme(start, numBytes, &lexeme, NULL);
- start +=scanned;
+ start += scanned;
numBytes -= scanned;
break;
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 9552b64..d788d43 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.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: tclCompile.c,v 1.183 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.184 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -861,7 +861,6 @@ TclCleanupByteCode(
if (hePtr) {
ExtCmdLoc *eclPtr = Tcl_GetHashValue(hePtr);
- int i;
if (eclPtr->type == TCL_LOCATION_SOURCE) {
Tcl_DecrRefCount(eclPtr->path);
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index 2751b4a..e0aea5b 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclDictObj.c,v 1.81 2010/02/24 14:30:34 dkf Exp $
+ * RCS: @(#) $Id: tclDictObj.c,v 1.82 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -405,7 +405,7 @@ FreeDictInternalRep(
{
Dict *dict = dictPtr->internalRep.otherValuePtr;
- --dict->refcount;
+ dict->refcount--;
if (dict->refcount <= 0) {
DeleteDict(dict);
}
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index bc92251..c4750c5 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEnsemble.c,v 1.4 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclEnsemble.c,v 1.5 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -204,14 +204,14 @@ TclNamespaceEnsembleCmd(
paramObj = (len > 0 ? objv[1] : NULL);
continue;
case CRT_MAP: {
- Tcl_Obj *patchedDict = NULL, *subcmdObj;
+ Tcl_Obj *patchedDict = NULL, *subcmdWordsObj;
/*
* Verify that the map is sensible.
*/
if (Tcl_DictObjFirst(interp, objv[1], &search,
- &subcmdObj, &listObj, &done) != TCL_OK) {
+ &subcmdWordsObj, &listObj, &done) != TCL_OK) {
if (allocatedMapFlag) {
Tcl_DecrRefCount(mapObj);
}
@@ -262,9 +262,10 @@ TclNamespaceEnsembleCmd(
if (patchedDict == NULL) {
patchedDict = Tcl_DuplicateObj(objv[1]);
}
- Tcl_DictObjPut(NULL, patchedDict, subcmdObj, newList);
+ Tcl_DictObjPut(NULL, patchedDict, subcmdWordsObj,
+ newList);
}
- Tcl_DictObjNext(&search, &subcmdObj, &listObj, &done);
+ Tcl_DictObjNext(&search, &subcmdWordsObj,&listObj, &done);
} while (!done);
if (allocatedMapFlag) {
@@ -491,7 +492,7 @@ TclNamespaceEnsembleCmd(
paramObj = (len > 0 ? objv[1] : NULL);
continue;
case CONF_MAP: {
- Tcl_Obj *patchedDict = NULL, *subcmdObj, **listv;
+ Tcl_Obj *patchedDict = NULL, *subcmdWordsObj, **listv;
const char *cmd;
/*
@@ -499,7 +500,7 @@ TclNamespaceEnsembleCmd(
*/
if (Tcl_DictObjFirst(interp, objv[1], &search,
- &subcmdObj, &listObj, &done) != TCL_OK) {
+ &subcmdWordsObj, &listObj, &done) != TCL_OK) {
goto freeMapAndError;
}
if (done) {
@@ -539,10 +540,11 @@ TclNamespaceEnsembleCmd(
if (patchedDict == NULL) {
patchedDict = Tcl_DuplicateObj(objv[1]);
}
- Tcl_DictObjPut(NULL, patchedDict, subcmdObj,
+ Tcl_DictObjPut(NULL, patchedDict, subcmdWordsObj,
newList);
}
- Tcl_DictObjNext(&search, &subcmdObj, &listObj, &done);
+ Tcl_DictObjNext(&search, &subcmdWordsObj, &listObj,
+ &done);
} while (!done);
if (allocatedMapFlag) {
Tcl_DecrRefCount(mapObj);
@@ -865,14 +867,14 @@ Tcl_SetEnsembleMappingDict(
for (Tcl_DictObjFirst(NULL, mapDict, &search, NULL, &valuePtr, &done);
!done; Tcl_DictObjNext(&search, NULL, &valuePtr, &done)) {
- Tcl_Obj *cmdPtr;
+ Tcl_Obj *cmdObjPtr;
const char *bytes;
- if (Tcl_ListObjIndex(interp, valuePtr, 0, &cmdPtr) != TCL_OK) {
+ if (Tcl_ListObjIndex(interp, valuePtr, 0, &cmdObjPtr) != TCL_OK) {
Tcl_DictObjDone(&search);
return TCL_ERROR;
}
- bytes = TclGetString(cmdPtr);
+ bytes = TclGetString(cmdObjPtr);
if (bytes[0] != ':' || bytes[1] != ':') {
Tcl_AppendResult(interp,
"ensemble target is not a fully-qualified command",
@@ -2311,8 +2313,6 @@ BuildEnsembleConfig(
* Remove pre-existing table.
*/
- Tcl_HashSearch search;
-
ckfree((char *) ensemblePtr->subcommandArrayPtr);
hPtr = Tcl_FirstHashEntry(hash, &search);
while (hPtr != NULL) {
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index f89ca41..87fb3d7 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEnv.c,v 1.41 2010/01/13 06:46:56 nijtmans Exp $
+ * RCS: @(#) $Id: tclEnv.c,v 1.42 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -722,8 +722,7 @@ TclCygwinPutenv(
/* Can't happen. */
return;
}
- *value = '\0';
- ++value;
+ *(value++) = '\0';
if (*value == '\0') {
value = NULL;
}
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index 8e67238..28c0ab8 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclFileName.c,v 1.101 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclFileName.c,v 1.102 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -421,7 +421,7 @@ TclpGetNativePathType(
&& (path[1] == '/') && isdigit(UCHAR(path[2]))) {
path += 3;
while (isdigit(UCHAR(*path))) {
- ++path;
+ path++;
}
}
#endif
@@ -647,11 +647,12 @@ SplitUnixPath(
/*
* Check for QNX //<node id> prefix
*/
+
if ((path[0] == '/') && (path[1] == '/')
&& isdigit(UCHAR(path[2]))) { /* INTL: digit */
path += 3;
while (isdigit(UCHAR(*path))) { /* INTL: digit */
- ++path;
+ path++;
}
}
#endif
@@ -1823,7 +1824,7 @@ TclGlob(
if (tail[0] == '/') {
tail++;
} else {
- tail+=2;
+ tail += 2;
}
Tcl_IncrRefCount(pathPrefix);
break;
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index a6e7ed5..dcad087 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIORTrans.c,v 1.12 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclIORTrans.c,v 1.13 2010/03/05 14:34:04 dkf Exp $
*/
#include <tclInt.h>
@@ -1058,7 +1058,7 @@ ReflectInput(
int *errorCodePtr)
{
ReflectedTransform *rtPtr = clientData;
- int gotBytes, copied, read;
+ int gotBytes, copied, readBytes;
/*
* The following check can be done before thread redirection, because we
@@ -1124,8 +1124,8 @@ ReflectInput(
return gotBytes;
}
- read = Tcl_ReadRaw(rtPtr->parent, buf, toRead);
- if (read < 0) {
+ readBytes = Tcl_ReadRaw(rtPtr->parent, buf, toRead);
+ if (readBytes < 0) {
/*
* Report errors to caller. The state of the seek system is
* unchanged!
@@ -1144,7 +1144,7 @@ ReflectInput(
return -1;
}
- if (read == 0) {
+ if (readBytes == 0) {
/*
* Check wether we hit on EOF in 'parent' or not. If not
* differentiate between blocking and non-blocking modes. In
@@ -1200,7 +1200,7 @@ ReflectInput(
((Channel *) rtPtr->parent)->state->flags &= ~CHANNEL_EOF;
continue; /* at: while (toRead > 0) */
}
- } /* read == 0 */
+ } /* readBytes == 0 */
/*
* Transform the read chunk, which was not empty. Anything we got back
@@ -1208,7 +1208,7 @@ ReflectInput(
* iteration will put it into the result.
*/
- if (!TransformRead(rtPtr, errorCodePtr, UCHARP(buf), read)) {
+ if (!TransformRead(rtPtr, errorCodePtr, UCHARP(buf), readBytes)) {
return -1;
}
} /* while toRead > 0 */
@@ -2656,9 +2656,7 @@ ForwardProc(
break;
}
- case ForwardedLimit: {
- Tcl_Obj *resObj;
-
+ case ForwardedLimit:
if (InvokeTclMethod(rtPtr, "limit?", NULL, NULL, &resObj) != TCL_OK) {
ForwardSetObjError(paramPtr, resObj);
paramPtr->limit.max = -1;
@@ -2670,7 +2668,6 @@ ForwardProc(
Tcl_DecrRefCount(resObj);
break;
- }
default:
/*
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index a22e664..23e864b 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.168 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.169 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1511,7 +1511,7 @@ TclGetOpenModeEx(
default:
goto error;
}
- i=1;
+ i = 1;
while (i<3 && modeString[i]) {
if (modeString[i] == modeString[i-1]) {
goto error;
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index c732cec..edb05d7 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIndexObj.c,v 1.57 2010/03/01 23:19:36 ferrieux Exp $
+ * RCS: @(#) $Id: tclIndexObj.c,v 1.58 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -46,11 +46,11 @@ static void PrintUsage(Tcl_Interp *interp,
*/
static const Tcl_ObjType indexType = {
- "index", /* name */
- FreeIndex, /* freeIntRepProc */
- DupIndex, /* dupIntRepProc */
- UpdateStringOfIndex, /* updateStringProc */
- SetIndexFromAny /* setFromAnyProc */
+ "index", /* name */
+ FreeIndex, /* freeIntRepProc */
+ DupIndex, /* dupIntRepProc */
+ UpdateStringOfIndex, /* updateStringProc */
+ SetIndexFromAny /* setFromAnyProc */
};
/*
@@ -145,23 +145,22 @@ Tcl_GetIndexFromObj(
*
* GetIndexFromObjList --
*
- * This procedure looks up an object's value in a table of strings
- * and returns the index of the matching string, if any.
+ * This procedure looks up an object's value in a table of strings and
+ * returns the index of the matching string, if any.
*
* Results:
- * If the value of objPtr is identical to or a unique abbreviation
- * for one of the entries in tableObjPtr, then the return value is
- * TCL_OK and the index of the matching entry is stored at
- * *indexPtr. If there isn't a proper match, then TCL_ERROR is
- * returned and an error message is left in interp's result (unless
- * interp is NULL). The msg argument is used in the error
- * message; for example, if msg has the value "option" then the
- * error message will say something flag 'bad option "foo": must be
- * ...'
+ * If the value of objPtr is identical to or a unique abbreviation for
+ * one of the entries in tableObjPtr, then the return value is TCL_OK and
+ * the index of the matching entry is stored at *indexPtr. If there isn't
+ * a proper match, then TCL_ERROR is returned and an error message is
+ * left in interp's result (unless interp is NULL). The msg argument is
+ * used in the error message; for example, if msg has the value "option"
+ * then the error message will say something flag 'bad option "foo": must
+ * be ...'
*
* Side effects:
- * The result of the lookup is cached as the internal rep of
- * objPtr, so that repeated lookups can be done quickly.
+ * Removes any internal representation that the object might have. (TODO:
+ * find a way to cache the lookup.)
*
*----------------------------------------------------------------------
*/
@@ -183,8 +182,8 @@ GetIndexFromObjList(
const char **tablePtr;
/*
- * Use Tcl_GetIndexFromObjStruct to do the work to avoid duplicating
- * most of the code there. This is a bit ineffiecient but simpler.
+ * Use Tcl_GetIndexFromObjStruct to do the work to avoid duplicating most
+ * of the code there. This is a bit ineffiecient but simpler.
*/
result = Tcl_ListObjGetElements(interp, tableObjPtr, &objc, &objv);
@@ -237,13 +236,13 @@ GetIndexFromObjList(
*
* Results:
* If the value of objPtr is identical to or a unique abbreviation for
- * one of the entries in tablePtr, then the return value is TCL_OK and the
- * index of the matching entry is stored at *indexPtr. If there isn't a
- * proper match, then TCL_ERROR is returned and an error message is left
- * in interp's result (unless interp is NULL). The msg argument is used
- * in the error message; for example, if msg has the value "option" then
- * the error message will say something flag 'bad option "foo": must be
- * ...'
+ * one of the entries in tablePtr, then the return value is TCL_OK and
+ * the index of the matching entry is stored at *indexPtr. If there isn't
+ * a proper match, then TCL_ERROR is returned and an error message is
+ * left in interp's result (unless interp is NULL). The msg argument is
+ * used in the error message; for example, if msg has the value "option"
+ * then the error message will say something flag 'bad option "foo": must
+ * be ...'
*
* Side effects:
* The result of the lookup is cached as the internal rep of objPtr, so
@@ -348,8 +347,8 @@ Tcl_GetIndexFromObjStruct(
objPtr->typePtr = &indexType;
}
indexRep->tablePtr = (void *) tablePtr;
- indexRep->offset = offset;
- indexRep->index = index;
+ indexRep->offset = offset;
+ indexRep->index = index;
*indexPtr = index;
return TCL_OK;
@@ -364,18 +363,20 @@ Tcl_GetIndexFromObjStruct(
TclNewObj(resultPtr);
Tcl_SetObjResult(interp, resultPtr);
- Tcl_AppendStringsToObj(resultPtr, (numAbbrev > 1) &&
- !(flags & TCL_EXACT) ? "ambiguous " : "bad ", msg, " \"", key, NULL);
+ Tcl_AppendStringsToObj(resultPtr,
+ (numAbbrev>1 && !(flags & TCL_EXACT) ? "ambiguous " : "bad "),
+ msg, " \"", key, NULL);
if (STRING_AT(tablePtr, offset, 0) == NULL) {
Tcl_AppendStringsToObj(resultPtr, "\": no valid options", NULL);
} else {
- Tcl_AppendStringsToObj(resultPtr, "\": must be ", STRING_AT(tablePtr, offset, 0), NULL);
+ Tcl_AppendStringsToObj(resultPtr, "\": must be ",
+ STRING_AT(tablePtr, offset, 0), NULL);
for (entryPtr = NEXT_ENTRY(tablePtr, offset), count = 0;
- *entryPtr != NULL;
- entryPtr = NEXT_ENTRY(entryPtr, offset), count++) {
+ *entryPtr != NULL;
+ entryPtr = NEXT_ENTRY(entryPtr, offset), count++) {
if (*NEXT_ENTRY(entryPtr, offset) == NULL) {
- Tcl_AppendStringsToObj(resultPtr, ((count > 0) ? "," : ""),
- " or ", *entryPtr, NULL);
+ Tcl_AppendStringsToObj(resultPtr, (count > 0 ? "," : ""),
+ " or ", *entryPtr, NULL);
} else {
Tcl_AppendStringsToObj(resultPtr, ", ", *entryPtr, NULL);
}
@@ -1232,7 +1233,7 @@ Tcl_ParseArgsObjv(
(double *) infoPtr->dstPtr) == TCL_ERROR) {
Tcl_AppendResult(interp, "expected floating-point argument ",
"for \"", infoPtr->keyStr, "\" but got \"",
- Tcl_GetString((Tcl_Obj *) objv[srcIndex]),"\"", NULL);
+ Tcl_GetString(objv[srcIndex]), "\"", NULL);
goto error;
}
srcIndex++;
@@ -1285,7 +1286,7 @@ Tcl_ParseArgsObjv(
*/
argsDone:
- if (remObjv==NULL) {
+ if (remObjv == NULL) {
/*
* Nothing to do.
*/
@@ -1295,9 +1296,9 @@ Tcl_ParseArgsObjv(
if (objc > 0) {
leftovers = (Tcl_Obj **) ckrealloc((void *) leftovers,
- (nrem+objc+1) * sizeof(Tcl_Obj*));
+ (nrem+objc+1) * sizeof(Tcl_Obj *));
while (objc) {
- leftovers[nrem]=objv[srcIndex];
+ leftovers[nrem] = objv[srcIndex];
nrem++;
srcIndex++;
objc--;
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 9c9a073..4bdb3c7 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.463 2010/02/16 21:34:30 nijtmans Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.464 2010/03/05 14:34:04 dkf Exp $
*/
#ifndef _TCLINT
@@ -2781,7 +2781,8 @@ typedef struct ForIterData {
MODULE_SCOPE int TclNREvalCmd(Tcl_Interp *interp, Tcl_Obj *objPtr,
int flags);
MODULE_SCOPE void TclPushTailcallPoint(Tcl_Interp *interp);
-MODULE_SCOPE void TclAdvanceContinuations(int *line, int **next, int loc);
+MODULE_SCOPE void TclAdvanceContinuations(int *line, int **next,
+ int loc);
MODULE_SCOPE void TclAdvanceLines(int *line, const char *start,
const char *end);
MODULE_SCOPE void TclArgumentEnter(Tcl_Interp *interp,
@@ -2802,18 +2803,19 @@ MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string,
int strLen, const unsigned char *pattern,
int ptnLen, int flags);
MODULE_SCOPE double TclCeil(mp_int *a);
-MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp, const char *value);
+MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp,
+ const char *value);
MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp,
Tcl_Channel chan);
MODULE_SCOPE int TclClearRootEnsemble(ClientData data[],
Tcl_Interp *interp, int result);
MODULE_SCOPE void TclCleanupLiteralTable(Tcl_Interp *interp,
LiteralTable *tablePtr);
-MODULE_SCOPE ContLineLoc* TclContinuationsEnter(Tcl_Obj *objPtr, int num,
+MODULE_SCOPE ContLineLoc *TclContinuationsEnter(Tcl_Obj *objPtr, int num,
int *loc);
MODULE_SCOPE void TclContinuationsEnterDerived(Tcl_Obj *objPtr,
int start, int *clNext);
-MODULE_SCOPE ContLineLoc* TclContinuationsGet(Tcl_Obj *objPtr);
+MODULE_SCOPE ContLineLoc *TclContinuationsGet(Tcl_Obj *objPtr);
MODULE_SCOPE void TclContinuationsCopy(Tcl_Obj *objPtr,
Tcl_Obj *originObjPtr);
MODULE_SCOPE int TclDoubleDigits(char *buf, double value, int *signum);
@@ -2937,7 +2939,7 @@ MODULE_SCOPE int TclMarkList(Tcl_Interp *interp, const char *list,
MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[], Tcl_Obj **optionsPtrPtr,
int *codePtr, int *levelPtr);
-MODULE_SCOPE int TclNokia770Doubles();
+MODULE_SCOPE int TclNokia770Doubles(void);
MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr);
MODULE_SCOPE void TclObjVarErrMsg(Tcl_Interp *interp, Tcl_Obj *part1Ptr,
Tcl_Obj *part2Ptr, const char *operation,
@@ -3847,21 +3849,25 @@ MODULE_SCOPE void TclpFreeAllocCache(void *);
MODULE_SCOPE Tcl_Mutex tclObjMutex;
#endif
-# define TclAllocObjStorageEx(interp, objPtr) \
- Tcl_MutexLock(&tclObjMutex); \
- if (tclFreeObjList == NULL) { \
- TclAllocateFreeObjects(); \
- } \
- (objPtr) = tclFreeObjList; \
- tclFreeObjList = (Tcl_Obj *) \
- tclFreeObjList->internalRep.otherValuePtr; \
- Tcl_MutexUnlock(&tclObjMutex)
+# define TclAllocObjStorageEx(interp, objPtr) \
+ do { \
+ Tcl_MutexLock(&tclObjMutex); \
+ if (tclFreeObjList == NULL) { \
+ TclAllocateFreeObjects(); \
+ } \
+ (objPtr) = tclFreeObjList; \
+ tclFreeObjList = (Tcl_Obj *) \
+ tclFreeObjList->internalRep.otherValuePtr; \
+ Tcl_MutexUnlock(&tclObjMutex); \
+ } while (0)
-# define TclFreeObjStorageEx(interp, objPtr) \
- Tcl_MutexLock(&tclObjMutex); \
+# define TclFreeObjStorageEx(interp, objPtr) \
+ do { \
+ Tcl_MutexLock(&tclObjMutex); \
(objPtr)->internalRep.otherValuePtr = (void *) tclFreeObjList; \
- tclFreeObjList = (objPtr); \
- Tcl_MutexUnlock(&tclObjMutex)
+ tclFreeObjList = (objPtr); \
+ Tcl_MutexUnlock(&tclObjMutex); \
+ } while (0)
#endif
#else /* TCL_MEM_DEBUG */
@@ -3869,10 +3875,13 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
int line);
# define TclDbNewObj(objPtr, file, line) \
- TclIncrObjsAllocated(); \
- (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
- TclDbInitNewObj((objPtr), (file), (line)); \
- TCL_DTRACE_OBJ_CREATE(objPtr)
+ do { \
+ TclIncrObjsAllocated(); \
+ (objPtr) = (Tcl_Obj *) \
+ Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
+ TclDbInitNewObj((objPtr), (file), (line)); \
+ TCL_DTRACE_OBJ_CREATE(objPtr); \
+ } while (0)
# define TclNewObj(objPtr) \
TclDbNewObj(objPtr, __FILE__, __LINE__);
@@ -3983,40 +3992,40 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
#define TCL_MAX_TOKENS (int)(UINT_MAX / sizeof(Tcl_Token))
#define TCL_MIN_TOKEN_GROWTH 50
#define TclGrowTokenArray(tokenPtr, used, available, append, staticPtr) \
-{ \
- int needed = (used) + (append); \
- if (needed > TCL_MAX_TOKENS) { \
- Tcl_Panic("max # of tokens for a Tcl parse (%d) exceeded", \
- TCL_MAX_TOKENS); \
- } \
- if (needed > (available)) { \
- int allocated = 2 * needed; \
- Tcl_Token *oldPtr = (tokenPtr); \
- Tcl_Token *newPtr; \
- if (oldPtr == (staticPtr)) { \
- oldPtr = NULL; \
- } \
- if (allocated > TCL_MAX_TOKENS) { \
- allocated = TCL_MAX_TOKENS; \
+ do { \
+ int needed = (used) + (append); \
+ if (needed > TCL_MAX_TOKENS) { \
+ Tcl_Panic("max # of tokens for a Tcl parse (%d) exceeded", \
+ TCL_MAX_TOKENS); \
} \
- newPtr = (Tcl_Token *) attemptckrealloc((char *) oldPtr, \
- (unsigned int) (allocated * sizeof(Tcl_Token))); \
- if (newPtr == NULL) { \
- allocated = needed + (append) + TCL_MIN_TOKEN_GROWTH; \
+ if (needed > (available)) { \
+ int allocated = 2 * needed; \
+ Tcl_Token *oldPtr = (tokenPtr); \
+ Tcl_Token *newPtr; \
+ if (oldPtr == (staticPtr)) { \
+ oldPtr = NULL; \
+ } \
if (allocated > TCL_MAX_TOKENS) { \
allocated = TCL_MAX_TOKENS; \
} \
- newPtr = (Tcl_Token *) ckrealloc((char *) oldPtr, \
+ newPtr = (Tcl_Token *) attemptckrealloc((char *) oldPtr, \
(unsigned int) (allocated * sizeof(Tcl_Token))); \
+ if (newPtr == NULL) { \
+ allocated = needed + (append) + TCL_MIN_TOKEN_GROWTH; \
+ if (allocated > TCL_MAX_TOKENS) { \
+ allocated = TCL_MAX_TOKENS; \
+ } \
+ newPtr = (Tcl_Token *) ckrealloc((char *) oldPtr, \
+ (unsigned int) (allocated * sizeof(Tcl_Token))); \
+ } \
+ (available) = allocated; \
+ if (oldPtr == NULL) { \
+ memcpy(newPtr, staticPtr, \
+ (size_t) ((used) * sizeof(Tcl_Token))); \
+ } \
+ (tokenPtr) = newPtr; \
} \
- (available) = allocated; \
- if (oldPtr == NULL) { \
- memcpy(newPtr, staticPtr, \
- (size_t) ((used) * sizeof(Tcl_Token))); \
- } \
- (tokenPtr) = newPtr; \
- } \
-}
+ } while (0)
#define TclGrowParseTokenArray(parsePtr, append) \
TclGrowTokenArray((parsePtr)->tokenPtr, (parsePtr)->numTokens, \
@@ -4110,8 +4119,8 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
*/
#define TclInvalidateNsCmdLookup(nsPtr) \
- if ((nsPtr)->numExportPatterns) { \
- (nsPtr)->exportLookupEpoch++; \
+ if ((nsPtr)->numExportPatterns) { \
+ (nsPtr)->exportLookupEpoch++; \
}
/*
@@ -4154,7 +4163,8 @@ MODULE_SCOPE int Procbodytest_SafeInit(Tcl_Interp *interp);
*----------------------------------------------------------------
*/
-#define TclMatchIsTrivial(pattern) strpbrk((pattern), "*[?\\") == NULL
+#define TclMatchIsTrivial(pattern) \
+ (strpbrk((pattern), "*[?\\") == NULL)
/*
*----------------------------------------------------------------
@@ -4165,7 +4175,8 @@ MODULE_SCOPE int Procbodytest_SafeInit(Tcl_Interp *interp);
*----------------------------------------------------------------
*/
-#define TclFormatInt(buf, n) sprintf((buf), "%ld", (long)(n))
+#define TclFormatInt(buf, n) \
+ sprintf((buf), "%ld", (long)(n))
/*
*----------------------------------------------------------------
@@ -4183,10 +4194,12 @@ MODULE_SCOPE int Procbodytest_SafeInit(Tcl_Interp *interp);
*/
#define TclSetIntObj(objPtr, i) \
- TclInvalidateStringRep(objPtr);\
- TclFreeIntRep(objPtr); \
- (objPtr)->internalRep.longValue = (long)(i); \
- (objPtr)->typePtr = &tclIntType
+ do { \
+ TclInvalidateStringRep(objPtr); \
+ TclFreeIntRep(objPtr); \
+ (objPtr)->internalRep.longValue = (long)(i); \
+ (objPtr)->typePtr = &tclIntType; \
+ } while (0)
#define TclSetLongObj(objPtr, l) \
TclSetIntObj((objPtr), (l))
@@ -4203,17 +4216,21 @@ MODULE_SCOPE int Procbodytest_SafeInit(Tcl_Interp *interp);
#ifndef NO_WIDE_TYPE
#define TclSetWideIntObj(objPtr, w) \
- TclInvalidateStringRep(objPtr);\
- TclFreeIntRep(objPtr); \
- (objPtr)->internalRep.wideValue = (Tcl_WideInt)(w); \
- (objPtr)->typePtr = &tclWideIntType
+ do { \
+ TclInvalidateStringRep(objPtr); \
+ TclFreeIntRep(objPtr); \
+ (objPtr)->internalRep.wideValue = (Tcl_WideInt)(w); \
+ (objPtr)->typePtr = &tclWideIntType; \
+ } while (0)
#endif
#define TclSetDoubleObj(objPtr, d) \
- TclInvalidateStringRep(objPtr);\
- TclFreeIntRep(objPtr); \
- (objPtr)->internalRep.doubleValue = (double)(d); \
- (objPtr)->typePtr = &tclDoubleType
+ do { \
+ TclInvalidateStringRep(objPtr); \
+ TclFreeIntRep(objPtr); \
+ (objPtr)->internalRep.doubleValue = (double)(d); \
+ (objPtr)->typePtr = &tclDoubleType; \
+ } while (0)
/*
*----------------------------------------------------------------
@@ -4234,13 +4251,15 @@ MODULE_SCOPE int Procbodytest_SafeInit(Tcl_Interp *interp);
#ifndef TCL_MEM_DEBUG
#define TclNewIntObj(objPtr, i) \
- TclIncrObjsAllocated(); \
- TclAllocObjStorage(objPtr); \
- (objPtr)->refCount = 0; \
- (objPtr)->bytes = NULL; \
- (objPtr)->internalRep.longValue = (long)(i); \
- (objPtr)->typePtr = &tclIntType; \
- TCL_DTRACE_OBJ_CREATE(objPtr)
+ do { \
+ TclIncrObjsAllocated(); \
+ TclAllocObjStorage(objPtr); \
+ (objPtr)->refCount = 0; \
+ (objPtr)->bytes = NULL; \
+ (objPtr)->internalRep.longValue = (long)(i); \
+ (objPtr)->typePtr = &tclIntType; \
+ TCL_DTRACE_OBJ_CREATE(objPtr); \
+ } while (0)
#define TclNewLongObj(objPtr, l) \
TclNewIntObj((objPtr), (l))
@@ -4253,21 +4272,25 @@ MODULE_SCOPE int Procbodytest_SafeInit(Tcl_Interp *interp);
TclNewIntObj((objPtr), ((b)? 1 : 0))
#define TclNewDoubleObj(objPtr, d) \
- TclIncrObjsAllocated(); \
- TclAllocObjStorage(objPtr); \
- (objPtr)->refCount = 0; \
- (objPtr)->bytes = NULL; \
- (objPtr)->internalRep.doubleValue = (double)(d); \
- (objPtr)->typePtr = &tclDoubleType; \
- TCL_DTRACE_OBJ_CREATE(objPtr)
+ do { \
+ TclIncrObjsAllocated(); \
+ TclAllocObjStorage(objPtr); \
+ (objPtr)->refCount = 0; \
+ (objPtr)->bytes = NULL; \
+ (objPtr)->internalRep.doubleValue = (double)(d); \
+ (objPtr)->typePtr = &tclDoubleType; \
+ TCL_DTRACE_OBJ_CREATE(objPtr); \
+ } while (0)
#define TclNewStringObj(objPtr, s, len) \
- TclIncrObjsAllocated(); \
- TclAllocObjStorage(objPtr); \
- (objPtr)->refCount = 0; \
- TclInitStringRep((objPtr), (s), (len));\
- (objPtr)->typePtr = NULL; \
- TCL_DTRACE_OBJ_CREATE(objPtr)
+ do { \
+ TclIncrObjsAllocated(); \
+ TclAllocObjStorage(objPtr); \
+ (objPtr)->refCount = 0; \
+ TclInitStringRep((objPtr), (s), (len)); \
+ (objPtr)->typePtr = NULL; \
+ TCL_DTRACE_OBJ_CREATE(objPtr); \
+ } while (0)
#else /* TCL_MEM_DEBUG */
#define TclNewIntObj(objPtr, i) \
@@ -4396,43 +4419,45 @@ MODULE_SCOPE int Procbodytest_SafeInit(Tcl_Interp *interp);
*----------------------------------------------------------------
*/
-#define TclSmallAlloc(nbytes, memPtr) \
+#define TclSmallAlloc(nbytes, memPtr) \
TclSmallAllocEx(NULL, (nbytes), (memPtr))
-#define TclSmallFree(memPtr) \
+#define TclSmallFree(memPtr) \
TclSmallFreeEx(NULL, (memPtr))
#ifndef TCL_MEM_DEBUG
-#define TclSmallAllocEx(interp, nbytes, memPtr) \
- { \
+#define TclSmallAllocEx(interp, nbytes, memPtr) \
+ do { \
Tcl_Obj *objPtr; \
TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \
TclIncrObjsAllocated(); \
TclAllocObjStorageEx((interp), (objPtr)); \
memPtr = (ClientData) (objPtr); \
- }
+ } while (0)
-#define TclSmallFreeEx(interp, memPtr) \
- TclFreeObjStorageEx((interp), (Tcl_Obj *) (memPtr)); \
- TclIncrObjsFreed()
+#define TclSmallFreeEx(interp, memPtr) \
+ do { \
+ TclFreeObjStorageEx((interp), (Tcl_Obj *) (memPtr)); \
+ TclIncrObjsFreed(); \
+ } while (0)
#else /* TCL_MEM_DEBUG */
-#define TclSmallAllocEx(interp, nbytes, memPtr) \
- { \
+#define TclSmallAllocEx(interp, nbytes, memPtr) \
+ do { \
Tcl_Obj *objPtr; \
TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \
TclNewObj(objPtr); \
memPtr = (ClientData) objPtr; \
- }
+ } while (0)
-#define TclSmallFreeEx(interp, memPtr) \
- { \
+#define TclSmallFreeEx(interp, memPtr) \
+ do { \
Tcl_Obj *objPtr = (Tcl_Obj *) memPtr; \
objPtr->bytes = NULL; \
objPtr->typePtr = NULL; \
objPtr->refCount = 1; \
TclDecrRefCount(objPtr); \
- }
+ } while (0)
#endif /* TCL_MEM_DEBUG */
/*
@@ -4479,7 +4504,8 @@ typedef struct TEOV_callback {
* Inline version of Tcl_NRAddCallback.
*/
-#define TclNRAddCallback(interp,postProcPtr,data0,data1,data2,data3) { \
+#define TclNRAddCallback(interp,postProcPtr,data0,data1,data2,data3) \
+ do { \
TEOV_callback *callbackPtr; \
TCLNR_ALLOC((interp), (callbackPtr)); \
callbackPtr->procPtr = (postProcPtr); \
@@ -4489,9 +4515,10 @@ typedef struct TEOV_callback {
callbackPtr->data[3] = (ClientData)(data3); \
callbackPtr->nextPtr = TOP_CB(interp); \
TOP_CB(interp) = callbackPtr; \
- }
+ } while (0)
-#define TclNRDeferCallback(interp,postProcPtr,data0,data1,data2,data3) { \
+#define TclNRDeferCallback(interp,postProcPtr,data0,data1,data2,data3) \
+ do { \
TEOV_callback *callbackPtr; \
TCLNR_ALLOC((interp), (callbackPtr)); \
callbackPtr->procPtr = (postProcPtr); \
@@ -4501,16 +4528,17 @@ typedef struct TEOV_callback {
callbackPtr->data[3] = (ClientData)(data3); \
callbackPtr->nextPtr = ((Interp *)interp)->deferredCallbacks; \
((Interp *)interp)->deferredCallbacks = callbackPtr; \
- }
+ } while (0)
-#define TclNRSpliceCallbacks(interp,topPtr) { \
+#define TclNRSpliceCallbacks(interp, topPtr) \
+ do { \
TEOV_callback *bottomPtr = topPtr; \
while (bottomPtr->nextPtr) { \
bottomPtr = bottomPtr->nextPtr; \
} \
bottomPtr->nextPtr = TOP_CB(interp); \
TOP_CB(interp) = topPtr; \
- }
+ } while (0)
#define TclNRSpliceDeferred(interp) \
if (((Interp *)interp)->deferredCallbacks) { \
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 7c5e5b5..c9959fc 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInterp.c,v 1.111 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclInterp.c,v 1.112 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -645,7 +645,7 @@ Tcl_InterpObjCmd(
int i, flags;
Tcl_Interp *slaveInterp;
Tcl_Obj *resultObjPtr;
- static const char *const options[] = {
+ static const char *const cancelOptions[] = {
"-unwind", "--", NULL
};
enum option {
@@ -658,8 +658,8 @@ Tcl_InterpObjCmd(
if (TclGetString(objv[i])[0] != '-') {
break;
}
- if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObj(interp, objv[i], cancelOptions, "option",
+ 0, &index) != TCL_OK) {
return TCL_ERROR;
}
@@ -720,7 +720,7 @@ Tcl_InterpObjCmd(
int i, last, safe;
Tcl_Obj *slavePtr;
char buf[16 + TCL_INTEGER_SPACE];
- static const char *const options[] = {
+ static const char *const createOptions[] = {
"-safe", "--", NULL
};
enum option {
@@ -737,8 +737,8 @@ Tcl_InterpObjCmd(
last = 0;
for (i = 2; i < objc; i++) {
if ((last == 0) && (Tcl_GetString(objv[i])[0] == '-')) {
- if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObj(interp, objv[i], createOptions,
+ "option", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index == OPT_SAFE) {
@@ -879,7 +879,7 @@ Tcl_InterpObjCmd(
return TCL_OK;
}
case OPT_INVOKEHID: {
- int i, index;
+ int i;
const char *namespaceName;
Tcl_Interp *slaveInterp;
static const char *const hiddenOptions[] = {
@@ -2460,7 +2460,7 @@ SlaveObjCmd(
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(Tcl_IsSafe(slaveInterp)));
return TCL_OK;
case OPT_INVOKEHIDDEN: {
- int i, index;
+ int i;
const char *namespaceName;
static const char *const hiddenOptions[] = {
"-global", "-namespace", "--", NULL
diff --git a/generic/tclLoad.c b/generic/tclLoad.c
index e5b70c3..e6e2ba5 100644
--- a/generic/tclLoad.c
+++ b/generic/tclLoad.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoad.c,v 1.23 2008/12/19 09:33:16 nijtmans Exp $
+ * RCS: @(#) $Id: tclLoad.c,v 1.24 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -443,9 +443,9 @@ Tcl_LoadObjCmd(
Tcl_MutexLock(&packageMutex);
if (Tcl_IsSafe(target)) {
- ++pkgPtr->safeInterpRefCount;
+ pkgPtr->safeInterpRefCount++;
} else {
- ++pkgPtr->interpRefCount;
+ pkgPtr->interpRefCount++;
}
Tcl_MutexUnlock(&packageMutex);
@@ -725,9 +725,9 @@ Tcl_UnloadObjCmd(
Tcl_MutexUnlock(&packageMutex);
if (Tcl_IsSafe(target)) {
- --safeRefCount;
+ safeRefCount--;
} else {
- --trustedRefCount;
+ trustedRefCount--;
}
if (safeRefCount <= 0 && trustedRefCount <= 0) {
@@ -747,7 +747,7 @@ Tcl_UnloadObjCmd(
Tcl_MutexLock(&packageMutex);
if (Tcl_IsSafe(target)) {
- --pkgPtr->safeInterpRefCount;
+ pkgPtr->safeInterpRefCount--;
/*
* Do not let counter get negative.
@@ -757,7 +757,7 @@ Tcl_UnloadObjCmd(
pkgPtr->safeInterpRefCount = 0;
}
} else {
- --pkgPtr->interpRefCount;
+ pkgPtr->interpRefCount--;
/*
* Do not let counter get negative.
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index dee324c..e32e0ba 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -22,7 +22,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNamesp.c,v 1.203 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.204 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1638,13 +1638,12 @@ DoImport(
cmdPtr = Tcl_GetHashValue(hPtr);
if (found != NULL && cmdPtr->deleteProc == DeleteImportedCmd) {
Command *overwrite = Tcl_GetHashValue(found);
- Command *link = cmdPtr;
+ Command *linkCmd = cmdPtr;
- while (link->deleteProc == DeleteImportedCmd) {
- ImportedCmdData *dataPtr = link->objClientData;
-
- link = dataPtr->realCmdPtr;
- if (overwrite == link) {
+ while (linkCmd->deleteProc == DeleteImportedCmd) {
+ dataPtr = linkCmd->objClientData;
+ linkCmd = dataPtr->realCmdPtr;
+ if (overwrite == linkCmd) {
Tcl_AppendResult(interp, "import pattern \"", pattern,
"\" would create a loop containing command \"",
Tcl_DStringValue(&ds), "\"", NULL);
diff --git a/generic/tclOO.c b/generic/tclOO.c
index 7ae6ac0..905626a 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclOO.c,v 1.34 2010/03/04 23:42:53 dkf Exp $
+ * RCS: @(#) $Id: tclOO.c,v 1.35 2010/03/05 14:34:04 dkf Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -1006,10 +1006,9 @@ ObjectNamespaceDeleted(
}
if (clsPtr != NULL) {
- Class *superPtr, *mixinPtr;
+ Class *superPtr;
if (clsPtr->metadataPtr != NULL) {
- FOREACH_HASH_DECLS;
Tcl_ObjectMetadataType *metadataTypePtr;
ClientData value;
diff --git a/generic/tclParse.c b/generic/tclParse.c
index dd9e4ff..0e55549 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -468,7 +468,7 @@ Tcl_ParseCommand(
for(s=elemStart;size>0;s++,size--) {
if ((*s)=='\\') {
- nakedbs=1;
+ nakedbs = 1;
break;
}
}
@@ -661,7 +661,7 @@ ParseWhiteSpace(
if (p[1] != '\n') {
break;
}
- p+=2;
+ p += 2;
if (--numBytes == 0) {
*incompletePtr = 1;
break;
@@ -746,7 +746,7 @@ TclParseHex(
break;
}
- ++p;
+ p++;
result <<= 4;
if (digit >= 'a') {
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index df1af1c..152ffde 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPathObj.c,v 1.87 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.88 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -251,7 +251,7 @@ TclFSNormalizeAbsolutePath(
continue;
}
if (dirSep[2] == '.' && IsSeparatorOrNull(dirSep[3])) {
- Tcl_Obj *link;
+ Tcl_Obj *linkObj;
int curLen;
char *linkStr;
@@ -261,6 +261,7 @@ TclFSNormalizeAbsolutePath(
if (retVal == NULL) {
const char *path = TclGetString(pathPtr);
+
retVal = Tcl_NewStringObj(path, dirSep - path);
Tcl_IncrRefCount(retVal);
}
@@ -269,16 +270,17 @@ TclFSNormalizeAbsolutePath(
Tcl_AppendToObj(retVal, dirSep, 1);
}
if (!first || (tclPlatform == TCL_PLATFORM_UNIX)) {
- link = Tcl_FSLink(retVal, NULL, 0);
- if (link != NULL) {
+ linkObj = Tcl_FSLink(retVal, NULL, 0);
+ if (linkObj != NULL) {
/*
* Got a link. Need to check if the link is relative
* or absolute, for those platforms where relative
* links exist.
*/
- if (tclPlatform != TCL_PLATFORM_WINDOWS &&
- Tcl_FSGetPathType(link) == TCL_PATH_RELATIVE) {
+ if (tclPlatform != TCL_PLATFORM_WINDOWS
+ && Tcl_FSGetPathType(linkObj)
+ == TCL_PATH_RELATIVE) {
/*
* We need to follow this link which is relative
* to retVal's directory. This means concatenating
@@ -304,8 +306,8 @@ TclFSNormalizeAbsolutePath(
*/
Tcl_SetObjLength(retVal, curLen+1);
- Tcl_AppendObjToObj(retVal, link);
- TclDecrRefCount(link);
+ Tcl_AppendObjToObj(retVal, linkObj);
+ TclDecrRefCount(linkObj);
linkStr = Tcl_GetStringFromObj(retVal, &curLen);
} else {
/*
@@ -313,7 +315,7 @@ TclFSNormalizeAbsolutePath(
*/
TclDecrRefCount(retVal);
- retVal = link;
+ retVal = linkObj;
linkStr = Tcl_GetStringFromObj(retVal, &curLen);
/*
@@ -878,18 +880,18 @@ Tcl_FSJoinPath(
* could expand that in the future.
*/
- if ((i == (elements-2)) && (i == 0) && (elt->typePtr == &tclFsPathType)
- && !(elt->bytes != NULL && (elt->bytes[0] == '\0'))) {
- Tcl_Obj *tail;
- Tcl_PathType type;
+ if ((i == (elements-2)) && (i == 0)
+ && (elt->typePtr == &tclFsPathType)
+ && !((elt->bytes != NULL) && (elt->bytes[0] == '\0'))) {
+ Tcl_Obj *tailObj;
- Tcl_ListObjIndex(NULL, listObj, i+1, &tail);
- type = TclGetPathType(tail, NULL, NULL, NULL);
+ Tcl_ListObjIndex(NULL, listObj, i+1, &tailObj);
+ type = TclGetPathType(tailObj, NULL, NULL, NULL);
if (type == TCL_PATH_RELATIVE) {
const char *str;
int len;
- str = Tcl_GetStringFromObj(tail, &len);
+ str = Tcl_GetStringFromObj(tailObj, &len);
if (len == 0) {
/*
* This happens if we try to handle the root volume '/'.
@@ -931,22 +933,22 @@ Tcl_FSJoinPath(
/*
* Otherwise we don't have an easy join, and we must let the
- * more general code below handle things
+ * more general code below handle things.
*/
} else if (tclPlatform == TCL_PLATFORM_UNIX) {
if (res != NULL) {
TclDecrRefCount(res);
}
- return tail;
+ return tailObj;
} else {
- const char *str = Tcl_GetString(tail);
+ const char *str = TclGetString(tailObj);
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
if (strchr(str, '\\') == NULL) {
if (res != NULL) {
TclDecrRefCount(res);
}
- return tail;
+ return tailObj;
}
}
}
@@ -2752,7 +2754,7 @@ TclNativePathInFilesystem(
int len;
- Tcl_GetStringFromObj(pathPtr, &len);
+ (void) Tcl_GetStringFromObj(pathPtr, &len);
if (len == 0) {
/*
* We reject the empty path "".
diff --git a/generic/tclProc.c b/generic/tclProc.c
index e705108..e4ca35b 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclProc.c,v 1.178 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclProc.c,v 1.179 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -332,8 +332,8 @@ Tcl_ProcObjCmd(
}
if ((procArgs[0] == 'a') && (strncmp(procArgs, "args", 4) == 0)) {
- procArgs +=4;
- while(*procArgs != '\0') {
+ procArgs += 4;
+ while (*procArgs != '\0') {
if (*procArgs != ' ') {
goto done;
}
@@ -973,11 +973,11 @@ TclNRUplevelObjCmd(
if (result == -1) {
return TCL_ERROR;
}
- objc -= (result+1);
+ objc -= result + 1;
if (objc == 0) {
goto uplevelSyntax;
}
- objv += (result+1);
+ objv += result + 1;
/*
* Modify the interpreter state to execute in the given frame.
@@ -1390,7 +1390,7 @@ InitLocalCache(
i++;
}
namePtr++;
- localPtr=localPtr->nextPtr;
+ localPtr = localPtr->nextPtr;
}
codePtr->localCachePtr = localCachePtr;
localCachePtr->refCount = 1;
diff --git a/generic/tclScan.c b/generic/tclScan.c
index a9be080..6d23950 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclScan.c,v 1.34 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclScan.c,v 1.35 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -449,14 +449,10 @@ ValidateFormat(
TCL_STATIC);
goto error;
default:
- {
- char buf[TCL_UTF_MAX+1];
-
- buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
- Tcl_AppendResult(interp, "bad scan conversion character \"",
- buf, "\"", NULL);
- goto error;
- }
+ buf[Tcl_UniCharToUtf(ch, buf)] = '\0';
+ Tcl_AppendResult(interp, "bad scan conversion character \"", buf,
+ "\"", NULL);
+ goto error;
}
if (!(flags & SCAN_SUPPRESS)) {
if (objIndex >= nspace) {
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index 20016db..9577798 100755
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStrToD.c,v 1.40 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclStrToD.c,v 1.41 2010/03/05 14:34:04 dkf Exp $
*
*----------------------------------------------------------------------
*/
@@ -143,7 +143,7 @@ static int n770_fp; /* Flag is 1 on Nokia N770 floating point.
static double AbsoluteValue(double v, int *signum);
static int AccumulateDecimalDigit(unsigned, int,
Tcl_WideUInt *, mp_int *, int);
-static double BignumToBiasedFrExp(mp_int *big, int* machexp);
+static double BignumToBiasedFrExp(mp_int *big, int *machexp);
static int GetIntegerTimesPower(double v, mp_int *r, int *e);
static double MakeHighPrecisionDouble(int signum,
mp_int *significand, int nSigDigs, int exponent);
@@ -456,7 +456,7 @@ TclParseNumber(
case ZERO_O:
zeroo:
if (c == '0') {
- ++numTrailZeros;
+ numTrailZeros++;
state = OCTAL;
break;
} else if (c >= '1' && c <= '7') {
@@ -529,7 +529,7 @@ TclParseNumber(
*/
if (c == '0') {
- ++numTrailZeros;
+ numTrailZeros++;
state = BAD_OCTAL;
break;
} else if (isdigit(UCHAR(c))) {
@@ -572,7 +572,7 @@ TclParseNumber(
case ZERO_X:
zerox:
if (c == '0') {
- ++numTrailZeros;
+ numTrailZeros++;
state = HEXADECIMAL;
break;
} else if (isdigit(UCHAR(c))) {
@@ -619,7 +619,7 @@ TclParseNumber(
case ZERO_B:
zerob:
if (c == '0') {
- ++numTrailZeros;
+ numTrailZeros++;
state = BINARY;
break;
} else if (c != '1') {
@@ -666,7 +666,7 @@ TclParseNumber(
acceptPoint = p;
acceptLen = len;
if (c == '0') {
- ++numTrailZeros;
+ numTrailZeros++;
state = DECIMAL;
break;
} else if (isdigit(UCHAR(c))) {
@@ -709,12 +709,12 @@ TclParseNumber(
case LEADING_RADIX_POINT:
if (c == '0') {
- ++numDigitsAfterDp;
- ++numTrailZeros;
+ numDigitsAfterDp++;
+ numTrailZeros++;
state = FRACTION;
break;
} else if (isdigit(UCHAR(c))) {
- ++numDigitsAfterDp;
+ numDigitsAfterDp++;
if (objPtr != NULL) {
significandOverflow = AccumulateDecimalDigit(
(unsigned)(c-'0'), numTrailZeros,
@@ -894,8 +894,8 @@ TclParseNumber(
acceptLen = len;
goto endgame;
}
- ++p;
- --len;
+ p++;
+ len--;
}
endgame:
@@ -921,8 +921,8 @@ TclParseNumber(
*/
while (len != 0 && isspace(UCHAR(*p))) {
- ++p;
- --len;
+ p++;
+ len--;
}
}
if (endPtrPtr == NULL) {
@@ -1924,7 +1924,7 @@ TclDoubleDigits(
i = mp_cmp_mag(&temp, &s);
if (i>0 || (highOK && i==0)) {
mp_mul_d(&s, 10, &s);
- ++k;
+ k++;
} else {
mp_mul_d(&temp, 10, &temp);
i = mp_cmp_mag(&temp, &s);
@@ -1932,7 +1932,7 @@ TclDoubleDigits(
mp_mul_d(&r, 10, &r);
mp_mul_d(&mplus, 10, &mplus);
mp_mul_d(&mminus, 10, &mminus);
- --k;
+ k--;
}
}
@@ -1961,7 +1961,7 @@ TclDoubleDigits(
if (highOK) {
tc2 = (tc2 >= 0);
} else {
- tc2= (tc2 > 0);
+ tc2 = (tc2 > 0);
}
if (!tc1) {
if (!tc2) {
@@ -2206,7 +2206,7 @@ TclInitDoubleConversion(void)
if (frexp((double) FLT_RADIX, &log2FLT_RADIX) != 0.5) {
Tcl_Panic("This code doesn't work on a decimal machine!");
}
- --log2FLT_RADIX;
+ log2FLT_RADIX--;
mantBits = DBL_MANT_DIG * log2FLT_RADIX;
d = 1.0;
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 005f3d9..30851c1 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.133 2010/02/24 10:32:17 dkf Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.134 2010/03/05 14:34:04 dkf Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -2376,7 +2376,6 @@ AppendPrintfToObjVA(
int code, objc;
Tcl_Obj **objv, *list = Tcl_NewObj();
const char *p;
- char *end;
p = format;
Tcl_IncrRefCount(list);
@@ -2469,10 +2468,13 @@ AppendPrintfToObjVA(
p++;
break;
case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
+ case '5': case '6': case '7': case '8': case '9': {
+ char *end;
+
lastNum = (int) strtoul(p, &end, 10);
p = end;
break;
+ }
case '.':
gotPrecision = 1;
p++;
diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c
index bd6491c..6ea6351 100755
--- a/generic/tclThreadAlloc.c
+++ b/generic/tclThreadAlloc.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: tclThreadAlloc.c,v 1.31 2009/11/26 17:37:26 das Exp $
+ * RCS: @(#) $Id: tclThreadAlloc.c,v 1.32 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -325,7 +325,7 @@ TclpAlloc(
blockPtr = NULL;
size = reqSize + sizeof(Block);
#if RCHECK
- ++size;
+ size++;
#endif
if (size > MAXALLOC) {
bucket = NBUCKETS;
@@ -336,13 +336,13 @@ TclpAlloc(
} else {
bucket = 0;
while (bucketInfo[bucket].blockSize < size) {
- ++bucket;
+ bucket++;
}
if (cachePtr->buckets[bucket].numFree || GetBlocks(cachePtr, bucket)) {
blockPtr = cachePtr->buckets[bucket].firstPtr;
cachePtr->buckets[bucket].firstPtr = blockPtr->nextBlock;
- --cachePtr->buckets[bucket].numFree;
- ++cachePtr->buckets[bucket].numRemoves;
+ cachePtr->buckets[bucket].numFree--;
+ cachePtr->buckets[bucket].numRemoves++;
cachePtr->buckets[bucket].totalAssigned += reqSize;
}
}
@@ -402,8 +402,8 @@ TclpFree(
cachePtr->buckets[bucket].totalAssigned -= blockPtr->blockReqSize;
blockPtr->nextBlock = cachePtr->buckets[bucket].firstPtr;
cachePtr->buckets[bucket].firstPtr = blockPtr;
- ++cachePtr->buckets[bucket].numFree;
- ++cachePtr->buckets[bucket].numInserts;
+ cachePtr->buckets[bucket].numFree++;
+ cachePtr->buckets[bucket].numInserts++;
if (cachePtr != sharedPtr &&
cachePtr->buckets[bucket].numFree > bucketInfo[bucket].maxBlocks) {
@@ -469,7 +469,7 @@ TclpRealloc(
blockPtr = Ptr2Block(ptr);
size = reqSize + sizeof(Block);
#if RCHECK
- ++size;
+ size++;
#endif
bucket = blockPtr->sourceBucket;
if (bucket != NBUCKETS) {
@@ -578,7 +578,7 @@ TclThreadAllocObj(void)
objPtr = cachePtr->firstObjPtr;
cachePtr->firstObjPtr = objPtr->internalRep.otherValuePtr;
- --cachePtr->numObjects;
+ cachePtr->numObjects--;
return objPtr;
}
@@ -618,7 +618,7 @@ TclThreadFreeObj(
objPtr->internalRep.otherValuePtr = cachePtr->firstObjPtr;
cachePtr->firstObjPtr = objPtr;
- ++cachePtr->numObjects;
+ cachePtr->numObjects++;
/*
* If the number of free objects has exceeded the high water mark, move
@@ -810,14 +810,14 @@ LockBucket(
#if 0
if (Tcl_MutexTryLock(bucketInfo[bucket].lockPtr) != TCL_OK) {
Tcl_MutexLock(bucketInfo[bucket].lockPtr);
- ++cachePtr->buckets[bucket].numWaits;
- ++sharedPtr->buckets[bucket].numWaits;
+ cachePtr->buckets[bucket].numWaits++;
+ sharedPtr->buckets[bucket].numWaits++;
}
#else
Tcl_MutexLock(bucketInfo[bucket].lockPtr);
#endif
- ++cachePtr->buckets[bucket].numLocks;
- ++sharedPtr->buckets[bucket].numLocks;
+ cachePtr->buckets[bucket].numLocks++;
+ sharedPtr->buckets[bucket].numLocks++;
}
static void
@@ -956,7 +956,7 @@ GetBlocks(
size = bucketInfo[n].blockSize;
blockPtr = cachePtr->buckets[n].firstPtr;
cachePtr->buckets[n].firstPtr = blockPtr->nextBlock;
- --cachePtr->buckets[n].numFree;
+ cachePtr->buckets[n].numFree--;
break;
}
}
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 6b054d8..71e4093 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.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: tclUtil.c,v 1.113 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.114 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -435,7 +435,7 @@ Tcl_SplitList(
if (next == '\0') {
break;
}
- ++l;
+ l++;
if (isspace(UCHAR(next))) { /* INTL: ISO space. */
continue;
}
@@ -553,7 +553,7 @@ TclMarkList(
if ((l+1) == end) {
break;
}
- ++l;
+ l++;
if (isspace(UCHAR(next))) { /* INTL: ISO space. */
continue;
}
@@ -2238,7 +2238,7 @@ Tcl_PrintDouble(
* at least TCL_DOUBLE_SPACE characters. */
{
char *p, c;
- int exp;
+ int exponent;
int signum;
char buffer[TCL_DOUBLE_SPACE];
Tcl_UniChar ch;
@@ -2279,12 +2279,12 @@ Tcl_PrintDouble(
* Ordinary (normal and denormal) values.
*/
- exp = TclDoubleDigits(buffer, value, &signum);
+ exponent = TclDoubleDigits(buffer, value, &signum);
if (signum) {
*dst++ = '-';
}
p = buffer;
- if (exp < -3 || exp > 17) {
+ if (exponent < -3 || exponent > 17) {
/*
* E format for numbers < 1e-3 or >= 1e17.
*/
@@ -2298,17 +2298,17 @@ Tcl_PrintDouble(
c = *++p;
}
}
- sprintf(dst, "e%+d", exp-1);
+ sprintf(dst, "e%+d", exponent-1);
} else {
/*
* F format for others.
*/
- if (exp <= 0) {
+ if (exponent <= 0) {
*dst++ = '0';
}
c = *p;
- while (exp-- > 0) {
+ while (exponent-- > 0) {
if (c != '\0') {
*dst++ = c;
c = *++p;
@@ -2320,7 +2320,7 @@ Tcl_PrintDouble(
if (c == '\0') {
*dst++ = '0';
} else {
- while (++exp < 0) {
+ while (++exponent < 0) {
*dst++ = '0';
}
while (c != '\0') {
@@ -2624,14 +2624,13 @@ TclGetIntForIndex(
parseError:
if (interp != NULL) {
- const char *bytes = Tcl_GetString(objPtr);
-
/*
* The result might not be empty; this resets it which should be both
* a cheap operation, and of little problem because this is an
* error-generation path anyway.
*/
+ bytes = Tcl_GetString(objPtr);
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "bad index \"", bytes,
"\": must be integer?[+-]integer? or end?[+-]integer?", NULL);
@@ -2820,7 +2819,7 @@ TclCheckBadOctal(
}
if (*p == '0') {
if ((p[1] == 'o') || p[1] == 'O') {
- p+=2;
+ p += 2;
}
while (isdigit(UCHAR(*p))) { /* INTL: digit. */
p++;
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 6ad657f..9b2a11b 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.197 2010/02/24 10:32:17 dkf Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.198 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -2445,7 +2445,7 @@ UnsetVarStruct(
if (traced) {
VarTrace *tracePtr = NULL;
- Tcl_HashEntry *tPtr = NULL;
+ Tcl_HashEntry *tPtr;
if (TclIsVarTraced(&dummyVar)) {
/*
@@ -2454,9 +2454,8 @@ UnsetVarStruct(
*/
int isNew;
- Tcl_HashEntry *tPtr =
- Tcl_FindHashEntry(&iPtr->varTraces, (char *) varPtr);
+ tPtr = Tcl_FindHashEntry(&iPtr->varTraces, (char *) varPtr);
tracePtr = Tcl_GetHashValue(tPtr);
varPtr->flags &= ~VAR_ALL_TRACES;
Tcl_DeleteHashEntry(tPtr);
@@ -2464,8 +2463,6 @@ UnsetVarStruct(
tPtr = Tcl_CreateHashEntry(&iPtr->varTraces,
(char *) &dummyVar, &isNew);
Tcl_SetHashValue(tPtr, tracePtr);
- } else {
- tPtr = NULL;
}
}
@@ -2484,12 +2481,12 @@ UnsetVarStruct(
tracePtr = NULL;
if (TclIsVarTraced(&dummyVar)) {
- tPtr = Tcl_FindHashEntry(&iPtr->varTraces, (char *) &dummyVar);
+ tPtr = Tcl_FindHashEntry(&iPtr->varTraces,
+ (char *) &dummyVar);
tracePtr = Tcl_GetHashValue(tPtr);
- }
-
- if (tPtr) {
- Tcl_DeleteHashEntry(tPtr);
+ if (tPtr) {
+ Tcl_DeleteHashEntry(tPtr);
+ }
}
}
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 21d9a82..a8d97d4 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclZlib.c,v 1.35 2010/02/24 10:45:04 dkf Exp $
+ * RCS: @(#) $Id: tclZlib.c,v 1.36 2010/03/05 14:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1700,15 +1700,16 @@ TclZlibCmd(
NULL
};
enum zlibCommands {
- z_adler32, z_compress, z_crc32, z_decompress, z_deflate, z_gunzip,
- z_gzip, z_inflate, z_push, z_stream
+ CMD_ADLER, CMD_COMPRESS, CMD_CRC, CMD_DECOMPRESS, CMD_DEFLATE,
+ CMD_GUNZIP, CMD_GZIP, CMD_INFLATE, CMD_PUSH, CMD_STREAM
};
static const char *const stream_formats[] = {
"compress", "decompress", "deflate", "gunzip", "gzip", "inflate",
NULL
};
enum zlibFormats {
- f_compress, f_decompress, f_deflate, f_gunzip, f_gzip, f_inflate
+ FMT_COMPRESS, FMT_DECOMPRESS, FMT_DEFLATE, FMT_GUNZIP, FMT_GZIP,
+ FMT_INFLATE
};
if (objc < 2) {
@@ -1721,7 +1722,7 @@ TclZlibCmd(
}
switch ((enum zlibCommands) command) {
- case z_adler32: /* adler32 str ?startvalue?
+ case CMD_ADLER: /* adler32 str ?startvalue?
* -> checksum */
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "data ?startValue?");
@@ -1738,7 +1739,7 @@ TclZlibCmd(
Tcl_SetWideIntObj(obj,
(Tcl_WideInt) Tcl_ZlibAdler32(start, data, dlen));
return TCL_OK;
- case z_crc32: /* crc32 str ?startvalue?
+ case CMD_CRC: /* crc32 str ?startvalue?
* -> checksum */
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "data ?startValue?");
@@ -1755,7 +1756,7 @@ TclZlibCmd(
Tcl_SetWideIntObj(obj,
(Tcl_WideInt) Tcl_ZlibCRC32(start, data, dlen));
return TCL_OK;
- case z_deflate: /* deflate data ?level?
+ case CMD_DEFLATE: /* deflate data ?level?
* -> rawCompressedData */
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "data ?level?");
@@ -1771,7 +1772,7 @@ TclZlibCmd(
}
return Tcl_ZlibDeflate(interp, TCL_ZLIB_FORMAT_RAW, objv[2], level,
NULL);
- case z_compress: /* compress data ?level?
+ case CMD_COMPRESS: /* compress data ?level?
* -> zlibCompressedData */
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "data ?level?");
@@ -1787,7 +1788,7 @@ TclZlibCmd(
}
return Tcl_ZlibDeflate(interp, TCL_ZLIB_FORMAT_ZLIB, objv[2], level,
NULL);
- case z_gzip: /* gzip data ?level?
+ case CMD_GZIP: /* gzip data ?level?
* -> gzippedCompressedData */
if (objc < 3 || objc > 7 || ((objc & 1) == 0)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1822,7 +1823,7 @@ TclZlibCmd(
}
return Tcl_ZlibDeflate(interp, TCL_ZLIB_FORMAT_GZIP, objv[2], level,
headerDictObj);
- case z_inflate: /* inflate rawcomprdata ?bufferSize?
+ case CMD_INFLATE: /* inflate rawcomprdata ?bufferSize?
* -> decompressedData */
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "data ?bufferSize?");
@@ -1839,7 +1840,7 @@ TclZlibCmd(
}
return Tcl_ZlibInflate(interp, TCL_ZLIB_FORMAT_RAW, objv[2],
buffersize, NULL);
- case z_decompress: /* decompress zlibcomprdata \
+ case CMD_DECOMPRESS: /* decompress zlibcomprdata \
* ?bufferSize?
* -> decompressedData */
if (objc < 3 || objc > 4) {
@@ -1857,7 +1858,7 @@ TclZlibCmd(
}
return Tcl_ZlibInflate(interp, TCL_ZLIB_FORMAT_ZLIB, objv[2],
buffersize, NULL);
- case z_gunzip: /* gunzip gzippeddata ?bufferSize?
+ case CMD_GUNZIP: /* gunzip gzippeddata ?bufferSize?
* -> decompressedData */
if (objc < 3 || objc > 5 || ((objc & 1) == 0)) {
Tcl_WrongNumArgs(interp, 2, objv, "data ?-headerVar varName?");
@@ -1904,7 +1905,7 @@ TclZlibCmd(
return TCL_ERROR;
}
return TCL_OK;
- case z_stream: /* stream deflate/inflate/...gunzip \
+ case CMD_STREAM: /* stream deflate/inflate/...gunzip \
* ?level?
* -> handleCmd */
if (objc < 3 || objc > 4) {
@@ -1917,19 +1918,19 @@ TclZlibCmd(
}
mode = TCL_ZLIB_STREAM_INFLATE;
switch ((enum zlibFormats) format) {
- case f_deflate:
+ case FMT_DEFLATE:
mode = TCL_ZLIB_STREAM_DEFLATE;
- case f_inflate:
+ case FMT_INFLATE:
format = TCL_ZLIB_FORMAT_RAW;
break;
- case f_compress:
+ case FMT_COMPRESS:
mode = TCL_ZLIB_STREAM_DEFLATE;
- case f_decompress:
+ case FMT_DECOMPRESS:
format = TCL_ZLIB_FORMAT_ZLIB;
break;
- case f_gzip:
+ case FMT_GZIP:
mode = TCL_ZLIB_STREAM_DEFLATE;
- case f_gunzip:
+ case FMT_GUNZIP:
format = TCL_ZLIB_FORMAT_GZIP;
break;
}
@@ -1950,10 +1951,10 @@ TclZlibCmd(
}
Tcl_SetObjResult(interp, Tcl_ZlibStreamGetCommandName(zh));
return TCL_OK;
- case z_push: { /* push mode channel options...
+ case CMD_PUSH: { /* push mode channel options...
* -> channel */
Tcl_Channel chan;
- int chanMode, mode;
+ int chanMode;
static const char *const pushOptions[] = {
"-header", "-level", "-limit",
NULL
@@ -1972,27 +1973,27 @@ TclZlibCmd(
return TCL_ERROR;
}
switch ((enum zlibFormats) format) {
- case f_deflate:
+ case FMT_DEFLATE:
mode = TCL_ZLIB_STREAM_DEFLATE;
format = TCL_ZLIB_FORMAT_RAW;
break;
- case f_inflate:
+ case FMT_INFLATE:
mode = TCL_ZLIB_STREAM_INFLATE;
format = TCL_ZLIB_FORMAT_RAW;
break;
- case f_compress:
+ case FMT_COMPRESS:
mode = TCL_ZLIB_STREAM_DEFLATE;
format = TCL_ZLIB_FORMAT_ZLIB;
break;
- case f_decompress:
+ case FMT_DECOMPRESS:
mode = TCL_ZLIB_STREAM_INFLATE;
format = TCL_ZLIB_FORMAT_ZLIB;
break;
- case f_gzip:
+ case FMT_GZIP:
mode = TCL_ZLIB_STREAM_DEFLATE;
format = TCL_ZLIB_FORMAT_GZIP;
break;
- case f_gunzip:
+ case FMT_GUNZIP:
mode = TCL_ZLIB_STREAM_INFLATE;
format = TCL_ZLIB_FORMAT_GZIP;
break;
@@ -2397,7 +2398,7 @@ ZlibTransformInput(
ZlibChannelData *cd = instanceData;
Tcl_DriverInputProc *inProc =
Tcl_ChannelInputProc(Tcl_GetChannelType(cd->parent));
- int e, read, flush = Z_NO_FLUSH;
+ int e, readBytes, flush = Z_NO_FLUSH;
if (cd->mode == TCL_ZLIB_STREAM_DEFLATE) {
return inProc(Tcl_GetChannelInstanceData(cd->parent), buf, toRead,
@@ -2457,16 +2458,16 @@ ZlibTransformInput(
* work around the general problem in this way.
*/
- read = Tcl_ReadRaw(cd->parent, cd->inBuffer, 1);
- if (read < 0) {
+ readBytes = Tcl_ReadRaw(cd->parent, cd->inBuffer, 1);
+ if (readBytes < 0) {
*errorCodePtr = Tcl_GetErrno();
return -1;
- } else if (read == 0) {
+ } else if (readBytes == 0) {
flush = Z_SYNC_FLUSH;
}
cd->inStream.next_in = (Bytef *) cd->inBuffer;
- cd->inStream.avail_in = read;
+ cd->inStream.avail_in = readBytes;
}
}