summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclBinary.c2
-rw-r--r--generic/tclCompile.h6
-rw-r--r--generic/tclEncoding.c2
-rw-r--r--generic/tclIO.h2
-rw-r--r--generic/tclInt.h10
-rw-r--r--generic/tclObj.c16
-rw-r--r--generic/tclProc.c7
-rw-r--r--generic/tclStringRep.h2
-rw-r--r--library/http/http.tcl2
-rw-r--r--library/init.tcl4
-rw-r--r--library/safe.tcl2
-rw-r--r--library/tcltest/tcltest.tcl6
-rw-r--r--tests/httpTest.tcl2
-rw-r--r--win/Makefile.in1
14 files changed, 36 insertions, 28 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index ea84b50..18cb2f1 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -274,7 +274,7 @@ typedef struct {
* array. */
size_t allocated; /* The amount of space actually allocated
* minus 1 byte. */
- unsigned char bytes[1]; /* The array of bytes. The actual size of this
+ unsigned char bytes[TCLFLEXARRAY]; /* The array of bytes. The actual size of this
* field depends on the 'allocated' field
* above. */
} ByteArray;
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index ff36d79..7e2fd55 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -969,7 +969,7 @@ typedef struct JumpFixupArray {
typedef struct ForeachVarList {
int numVars; /* The number of variables in the list. */
- int varIndexes[1]; /* An array of the indexes ("slot numbers")
+ int varIndexes[TCLFLEXARRAY];/* An array of the indexes ("slot numbers")
* for each variable in the procedure's array
* of local variables. Only scalar variables
* are supported. The actual size of this
@@ -993,7 +993,7 @@ typedef struct ForeachInfo {
* the loop's iteration count. Used to
* determine next value list element to assign
* each loop var. */
- ForeachVarList *varLists[1];/* An array of pointers to ForeachVarList
+ ForeachVarList *varLists[TCLFLEXARRAY];/* An array of pointers to ForeachVarList
* structures describing each var list. The
* actual size of this field will be large
* enough to numVars indexes. THIS MUST BE THE
@@ -1024,7 +1024,7 @@ MODULE_SCOPE const AuxDataType tclJumptableInfoType;
typedef struct {
size_t length; /* Size of array */
- int varIndices[1]; /* Array of variable indices to manage when
+ int varIndices[TCLFLEXARRAY]; /* Array of variable indices to manage when
* processing the start and end of a [dict
* update]. There is really more than one
* entry, and the structure is allocated to
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 2602955..4a43599 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -116,7 +116,7 @@ typedef struct {
* entry in this array is 1, otherwise it is
* 0. */
int numSubTables; /* Length of following array. */
- EscapeSubTable subTables[1];/* Information about each EscapeSubTable used
+ EscapeSubTable subTables[TCLFLEXARRAY];/* Information about each EscapeSubTable used
* by this encoding type. The actual size is
* as large as necessary to hold all
* EscapeSubTables. */
diff --git a/generic/tclIO.h b/generic/tclIO.h
index 1fd6458..d12c02e 100644
--- a/generic/tclIO.h
+++ b/generic/tclIO.h
@@ -44,7 +44,7 @@ typedef struct ChannelBuffer {
int bufLength; /* How big is the buffer? */
struct ChannelBuffer *nextPtr;
/* Next buffer in chain. */
- char buf[1]; /* Placeholder for real buffer. The real
+ char buf[TCLFLEXARRAY]; /* Placeholder for real buffer. The real
* buffer occuppies this space + bufSize-1
* bytes. This must be the last field in the
* structure. */
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 7ca9a8c..fba5ecd 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -909,6 +909,12 @@ typedef struct VarInHash {
*----------------------------------------------------------------
*/
+#if defined(__GNUC__) && (__GNUC__ > 2)
+# define TCLFLEXARRAY 0
+#else
+# define TCLFLEXARRAY 1
+#endif
+
/*
* Forward declaration to prevent an error when the forward reference to
* Command is encountered in the Proc and ImportRef types declared below.
@@ -952,7 +958,7 @@ typedef struct CompiledLocal {
* is marked by a unique tag during
* compilation, and that same tag is used to
* find the variable at runtime. */
- char name[1]; /* Name of the local variable starts here. If
+ char name[TCLFLEXARRAY]; /* Name of the local variable starts here. If
* the name is NULL, this will just be '\0'.
* The actual size of this field will be large
* enough to hold the name. MUST BE THE LAST
@@ -1290,7 +1296,7 @@ typedef struct CFWordBC {
typedef struct ContLineLoc {
int num; /* Number of entries in loc, not counting the
* final -1 marker entry. */
- int loc[1]; /* Table of locations, as character offsets.
+ int loc[TCLFLEXARRAY];/* Table of locations, as character offsets.
* The table is allocated as part of the
* structure, extending behind the nominal end
* of the structure. An entry containing the
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 6f4e9e8..e52098c 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -145,12 +145,12 @@ typedef struct PendingObjData {
#define ObjDeletionUnlock(contextPtr) ((contextPtr)->deletionCount--)
#define ObjDeletePending(contextPtr) ((contextPtr)->deletionCount > 0)
#define ObjOnStack(contextPtr) ((contextPtr)->deletionStack != NULL)
-#define PushObjToDelete(contextPtr,objPtr) \
+#define PushObjToDelete(contextPtr,objPtr) \
/* The string rep is already invalidated so we can use the bytes value \
* for our pointer chain: push onto the head of the stack. */ \
(objPtr)->bytes = (char *) ((contextPtr)->deletionStack); \
(contextPtr)->deletionStack = (objPtr)
-#define PopObjToDelete(contextPtr,objPtrVar) \
+#define PopObjToDelete(contextPtr,objPtrVar) \
(objPtrVar) = (contextPtr)->deletionStack; \
(contextPtr)->deletionStack = (Tcl_Obj *) (objPtrVar)->bytes
@@ -168,7 +168,7 @@ static __thread PendingObjData pendingObjData;
#else
static Tcl_ThreadDataKey pendingObjDataKey;
#define ObjInitDeletionContext(contextPtr) \
- PendingObjData *const contextPtr = \
+ PendingObjData *const contextPtr = \
(PendingObjData *)Tcl_GetThreadData(&pendingObjDataKey, sizeof(PendingObjData))
#endif
@@ -177,11 +177,11 @@ static Tcl_ThreadDataKey pendingObjDataKey;
*/
#define PACK_BIGNUM(bignum, objPtr) \
- if ((bignum).used > 0x7FFF) { \
- mp_int *temp = (mp_int *) Tcl_Alloc(sizeof(mp_int)); \
+ if ((bignum).used > 0x7FFF) { \
+ mp_int *temp = (mp_int *)Tcl_Alloc(sizeof(mp_int)); \
*temp = bignum; \
- (objPtr)->internalRep.twoPtrValue.ptr1 = temp; \
- (objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(-1); \
+ (objPtr)->internalRep.twoPtrValue.ptr1 = temp; \
+ (objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(-1); \
} else if (((bignum).alloc <= 0x7FFF) || (mp_shrink(&(bignum))) == MP_OKAY) { \
(objPtr)->internalRep.twoPtrValue.ptr1 = (bignum).dp; \
(objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR( ((bignum).sign << 30) \
@@ -533,7 +533,7 @@ TclContinuationsEnter(
ThreadSpecificData *tsdPtr = TclGetContLineTable();
Tcl_HashEntry *hPtr =
Tcl_CreateHashEntry(tsdPtr->lineCLPtr, objPtr, &newEntry);
- ContLineLoc *clLocPtr = (ContLineLoc *)Tcl_Alloc(sizeof(ContLineLoc) + num*sizeof(int));
+ ContLineLoc *clLocPtr = (ContLineLoc *)Tcl_Alloc(offsetof(ContLineLoc, loc) + (num + 1) *sizeof(int));
if (!newEntry) {
/*
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 6f51da8..e8c4e6c 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -632,7 +632,8 @@ TclCreateProc(
* local variables for the argument.
*/
- localPtr = (CompiledLocal *)Tcl_Alloc(offsetof(CompiledLocal, name) + fieldValues[0]->length +1);
+ localPtr = (CompiledLocal *)Tcl_Alloc(
+ offsetof(CompiledLocal, name) + fieldValues[0]->length + 1);
if (procPtr->firstLocalPtr == NULL) {
procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr;
} else {
@@ -1261,8 +1262,8 @@ InitLocalCache(
* for future calls.
*/
- localCachePtr = (LocalCache *)Tcl_Alloc(sizeof(LocalCache)
- + (localCt - 1) * sizeof(Tcl_Obj *)
+ localCachePtr = (LocalCache *)Tcl_Alloc(offsetof(LocalCache, varName0)
+ + localCt * sizeof(Tcl_Obj *)
+ numArgs * sizeof(Var));
namePtr = &localCachePtr->varName0;
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index 7db83e3..c8f87be 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -63,7 +63,7 @@ typedef struct {
* space allocated for the unicode array. */
int hasUnicode; /* Boolean determining whether the string has
* a Unicode representation. */
- Tcl_UniChar unicode[1]; /* The array of Unicode chars. The actual size
+ Tcl_UniChar unicode[TCLFLEXARRAY]; /* The array of Unicode chars. The actual size
* of this field depends on the 'maxChars'
* field above. */
} String;
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 192867e..4117f44 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -544,7 +544,7 @@ proc http::CloseSocket {s {token {}}} {
} else {
set map [array get socketMapping]
set ndx [lsearch -exact $map $s]
- if {$ndx != -1} {
+ if {$ndx >= 0} {
incr ndx -1
set connId [lindex $map $ndx]
}
diff --git a/library/init.tcl b/library/init.tcl
index 3b3563f..9775320 100644
--- a/library/init.tcl
+++ b/library/init.tcl
@@ -245,7 +245,7 @@ proc unknown args {
set errInfo [string range $errInfo 0 $last-1]
set tail "\"$cinfo\""
set last [string last $tail $errInfo]
- if {$last + [string length $tail] != [string length $errInfo]} {
+ if {$last < 0 || $last + [string length $tail] != [string length $errInfo]} {
return -code error -errorcode $errCode \
-errorinfo $errInfo $msg
}
@@ -742,7 +742,7 @@ proc tcl::CopyDirectory {action src dest} {
}
}
} else {
- if {[string first $nsrc $ndest] != -1} {
+ if {[string first $nsrc $ndest] >= 0} {
set srclen [expr {[llength [file split $nsrc]] - 1}]
set ndest [lindex [file split $ndest] $srclen]
if {$ndest eq [file tail $nsrc]} {
diff --git a/library/safe.tcl b/library/safe.tcl
index 10180e9..f0550a3 100644
--- a/library/safe.tcl
+++ b/library/safe.tcl
@@ -318,7 +318,7 @@ proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} {
# Make sure that tcl_library is in auto_path and at the first
# position (needed by setAccessPath)
set where [lsearch -exact $access_path [info library]]
- if {$where == -1} {
+ if {$where < 0} {
# not found, add it.
set access_path [linsert $access_path 0 [info library]]
Log $child "tcl_library was not in auto_path,\
diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl
index c894ff1..2af79bc 100644
--- a/library/tcltest/tcltest.tcl
+++ b/library/tcltest/tcltest.tcl
@@ -640,7 +640,7 @@ namespace eval tcltest {
proc IsVerbose {level} {
variable Option
- return [expr {[lsearch -exact $Option(-verbose) $level] != -1}]
+ return [expr {[lsearch -exact $Option(-verbose) $level] >= 0}]
}
# Default verbosity is to show bodies of failed tests
@@ -3107,7 +3107,7 @@ proc tcltest::removeFile {name {directory ""}} {
set fullName [file join $directory $name]
DebugPuts 3 "[lindex [info level 0] 0]: removing $fullName"
set idx [lsearch -exact $filesMade $fullName]
- if {$idx == -1} {
+ if {$idx < 0} {
DebugDo 1 {
Warn "removeFile removing \"$fullName\":\n not created by makeFile"
}
@@ -3184,7 +3184,7 @@ proc tcltest::removeDirectory {name {directory ""}} {
DebugPuts 3 "[lindex [info level 0] 0]: deleting $fullName"
set idx [lsearch -exact $filesMade $fullName]
set filesMade [lreplace $filesMade $idx $idx]
- if {$idx == -1} {
+ if {$idx < 0} {
DebugDo 1 {
Warn "removeDirectory removing \"$fullName\":\n not created\
by makeDirectory"
diff --git a/tests/httpTest.tcl b/tests/httpTest.tcl
index 4345845..7491fb4 100644
--- a/tests/httpTest.tcl
+++ b/tests/httpTest.tcl
@@ -153,7 +153,7 @@ proc httpTest::TestOverlaps {someResults n term msg badTrans notPiped} {
set myStart [lsearch -exact $someResults [list B $i]]
set myEnd [lsearch -exact $someResults [list $term $i]]
- if {($myStart == -1 || $myEnd == -1)} {
+ if {($myStart < 0 || $myEnd < 0)} {
set res "Cannot find positions of transaction $i"
append msg $res \n
Puts $res
diff --git a/win/Makefile.in b/win/Makefile.in
index 79d9a8f..616b630 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -596,6 +596,7 @@ ${TEST_DLL_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS}
${TEST_EXE_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS} tclTestMain.${OBJEXT}
@$(RM) ${TEST_EXE_FILE}
+ @$(RM) $(ROOT_DIR_NATIVE)/tests/safe-stock86.test
$(CC) $(CFLAGS) $(TCLTEST_OBJS) tclTestMain.$(OBJEXT) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
$(COPY) tclsh.exe.manifest ${TEST_EXE_FILE}.manifest