summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-02-05 21:35:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-02-05 21:35:10 (GMT)
commit2dad23ad65d5cf76fa7e2516a6702a8a6ff34723 (patch)
tree0b80be8eba412258b3fa4c109b6b554863d27378
parenteee14742522aed25744851879c80a96134de7369 (diff)
downloadtcl-2dad23ad65d5cf76fa7e2516a6702a8a6ff34723.zip
tcl-2dad23ad65d5cf76fa7e2516a6702a8a6ff34723.tar.gz
tcl-2dad23ad65d5cf76fa7e2516a6702a8a6ff34723.tar.bz2
More size_t-related consolidations. Now regexp can handle strings >2GB and more. Remove many type-casts which are not necessary any more.
-rw-r--r--generic/regc_locale.c71
-rw-r--r--generic/regcomp.c18
-rw-r--r--generic/regcustom.h4
-rw-r--r--generic/regex.h19
-rw-r--r--generic/regexec.c2
-rw-r--r--generic/tclAlloc.c4
-rw-r--r--generic/tclBasic.c2
-rw-r--r--generic/tclBinary.c3
-rw-r--r--generic/tclCkalloc.c12
-rw-r--r--generic/tclCompCmds.c6
-rw-r--r--generic/tclCompCmdsGR.c4
-rw-r--r--generic/tclCompCmdsSZ.c2
-rw-r--r--generic/tclCompExpr.c4
-rw-r--r--generic/tclCompile.c29
-rw-r--r--generic/tclDictObj.c12
-rw-r--r--generic/tclEncoding.c4
-rw-r--r--generic/tclEnsemble.c12
-rw-r--r--generic/tclEnv.c6
-rw-r--r--generic/tclExecute.c17
-rw-r--r--generic/tclFileName.c2
-rw-r--r--generic/tclIO.c24
-rw-r--r--generic/tclIORTrans.c8
-rw-r--r--generic/tclInt.h11
-rw-r--r--generic/tclInterp.c12
-rw-r--r--generic/tclLink.c24
-rw-r--r--generic/tclLiteral.c31
-rw-r--r--generic/tclObj.c2
-rw-r--r--generic/tclParse.c2
-rw-r--r--generic/tclPathObj.c13
-rw-r--r--generic/tclProc.c13
-rw-r--r--generic/tclRegexp.c2
-rw-r--r--generic/tclResult.c11
-rw-r--r--generic/tclStringObj.c40
-rw-r--r--generic/tclStringRep.h14
-rw-r--r--generic/tclThreadTest.c4
-rw-r--r--generic/tclTrace.c8
-rw-r--r--generic/tclUtf.c28
-rw-r--r--generic/tclUtil.c63
-rw-r--r--generic/tclVar.c2
-rw-r--r--generic/tclZipfs.c7
-rw-r--r--generic/tclZlib.c14
-rw-r--r--macosx/tclMacOSXFCmd.c5
-rw-r--r--unix/tclUnixChan.c4
-rw-r--r--unix/tclUnixFCmd.c29
-rw-r--r--unix/tclUnixFile.c11
-rw-r--r--unix/tclUnixInit.c3
-rw-r--r--unix/tclUnixPipe.c4
-rw-r--r--unix/tclUnixSock.c6
-rw-r--r--unix/tclXtNotify.c4
-rw-r--r--win/tclWinFCmd.c13
-rw-r--r--win/tclWinFile.c10
-rw-r--r--win/tclWinInit.c2
-rw-r--r--win/tclWinPipe.c2
53 files changed, 301 insertions, 358 deletions
diff --git a/generic/regc_locale.c b/generic/regc_locale.c
index d6d4cf3..65273d8 100644
--- a/generic/regc_locale.c
+++ b/generic/regc_locale.c
@@ -793,8 +793,6 @@ static const chr graphCharTable[] = {
/*
* End of auto-generated Unicode character ranges declarations.
*/
-
-#define CH NOCELT
/*
- element - map collating-element name to celt
@@ -887,9 +885,9 @@ range(
for (c=a; c<=b; c++) {
addchr(cv, c);
- lc = Tcl_UniCharToLower((chr)c);
- uc = Tcl_UniCharToUpper((chr)c);
- tc = Tcl_UniCharToTitle((chr)c);
+ lc = Tcl_UniCharToLower(c);
+ uc = Tcl_UniCharToUpper(c);
+ tc = Tcl_UniCharToTitle(c);
if (c != lc) {
addchr(cv, lc);
}
@@ -938,11 +936,11 @@ eclass(
if ((v->cflags&REG_FAKE) && c == 'x') {
cv = getcvec(v, 4, 0);
- addchr(cv, (chr)'x');
- addchr(cv, (chr)'y');
+ addchr(cv, 'x');
+ addchr(cv, 'y');
if (cases) {
- addchr(cv, (chr)'X');
- addchr(cv, (chr)'Y');
+ addchr(cv, 'X');
+ addchr(cv, 'Y');
}
return cv;
}
@@ -956,7 +954,7 @@ eclass(
}
cv = getcvec(v, 1, 0);
assert(cv != NULL);
- addchr(cv, (chr)c);
+ addchr(cv, c);
return cv;
}
@@ -977,7 +975,8 @@ cclass(
Tcl_DString ds;
const char *np;
const char *const *namePtr;
- int i, index;
+ size_t i;
+ int index;
/*
* The following arrays define the valid character class names.
@@ -1035,14 +1034,14 @@ cclass(
case CC_ALNUM:
cv = getcvec(v, NUM_ALPHA_CHAR, NUM_DIGIT_RANGE + NUM_ALPHA_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_ALPHA_CHAR ; i++) {
+ for (i=0 ; i<NUM_ALPHA_CHAR ; i++) {
addchr(cv, alphaCharTable[i]);
}
- for (i=0 ; (size_t)i<NUM_ALPHA_RANGE ; i++) {
+ for (i=0 ; i<NUM_ALPHA_RANGE ; i++) {
addrange(cv, alphaRangeTable[i].start,
alphaRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_DIGIT_RANGE ; i++) {
+ for (i=0 ; i<NUM_DIGIT_RANGE ; i++) {
addrange(cv, digitRangeTable[i].start,
digitRangeTable[i].end);
}
@@ -1051,11 +1050,11 @@ cclass(
case CC_ALPHA:
cv = getcvec(v, NUM_ALPHA_CHAR, NUM_ALPHA_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_ALPHA_RANGE ; i++) {
+ for (i=0 ; i<NUM_ALPHA_RANGE ; i++) {
addrange(cv, alphaRangeTable[i].start,
alphaRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_ALPHA_CHAR ; i++) {
+ for (i=0 ; i<NUM_ALPHA_CHAR ; i++) {
addchr(cv, alphaCharTable[i]);
}
}
@@ -1074,11 +1073,11 @@ cclass(
case CC_CNTRL:
cv = getcvec(v, NUM_CONTROL_CHAR, NUM_CONTROL_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_CONTROL_RANGE ; i++) {
+ for (i=0 ; i<NUM_CONTROL_RANGE ; i++) {
addrange(cv, controlRangeTable[i].start,
controlRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_CONTROL_CHAR ; i++) {
+ for (i=0 ; i<NUM_CONTROL_CHAR ; i++) {
addchr(cv, controlCharTable[i]);
}
}
@@ -1086,7 +1085,7 @@ cclass(
case CC_DIGIT:
cv = getcvec(v, 0, NUM_DIGIT_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_DIGIT_RANGE ; i++) {
+ for (i=0 ; i<NUM_DIGIT_RANGE ; i++) {
addrange(cv, digitRangeTable[i].start,
digitRangeTable[i].end);
}
@@ -1095,11 +1094,11 @@ cclass(
case CC_PUNCT:
cv = getcvec(v, NUM_PUNCT_CHAR, NUM_PUNCT_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_PUNCT_RANGE ; i++) {
+ for (i=0 ; i<NUM_PUNCT_RANGE ; i++) {
addrange(cv, punctRangeTable[i].start,
punctRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_PUNCT_CHAR ; i++) {
+ for (i=0 ; i<NUM_PUNCT_CHAR ; i++) {
addchr(cv, punctCharTable[i]);
}
}
@@ -1124,11 +1123,11 @@ cclass(
case CC_SPACE:
cv = getcvec(v, NUM_SPACE_CHAR, NUM_SPACE_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_SPACE_RANGE ; i++) {
+ for (i=0 ; i<NUM_SPACE_RANGE ; i++) {
addrange(cv, spaceRangeTable[i].start,
spaceRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_SPACE_CHAR ; i++) {
+ for (i=0 ; i<NUM_SPACE_CHAR ; i++) {
addchr(cv, spaceCharTable[i]);
}
}
@@ -1136,11 +1135,11 @@ cclass(
case CC_LOWER:
cv = getcvec(v, NUM_LOWER_CHAR, NUM_LOWER_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_LOWER_RANGE ; i++) {
+ for (i=0 ; i<NUM_LOWER_RANGE ; i++) {
addrange(cv, lowerRangeTable[i].start,
lowerRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_LOWER_CHAR ; i++) {
+ for (i=0 ; i<NUM_LOWER_CHAR ; i++) {
addchr(cv, lowerCharTable[i]);
}
}
@@ -1148,11 +1147,11 @@ cclass(
case CC_UPPER:
cv = getcvec(v, NUM_UPPER_CHAR, NUM_UPPER_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_UPPER_RANGE ; i++) {
+ for (i=0 ; i<NUM_UPPER_RANGE ; i++) {
addrange(cv, upperRangeTable[i].start,
upperRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_UPPER_CHAR ; i++) {
+ for (i=0 ; i<NUM_UPPER_CHAR ; i++) {
addchr(cv, upperCharTable[i]);
}
}
@@ -1160,18 +1159,18 @@ cclass(
case CC_PRINT:
cv = getcvec(v, NUM_SPACE_CHAR + NUM_GRAPH_CHAR, NUM_SPACE_RANGE + NUM_GRAPH_RANGE - 1);
if (cv) {
- for (i=1 ; (size_t)i<NUM_SPACE_RANGE ; i++) {
+ for (i=1 ; i<NUM_SPACE_RANGE ; i++) {
addrange(cv, spaceRangeTable[i].start,
spaceRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_SPACE_CHAR ; i++) {
+ for (i=0 ; i<NUM_SPACE_CHAR ; i++) {
addchr(cv, spaceCharTable[i]);
}
- for (i=0 ; (size_t)i<NUM_GRAPH_RANGE ; i++) {
+ for (i=0 ; i<NUM_GRAPH_RANGE ; i++) {
addrange(cv, graphRangeTable[i].start,
graphRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_GRAPH_CHAR ; i++) {
+ for (i=0 ; i<NUM_GRAPH_CHAR ; i++) {
addchr(cv, graphCharTable[i]);
}
}
@@ -1179,11 +1178,11 @@ cclass(
case CC_GRAPH:
cv = getcvec(v, NUM_GRAPH_CHAR, NUM_GRAPH_RANGE);
if (cv) {
- for (i=0 ; (size_t)i<NUM_GRAPH_RANGE ; i++) {
+ for (i=0 ; i<NUM_GRAPH_RANGE ; i++) {
addrange(cv, graphRangeTable[i].start,
graphRangeTable[i].end);
}
- for (i=0 ; (size_t)i<NUM_GRAPH_CHAR ; i++) {
+ for (i=0 ; i<NUM_GRAPH_CHAR ; i++) {
addchr(cv, graphCharTable[i]);
}
}
@@ -1210,9 +1209,9 @@ allcases(
chr c = (chr)pc;
chr lc, uc, tc;
- lc = Tcl_UniCharToLower((chr)c);
- uc = Tcl_UniCharToUpper((chr)c);
- tc = Tcl_UniCharToTitle((chr)c);
+ lc = Tcl_UniCharToLower(c);
+ uc = Tcl_UniCharToUpper(c);
+ tc = Tcl_UniCharToTitle(c);
if (tc != uc) {
cv = getcvec(v, 3, 0);
diff --git a/generic/regcomp.c b/generic/regcomp.c
index 58d55fb..144e7c2 100644
--- a/generic/regcomp.c
+++ b/generic/regcomp.c
@@ -39,7 +39,7 @@
/* automatically gathered by fwd; do not hand-edit */
/* === regcomp.c === */
int compile(regex_t *, const chr *, size_t, int);
-static void moresubs(struct vars *, int);
+static void moresubs(struct vars *, size_t);
static int freev(struct vars *, int);
static void makesearch(struct vars *, struct nfa *);
static struct subre *parse(struct vars *, int, int, struct state *, struct state *);
@@ -469,18 +469,18 @@ compile(
/*
- moresubs - enlarge subRE vector
- ^ static void moresubs(struct vars *, int);
+ ^ static void moresubs(struct vars *, size_t);
*/
static void
moresubs(
struct vars *v,
- int wanted) /* want enough room for this one */
+ size_t wanted) /* want enough room for this one */
{
struct subre **p;
size_t n;
- assert(wanted > 0 && (size_t)wanted >= v->nsubs);
- n = (size_t)wanted * 3 / 2 + 1;
+ assert(wanted > 0 && wanted >= v->nsubs);
+ n = wanted * 3 / 2 + 1;
if (v->subs == v->sub10) {
p = (struct subre **) MALLOC(n * sizeof(struct subre *));
if (p != NULL) {
@@ -499,7 +499,7 @@ moresubs(
*p = NULL;
}
assert(v->nsubs == n);
- assert((size_t)wanted < v->nsubs);
+ assert(wanted < v->nsubs);
}
/*
@@ -797,7 +797,7 @@ parseqatom(
struct subre *t;
int cap; /* capturing parens? */
int pos; /* positive lookahead? */
- int subno; /* capturing-parens or backref number */
+ size_t subno; /* capturing-parens or backref number */
int atomtype;
int qprefer; /* quantifier short/long preference */
int f;
@@ -954,10 +954,10 @@ parseqatom(
if (cap) {
v->nsubexp++;
subno = v->nsubexp;
- if ((size_t)subno >= v->nsubs) {
+ if (subno >= v->nsubs) {
moresubs(v, subno);
}
- assert((size_t)subno < v->nsubs);
+ assert(subno < v->nsubs);
} else {
atomtype = PLAIN; /* something that's not '(' */
}
diff --git a/generic/regcustom.h b/generic/regcustom.h
index 64985a6..1469ab7 100644
--- a/generic/regcustom.h
+++ b/generic/regcustom.h
@@ -56,9 +56,6 @@
#ifdef __REG_WIDE_EXEC
#undef __REG_WIDE_EXEC
#endif
-#ifdef __REG_REGOFF_T
-#undef __REG_REGOFF_T
-#endif
#ifdef __REG_NOFRONT
#undef __REG_NOFRONT
#endif
@@ -67,7 +64,6 @@
#endif
/* Interface types */
#define __REG_WIDE_T Tcl_UniChar
-#define __REG_REGOFF_T long /* Not really right, but good enough... */
/* Names and declarations */
#define __REG_WIDE_COMPILE TclReComp
#define __REG_WIDE_EXEC TclReExec
diff --git a/generic/regex.h b/generic/regex.h
index 8845f72..d80784d 100644
--- a/generic/regex.h
+++ b/generic/regex.h
@@ -89,9 +89,6 @@ extern "C" {
#ifdef __REG_WIDE_EXEC
#undef __REG_WIDE_EXEC
#endif
-#ifdef __REG_REGOFF_T
-#undef __REG_REGOFF_T
-#endif
#ifdef __REG_NOFRONT
#undef __REG_NOFRONT
#endif
@@ -100,7 +97,6 @@ extern "C" {
#endif
/* interface types */
#define __REG_WIDE_T Tcl_UniChar
-#define __REG_REGOFF_T long /* not really right, but good enough... */
/* names and declarations */
#define __REG_WIDE_COMPILE TclReComp
#define __REG_WIDE_EXEC TclReExec
@@ -115,17 +111,6 @@ extern "C" {
*/
/*
- * regoff_t has to be large enough to hold either off_t or ssize_t, and must
- * be signed; it's only a guess that long is suitable, so we offer
- * <sys/types.h> an override.
- */
-#ifdef __REG_REGOFF_T
-typedef __REG_REGOFF_T regoff_t;
-#else
-typedef long regoff_t;
-#endif
-
-/*
* other interface types
*/
@@ -157,8 +142,8 @@ typedef struct {
/* result reporting (may acquire more fields later) */
typedef struct {
- regoff_t rm_so; /* start of substring */
- regoff_t rm_eo; /* end of substring */
+ size_t rm_so; /* start of substring */
+ size_t rm_eo; /* end of substring */
} regmatch_t;
/* supplementary control and reporting */
diff --git a/generic/regexec.c b/generic/regexec.c
index 128d439..02a4614 100644
--- a/generic/regexec.c
+++ b/generic/regexec.c
@@ -889,7 +889,7 @@ cbrdissect(
MDEBUG(("cbackref n%d %d{%d-%d}\n", t->id, n, min, max));
/* get the backreferenced string */
- if (v->pmatch[n].rm_so == -1) {
+ if (v->pmatch[n].rm_so == (size_t)-1) {
return REG_NOMATCH;
}
brstring = v->start + v->pmatch[n].rm_so;
diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c
index 9dcb431..36ae5d4 100644
--- a/generic/tclAlloc.c
+++ b/generic/tclAlloc.c
@@ -255,7 +255,7 @@ TclpAlloc(
{
register union overhead *overPtr;
register size_t bucket;
- register unsigned amount;
+ register size_t amount;
struct block *bigBlockPtr = NULL;
if (!allocInit) {
@@ -603,7 +603,7 @@ TclpRealloc(
if (maxSize < numBytes) {
numBytes = maxSize;
}
- memcpy(newPtr, oldPtr, (size_t) numBytes);
+ memcpy(newPtr, oldPtr, numBytes);
TclpFree(oldPtr);
return newPtr;
}
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 51ff8a6..8196ef4 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -3992,7 +3992,7 @@ Tcl_CancelEval(
if (resultObjPtr != NULL) {
result = TclGetStringFromObj(resultObjPtr, &cancelInfo->length);
cancelInfo->result = Tcl_Realloc(cancelInfo->result,cancelInfo->length);
- memcpy(cancelInfo->result, result, (size_t) cancelInfo->length);
+ memcpy(cancelInfo->result, result, cancelInfo->length);
TclDecrRefCount(resultObjPtr); /* Discard their result object. */
} else {
cancelInfo->result = NULL;
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index ea64557..94ea600 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -548,8 +548,7 @@ SetByteArrayFromAny(
return TCL_OK;
}
- src = TclGetString(objPtr);
- length = objPtr->length;
+ src = TclGetStringFromObj(objPtr, &length);
srcEnd = src + length;
byteArrayPtr = Tcl_Alloc(BYTEARRAY_SIZE(length));
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index 32d4158..bdc5cf2 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -248,7 +248,7 @@ ValidateMemory(
}
}
if (guard_failed) {
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
fprintf(stderr, "low guard failed at %p, %s %d\n",
memHeaderP->body, file, line);
fflush(stderr); /* In case name pointer is bad. */
@@ -270,7 +270,7 @@ ValidateMemory(
}
if (guard_failed) {
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
fprintf(stderr, "high guard failed at %p, %s %d\n",
memHeaderP->body, file, line);
fflush(stderr); /* In case name pointer is bad. */
@@ -408,7 +408,7 @@ Tcl_DbCkalloc(
}
if (result == NULL) {
fflush(stdout);
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
Tcl_Panic("unable to alloc %" TCL_Z_MODIFIER "u bytes, %s line %d", size, file, line);
}
@@ -498,7 +498,7 @@ Tcl_AttemptDbCkalloc(
}
if (result == NULL) {
fflush(stdout);
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
return NULL;
}
@@ -689,7 +689,7 @@ Tcl_DbCkrealloc(
copySize = memp->length;
}
newPtr = Tcl_DbCkalloc(size, file, line);
- memcpy(newPtr, ptr, (size_t) copySize);
+ memcpy(newPtr, ptr, copySize);
Tcl_DbCkfree(ptr, file, line);
return newPtr;
}
@@ -723,7 +723,7 @@ Tcl_AttemptDbCkrealloc(
if (newPtr == NULL) {
return NULL;
}
- memcpy(newPtr, ptr, (size_t) copySize);
+ memcpy(newPtr, ptr, copySize);
Tcl_DbCkfree(ptr, file, line);
return newPtr;
}
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 22faa16..dc2470c 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -2762,10 +2762,12 @@ CompileEachloopCmd(
Tcl_Obj *varNameObj;
const char *bytes;
int varIndex;
+ size_t length;
+
Tcl_ListObjIndex(NULL, varListObj, j, &varNameObj);
- bytes = TclGetString(varNameObj);
- varIndex = LocalScalar(bytes, varNameObj->length, envPtr);
+ bytes = TclGetStringFromObj(varNameObj, &length);
+ varIndex = LocalScalar(bytes, length, envPtr);
if (varIndex < 0) {
code = TCL_ERROR;
goto done;
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index c790729..ca6629e 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -2636,8 +2636,8 @@ TclCompileSyntaxError(
CompileEnv *envPtr)
{
Tcl_Obj *msg = Tcl_GetObjResult(interp);
- const char *bytes = TclGetString(msg);
- size_t numBytes = msg->length;
+ size_t numBytes;
+ const char *bytes = TclGetStringFromObj(msg, &numBytes);
TclErrorStackResetIf(interp, bytes, numBytes);
TclEmitPush(TclRegisterLiteral(envPtr, bytes, numBytes, 0), envPtr);
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 5325099..d170dca 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -765,7 +765,7 @@ TclCompileStringMatchCmd(
}
str = tokenPtr[1].start;
length = tokenPtr[1].size;
- if ((length <= 1) || strncmp(str, "-nocase", (size_t) length)) {
+ if ((length <= 1) || strncmp(str, "-nocase", length)) {
/*
* Fail at run time, not in compilation.
*/
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 06634e2..3e4441b 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -1560,7 +1560,7 @@ ConvertTreeToTokens(
TclGrowParseTokenArray(parsePtr, toCopy);
subExprTokenPtr = parsePtr->tokenPtr + parsePtr->numTokens;
memcpy(subExprTokenPtr, tokenPtr,
- (size_t) toCopy * sizeof(Tcl_Token));
+ toCopy * sizeof(Tcl_Token));
subExprTokenPtr->type = TCL_TOKEN_SUB_EXPR;
parsePtr->numTokens += toCopy;
} else {
@@ -1577,7 +1577,7 @@ ConvertTreeToTokens(
subExprTokenPtr->numComponents++;
subExprTokenPtr++;
memcpy(subExprTokenPtr, tokenPtr,
- (size_t) toCopy * sizeof(Tcl_Token));
+ toCopy * sizeof(Tcl_Token));
parsePtr->numTokens += toCopy + 1;
}
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index cbdf373..3f28f15 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -769,8 +769,7 @@ TclSetByteCodeFromAny(
}
#endif
- stringPtr = TclGetString(objPtr);
- length = objPtr->length;
+ stringPtr = TclGetStringFromObj(objPtr, &length);
/*
* TIP #280: Pick up the CmdFrame in which the BC compiler was invoked and
@@ -1308,8 +1307,8 @@ CompileSubstObj(
}
if (codePtr == NULL) {
CompileEnv compEnv;
- const char *bytes = TclGetString(objPtr);
- size_t numBytes = objPtr->length;
+ size_t numBytes;
+ const char *bytes = TclGetStringFromObj(objPtr, &numBytes);
/* TODO: Check for more TIP 280 */
TclInitCompileEnv(interp, &compEnv, bytes, numBytes, NULL, 0);
@@ -1791,14 +1790,15 @@ CompileCmdLiteral(
const char *bytes;
Command *cmdPtr;
int cmdLitIdx, extraLiteralFlags = LITERAL_CMD_NAME;
+ size_t length;
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
extraLiteralFlags |= LITERAL_UNSHARED;
}
- bytes = TclGetString(cmdObj);
- cmdLitIdx = TclRegisterLiteral(envPtr, bytes, cmdObj->length, extraLiteralFlags);
+ bytes = TclGetStringFromObj(cmdObj, &length);
+ cmdLitIdx = TclRegisterLiteral(envPtr, bytes, length, extraLiteralFlags);
if (cmdPtr) {
TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLitIdx), cmdPtr);
@@ -2733,8 +2733,8 @@ PreventCycle(
* can be sure we do not have any lingering cycles hiding in
* the intrep.
*/
- const char *bytes = TclGetString(objPtr);
- size_t numBytes = objPtr->length;
+ size_t numBytes;
+ const char *bytes = TclGetStringFromObj(objPtr, &numBytes);
Tcl_Obj *copyPtr = Tcl_NewStringObj(bytes, numBytes);
Tcl_IncrRefCount(copyPtr);
@@ -2819,7 +2819,7 @@ TclInitByteCode(
p += sizeof(ByteCode);
codePtr->codeStart = p;
- memcpy(p, envPtr->codeStart, (size_t) codeBytes);
+ memcpy(p, envPtr->codeStart, codeBytes);
p += TCL_ALIGN(codeBytes); /* align object array */
codePtr->objArrayPtr = (Tcl_Obj **) p;
@@ -2830,7 +2830,7 @@ TclInitByteCode(
p += TCL_ALIGN(objArrayBytes); /* align exception range array */
if (exceptArrayBytes > 0) {
codePtr->exceptArrayPtr = (ExceptionRange *) p;
- memcpy(p, envPtr->exceptArrayPtr, (size_t) exceptArrayBytes);
+ memcpy(p, envPtr->exceptArrayPtr, exceptArrayBytes);
} else {
codePtr->exceptArrayPtr = NULL;
}
@@ -2838,7 +2838,7 @@ TclInitByteCode(
p += TCL_ALIGN(exceptArrayBytes); /* align AuxData array */
if (auxDataArrayBytes > 0) {
codePtr->auxDataArrayPtr = (AuxData *) p;
- memcpy(p, envPtr->auxDataArrayPtr, (size_t) auxDataArrayBytes);
+ memcpy(p, envPtr->auxDataArrayPtr, auxDataArrayBytes);
} else {
codePtr->auxDataArrayPtr = NULL;
}
@@ -2971,8 +2971,7 @@ TclFindCompiledLocal(
varNamePtr = &cachePtr->varName0;
for (i=0; i < cachePtr->numVars; varNamePtr++, i++) {
if (*varNamePtr) {
- localName = TclGetString(*varNamePtr);
- len = (*varNamePtr)->length;
+ localName = TclGetStringFromObj(*varNamePtr, &len);
if ((len == nameBytes) && !strncmp(name, localName, len)) {
return i;
}
@@ -2989,7 +2988,7 @@ TclFindCompiledLocal(
if (!TclIsVarTemporary(localPtr)) {
char *localName = localPtr->name;
- if ((nameBytes == (size_t)localPtr->nameLength) &&
+ if ((nameBytes == localPtr->nameLength) &&
(strncmp(name,localName,nameBytes) == 0)) {
return i;
}
@@ -3022,7 +3021,7 @@ TclFindCompiledLocal(
localPtr->resolveInfo = NULL;
if (name != NULL) {
- memcpy(localPtr->name, name, (size_t) nameBytes);
+ memcpy(localPtr->name, name, nameBytes);
}
localPtr->name[nameBytes] = '\0';
procPtr->numCompiledLocals++;
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index 42b4f87..f9515ae 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -541,13 +541,11 @@ UpdateStringOfDict(
flagPtr[i] = ( i ? TCL_DONT_QUOTE_HASH : 0 );
keyPtr = Tcl_GetHashKey(&dict->table, &cPtr->entry);
- elem = TclGetString(keyPtr);
- length = keyPtr->length;
+ elem = TclGetStringFromObj(keyPtr, &length);
bytesNeeded += TclScanElement(elem, length, flagPtr+i);
flagPtr[i+1] = TCL_DONT_QUOTE_HASH;
valuePtr = Tcl_GetHashValue(&cPtr->entry);
- elem = TclGetString(valuePtr);
- length = valuePtr->length;
+ elem = TclGetStringFromObj(valuePtr, &length);
bytesNeeded += TclScanElement(elem, length, flagPtr+i+1);
}
bytesNeeded += numElems;
@@ -561,15 +559,13 @@ UpdateStringOfDict(
for (i=0,cPtr=dict->entryChainHead; i<numElems; i+=2,cPtr=cPtr->nextPtr) {
flagPtr[i] |= ( i ? TCL_DONT_QUOTE_HASH : 0 );
keyPtr = Tcl_GetHashKey(&dict->table, &cPtr->entry);
- elem = TclGetString(keyPtr);
- length = keyPtr->length;
+ elem = TclGetStringFromObj(keyPtr, &length);
dst += TclConvertElement(elem, length, dst, flagPtr[i]);
*dst++ = ' ';
flagPtr[i+1] |= TCL_DONT_QUOTE_HASH;
valuePtr = Tcl_GetHashValue(&cPtr->entry);
- elem = TclGetString(valuePtr);
- length = valuePtr->length;
+ elem = TclGetStringFromObj(valuePtr, &length);
dst += TclConvertElement(elem, length, dst, flagPtr[i+1]);
*dst++ = ' ';
}
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 6abefa9..c477ca0 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -3620,9 +3620,7 @@ InitializeEncodingSearchPath(
if (*encodingPtr) {
((Encoding *)(*encodingPtr))->refCount++;
}
- bytes = TclGetString(searchPathObj);
-
- *lengthPtr = searchPathObj->length;
+ bytes = TclGetStringFromObj(searchPathObj, lengthPtr);
*valuePtr = Tcl_Alloc(*lengthPtr + 1);
memcpy(*valuePtr, bytes, *lengthPtr + 1);
Tcl_DecrRefCount(searchPathObj);
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index 870c6b0..1889475 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -1811,8 +1811,7 @@ NsEnsembleImplementationCmdNR(
size_t tableLength = ensemblePtr->subcommandTable.numEntries;
Tcl_Obj *fix;
- subcmdName = TclGetString(subObj);
- stringLength = subObj->length;
+ subcmdName = TclGetStringFromObj(subObj, &stringLength);
for (i=0 ; i<tableLength ; i++) {
register int cmp = strncmp(subcmdName,
ensemblePtr->subcommandArrayPtr[i],
@@ -3379,6 +3378,7 @@ CompileToInvokedCommand(
Tcl_Obj *objPtr, **words;
char *bytes;
int i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
+ size_t length;
DefineLineInformation;
/*
@@ -3391,8 +3391,8 @@ CompileToInvokedCommand(
for (i = 0, tokPtr = parsePtr->tokenPtr; i < parsePtr->numWords;
i++, tokPtr = TokenAfter(tokPtr)) {
if (i > 0 && i < numWords+1) {
- bytes = TclGetString(words[i-1]);
- PushLiteral(envPtr, bytes, words[i-1]->length);
+ bytes = TclGetStringFromObj(words[i-1], &length);
+ PushLiteral(envPtr, bytes, length);
continue;
}
@@ -3420,11 +3420,11 @@ CompileToInvokedCommand(
objPtr = Tcl_NewObj();
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, objPtr);
- bytes = TclGetString(objPtr);
+ bytes = TclGetStringFromObj(objPtr, &length);
if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
extraLiteralFlags |= LITERAL_UNSHARED;
}
- cmdLit = TclRegisterLiteral(envPtr, bytes, objPtr->length, extraLiteralFlags);
+ cmdLit = TclRegisterLiteral(envPtr, bytes, length, extraLiteralFlags);
TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLit), cmdPtr);
TclEmitPush(cmdLit, envPtr);
TclDecrRefCount(objPtr);
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index b4a62b9..445b345 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -441,12 +441,12 @@ TclUnsetEnv(
#if defined(_WIN32)
string = Tcl_Alloc(length + 2);
- memcpy(string, name, (size_t) length);
+ memcpy(string, name, length);
string[length] = '=';
string[length+1] = '\0';
#else
string = Tcl_Alloc(length + 1);
- memcpy(string, name, (size_t) length);
+ memcpy(string, name, length);
string[length] = '\0';
#endif /* _WIN32 */
@@ -691,7 +691,7 @@ ReplaceString(
(env.cacheSize + growth) * sizeof(char *));
env.cache[env.cacheSize] = newStr;
(void) memset(env.cache+env.cacheSize+1, 0,
- (size_t) (growth-1) * sizeof(char *));
+ (growth-1) * sizeof(char *));
env.cacheSize += growth;
}
}
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index c1b85ad..4b9114f 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1415,10 +1415,11 @@ CompileExprObj(
* TIP #280: No invoker (yet) - Expression compilation.
*/
- const char *string = TclGetString(objPtr);
+ size_t length;
+ const char *string = TclGetStringFromObj(objPtr, &length);
- TclInitCompileEnv(interp, &compEnv, string, objPtr->length, NULL, 0);
- TclCompileExpr(interp, string, objPtr->length, &compEnv, 0);
+ TclInitCompileEnv(interp, &compEnv, string, length, NULL, 0);
+ TclCompileExpr(interp, string, length, &compEnv, 0);
/*
* Successful compilation. If the expression yielded no instructions,
@@ -4524,8 +4525,8 @@ TEBCresume(
{
int index, numIndices, fromIdx, toIdx;
- int nocase, match, cflags, s1len, s2len;
- size_t slength, length2;
+ int nocase, match, cflags;
+ size_t slength, length2, s1len, s2len;
const char *s1, *s2;
case INST_LIST:
@@ -4799,8 +4800,7 @@ TEBCresume(
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
- s1 = TclGetString(valuePtr);
- s1len = valuePtr->length;
+ s1 = TclGetStringFromObj(valuePtr, &s1len);
TRACE(("\"%.30s\" \"%.30s\" => ", O2S(valuePtr), O2S(value2Ptr)));
if (TclListObjLength(interp, value2Ptr, &length) != TCL_OK) {
TRACE_ERROR(interp);
@@ -4818,8 +4818,7 @@ TEBCresume(
do {
Tcl_ListObjIndex(NULL, value2Ptr, i, &o);
if (o != NULL) {
- s2 = TclGetString(o);
- s2len = o->length;
+ s2 = TclGetStringFromObj(o, &s2len);
} else {
s2 = "";
s2len = 0;
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index 5d0cff6..48544f3 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.c
@@ -598,7 +598,7 @@ Tcl_SplitPath(
for (i = 0; i < *argcPtr; i++) {
Tcl_ListObjIndex(NULL, resultPtr, i, &eltPtr);
str = TclGetStringFromObj(eltPtr, &len);
- memcpy(p, str, (size_t) len+1);
+ memcpy(p, str, len+1);
p += len+1;
}
diff --git a/generic/tclIO.c b/generic/tclIO.c
index b80739f..f6119df 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -1563,7 +1563,7 @@ TclGetChannelFromObj(
* Re-use the ResolvedCmdName struct.
*/
- Tcl_Release((ClientData) resPtr->statePtr);
+ Tcl_Release(resPtr->statePtr);
} else {
resPtr = (ResolvedChanName *) Tcl_Alloc(sizeof(ResolvedChanName));
resPtr->refCount = 0;
@@ -1571,7 +1571,7 @@ TclGetChannelFromObj(
}
statePtr = ((Channel *)chan)->state;
resPtr->statePtr = statePtr;
- Tcl_Preserve((ClientData) statePtr);
+ Tcl_Preserve(statePtr);
resPtr->interp = interp;
resPtr->epoch = statePtr->epoch;
@@ -4321,7 +4321,7 @@ Write(
* that we need to stick at the beginning of this buffer.
*/
- memcpy(InsertPoint(bufPtr), safe, (size_t) saved);
+ memcpy(InsertPoint(bufPtr), safe, saved);
bufPtr->nextAdded += saved;
saved = 0;
}
@@ -4409,7 +4409,7 @@ Write(
*/
saved = -SpaceLeft(bufPtr);
- memcpy(safe, dst + dstLen, (size_t) saved);
+ memcpy(safe, dst + dstLen, saved);
bufPtr->nextAdded = bufPtr->bufLength;
}
@@ -4719,7 +4719,7 @@ Tcl_GetsObj(
gs.rawRead -= rawRead;
gs.bytesWrote--;
gs.charsWrote--;
- memmove(dst, dst + 1, (size_t) (dstEnd - dst));
+ memmove(dst, dst + 1, dstEnd - dst);
dstEnd--;
}
}
@@ -5089,7 +5089,7 @@ TclGetsObjBinary(
rawLen = dstEnd - dst;
byteArray = Tcl_SetByteArrayLength(objPtr, byteLen + rawLen);
- memcpy(byteArray + byteLen, dst, (size_t) rawLen);
+ memcpy(byteArray + byteLen, dst, rawLen);
byteLen += rawLen;
}
@@ -5106,7 +5106,7 @@ TclGetsObjBinary(
rawLen = eol - dst;
byteArray = Tcl_SetByteArrayLength(objPtr, byteLen + rawLen);
- memcpy(byteArray + byteLen, dst, (size_t) rawLen);
+ memcpy(byteArray + byteLen, dst, rawLen);
byteLen += rawLen;
bufPtr->nextRemoved += rawLen + skip;
@@ -5402,7 +5402,7 @@ FilterInputBytes(
}
extra = rawLen - gsPtr->rawRead;
memcpy(nextPtr->buf + (BUFFER_PADDING - extra),
- raw + gsPtr->rawRead, (size_t) extra);
+ raw + gsPtr->rawRead, extra);
nextPtr->nextRemoved -= extra;
bufPtr->nextAdded -= extra;
}
@@ -5657,7 +5657,7 @@ Tcl_ReadRaw(
* Copy the current chunk into the read buffer.
*/
- memcpy(readBuf, RemovePoint(bufPtr), (size_t) toCopy);
+ memcpy(readBuf, RemovePoint(bufPtr), toCopy);
bufPtr->nextRemoved += toCopy;
copied += toCopy;
readBuf += toCopy;
@@ -6406,7 +6406,7 @@ ReadChars(
}
nextPtr->nextRemoved -= srcLen;
- memcpy(RemovePoint(nextPtr), src, (size_t) srcLen);
+ memcpy(RemovePoint(nextPtr), src, srcLen);
RecycleBuffer(statePtr, bufPtr, 0);
statePtr->inQueueHead = nextPtr;
Tcl_SetObjLength(objPtr, numBytes);
@@ -6512,7 +6512,7 @@ TranslateInputEOL(
case TCL_TRANSLATE_LF:
case TCL_TRANSLATE_CR:
if (dstStart != srcStart) {
- memcpy(dstStart, srcStart, (size_t) srcLen);
+ memcpy(dstStart, srcStart, srcLen);
}
if (statePtr->inputTranslation == TCL_TRANSLATE_CR) {
char *dst = dstStart;
@@ -10406,7 +10406,7 @@ Tcl_IsChannelExisting(
}
if ((*chanName == *name) &&
- (memcmp(name, chanName, (size_t) chanNameLen + 1) == 0)) {
+ (memcmp(name, chanName, chanNameLen + 1) == 0)) {
return 1;
}
}
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index 3769533..31ed8d4 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -2607,7 +2607,7 @@ ForwardProc(
if (bytec > 0) {
paramPtr->transform.buf = Tcl_Alloc(bytec);
- memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
+ memcpy(paramPtr->transform.buf, bytev, bytec);
} else {
paramPtr->transform.buf = NULL;
}
@@ -2641,7 +2641,7 @@ ForwardProc(
if (bytec > 0) {
paramPtr->transform.buf = Tcl_Alloc(bytec);
- memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
+ memcpy(paramPtr->transform.buf, bytev, bytec);
} else {
paramPtr->transform.buf = NULL;
}
@@ -2670,7 +2670,7 @@ ForwardProc(
if (bytec > 0) {
paramPtr->transform.buf = Tcl_Alloc(bytec);
- memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
+ memcpy(paramPtr->transform.buf, bytev, bytec);
} else {
paramPtr->transform.buf = NULL;
}
@@ -2697,7 +2697,7 @@ ForwardProc(
if (bytec > 0) {
paramPtr->transform.buf = Tcl_Alloc(bytec);
- memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
+ memcpy(paramPtr->transform.buf, bytev, bytec);
} else {
paramPtr->transform.buf = NULL;
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 08f0606..b70e9b8 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -921,7 +921,7 @@ typedef struct CompiledLocal {
/* Next compiler-recognized local variable for
* this procedure, or NULL if this is the last
* local. */
- int nameLength; /* The number of bytes in local variable's name.
+ size_t nameLength; /* The number of bytes in local variable's name.
* Among others used to speed up var lookups. */
int frameIndex; /* Index in the array of compiler-assigned
* variables in the procedure call frame. */
@@ -2448,7 +2448,7 @@ typedef struct List {
(((objPtr)->typePtr == &tclIntType \
&& (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(INT_MAX)) \
? ((*(idxPtr) = ((objPtr)->internalRep.wideValue >= 0) \
- ? (int)(objPtr)->internalRep.wideValue : -1), TCL_OK) \
+ ? (int)(objPtr)->internalRep.wideValue : TCL_INDEX_NONE), TCL_OK) \
: TclGetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
/*
@@ -3179,7 +3179,7 @@ MODULE_SCOPE void TclRegisterCommandTypeName(
const char *nameStr);
MODULE_SCOPE int TclUtfCmp(const char *cs, const char *ct);
MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct);
-MODULE_SCOPE int TclUtfCount(int ch);
+MODULE_SCOPE size_t TclUtfCount(int ch);
MODULE_SCOPE Tcl_Obj * TclpNativeToNormalized(void *clientData);
MODULE_SCOPE Tcl_Obj * TclpFilesystemPathType(Tcl_Obj *pathPtr);
MODULE_SCOPE int TclpDlopen(Tcl_Interp *interp, Tcl_Obj *pathPtr,
@@ -4382,11 +4382,10 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
*(lenPtr) = *((size_t *) (objPtr)->internalRep.twoPtrValue.ptr1);
return response;
}
-
#else
#define TclGetStringFromObj(objPtr, lenPtr) \
(((objPtr)->bytes \
- ? 0 : Tcl_GetString((objPtr)), \
+ ? NULL : Tcl_GetString((objPtr)), \
*(lenPtr) = (objPtr)->length, (objPtr)->bytes))
#define TclGetUnicodeFromObj(objPtr, lenPtr) \
(Tcl_GetUnicodeFromObj(objPtr, NULL), \
@@ -4395,7 +4394,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
#define TclGetByteArrayFromObj(objPtr, lenPtr) \
(Tcl_GetByteArrayFromObj(objPtr, NULL), \
*(lenPtr) = *((size_t *) (objPtr)->internalRep.twoPtrValue.ptr1), \
- (unsigned char *)(((size_t *) (objPtr)->internalRep.twoPtrValue.ptr1) + 2))
+ (unsigned char *)(((size_t *) (objPtr)->internalRep.twoPtrValue.ptr1) + 2))
#endif
/*
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 6b28ff2..a5ce1af 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -1831,8 +1831,8 @@ AliasNRCmd(
cmdv = &listRep->elements;
prefv = &aliasPtr->objPtr;
- memcpy(cmdv, prefv, (size_t) (prefc * sizeof(Tcl_Obj *)));
- memcpy(cmdv+prefc, objv+1, (size_t) ((objc-1) * sizeof(Tcl_Obj *)));
+ memcpy(cmdv, prefv, prefc * sizeof(Tcl_Obj *));
+ memcpy(cmdv+prefc, objv+1, (objc-1) * sizeof(Tcl_Obj *));
for (i=0; i<cmdc; i++) {
Tcl_IncrRefCount(cmdv[i]);
@@ -1880,8 +1880,8 @@ TclAliasObjCmd(
cmdv = TclStackAlloc(interp, cmdc * sizeof(Tcl_Obj *));
}
- memcpy(cmdv, prefv, (size_t) (prefc * sizeof(Tcl_Obj *)));
- memcpy(cmdv+prefc, objv+1, (size_t) ((objc-1) * sizeof(Tcl_Obj *)));
+ memcpy(cmdv, prefv, prefc * sizeof(Tcl_Obj *));
+ memcpy(cmdv+prefc, objv+1, (objc-1) * sizeof(Tcl_Obj *));
Tcl_ResetResult(targetInterp);
@@ -1970,8 +1970,8 @@ TclLocalAliasObjCmd(
cmdv = TclStackAlloc(interp, cmdc * sizeof(Tcl_Obj *));
}
- memcpy(cmdv, prefv, (size_t) (prefc * sizeof(Tcl_Obj *)));
- memcpy(cmdv+prefc, objv+1, (size_t) ((objc-1) * sizeof(Tcl_Obj *)));
+ memcpy(cmdv, prefv, prefc * sizeof(Tcl_Obj *));
+ memcpy(cmdv+prefc, objv+1, (objc-1) * sizeof(Tcl_Obj *));
for (i=0; i<cmdc; i++) {
Tcl_IncrRefCount(cmdv[i]);
diff --git a/generic/tclLink.c b/generic/tclLink.c
index 1ca9215..c336393 100644
--- a/generic/tclLink.c
+++ b/generic/tclLink.c
@@ -545,11 +545,10 @@ LinkTraceProc(
break;
case TCL_LINK_STRING:
- value = TclGetString(valueObj);
- valueLength = valueObj->length + 1;
+ value = TclGetStringFromObj(valueObj, &valueLength);
pp = (char **) linkPtr->addr;
- *pp = Tcl_Realloc(*pp, valueLength);
+ *pp = Tcl_Realloc(*pp, ++valueLength);
memcpy(*pp, value, valueLength);
break;
@@ -660,16 +659,16 @@ static Tcl_ObjType invalidRealType = {
static int
SetInvalidRealFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) {
- const char *str;
- const char *endPtr;
+ size_t length;
+ const char *str, *endPtr;
- str = TclGetString(objPtr);
- if ((objPtr->length == 1) && (str[0] == '.')){
+ str = TclGetStringFromObj(objPtr, &length);
+ if ((length == 1) && (str[0] == '.')){
objPtr->typePtr = &invalidRealType;
objPtr->internalRep.doubleValue = 0.0;
return TCL_OK;
}
- if (TclParseNumber(NULL, objPtr, NULL, str, objPtr->length, &endPtr,
+ if (TclParseNumber(NULL, objPtr, NULL, str, length, &endPtr,
TCL_PARSE_DECIMAL_ONLY) == TCL_OK) {
/* If number is followed by [eE][+-]?, then it is an invalid
* double, but it could be the start of a valid double. */
@@ -699,13 +698,14 @@ SetInvalidRealFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) {
int
GetInvalidIntFromObj(Tcl_Obj *objPtr, int *intPtr)
{
- const char *str = TclGetString(objPtr);
+ size_t length;
+ const char *str = TclGetStringFromObj(objPtr, &length);
- if ((objPtr->length == 0) ||
- ((objPtr->length == 2) && (str[0] == '0') && strchr("xXbBoOdD", str[1]))) {
+ if ((length == 0) ||
+ ((length == 2) && (str[0] == '0') && strchr("xXbBoOdD", str[1]))) {
*intPtr = 0;
return TCL_OK;
- } else if ((objPtr->length == 1) && strchr("+-", str[0])) {
+ } else if ((length == 1) && strchr("+-", str[0])) {
*intPtr = (str[0] == '+');
return TCL_OK;
}
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index 3ece98b..8c85bbe 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -213,7 +213,7 @@ TclCreateLiteral(
if ((objLength == length) && ((length == 0)
|| ((objBytes[0] == bytes[0])
- && (memcmp(objBytes, bytes, (unsigned) length) == 0)))) {
+ && (memcmp(objBytes, bytes, length) == 0)))) {
/*
* A literal was found: return it
*/
@@ -422,7 +422,7 @@ TclRegisterLiteral(
for (localPtr=localTablePtr->buckets[localHash] ; localPtr!=NULL;
localPtr = localPtr->nextPtr) {
objPtr = localPtr->objPtr;
- if (((size_t)objPtr->length == length) && ((length == 0)
+ if ((objPtr->length == length) && ((length == 0)
|| ((objPtr->bytes[0] == bytes[0])
&& (memcmp(objPtr->bytes, bytes, length) == 0)))) {
if ((flags & LITERAL_ON_HEAP)) {
@@ -504,10 +504,10 @@ LookupLiteralEntry(
LiteralTable *globalTablePtr = &iPtr->literalTable;
register LiteralEntry *entryPtr;
const char *bytes;
- size_t globalHash;
+ size_t globalHash, length;
- bytes = TclGetString(objPtr);
- globalHash = (HashString(bytes, objPtr->length) & globalTablePtr->mask);
+ bytes = TclGetStringFromObj(objPtr, &length);
+ globalHash = (HashString(bytes, length) & globalTablePtr->mask);
for (entryPtr=globalTablePtr->buckets[globalHash] ; entryPtr!=NULL;
entryPtr=entryPtr->nextPtr) {
if (entryPtr->objPtr == objPtr) {
@@ -549,8 +549,7 @@ TclHideLiteral(
{
LiteralEntry **nextPtrPtr, *entryPtr, *lPtr;
LiteralTable *localTablePtr = &envPtr->localLitTable;
- size_t localHash;
- size_t length;
+ size_t localHash, length;
const char *bytes;
Tcl_Obj *newObjPtr;
@@ -568,8 +567,7 @@ TclHideLiteral(
TclReleaseLiteral(interp, lPtr->objPtr);
lPtr->objPtr = newObjPtr;
- bytes = TclGetString(newObjPtr);
- length = newObjPtr->length;
+ bytes = TclGetStringFromObj(newObjPtr, &length);
localHash = HashString(bytes, length) & localTablePtr->mask;
nextPtrPtr = &localTablePtr->buckets[localHash];
@@ -702,8 +700,7 @@ AddLocalLiteralEntry(
}
if (!found) {
- bytes = TclGetString(objPtr);
- length = objPtr->length;
+ bytes = TclGetStringFromObj(objPtr, &length);
Tcl_Panic("%s: literal \"%.*s\" wasn't found locally",
"AddLocalLiteralEntry", (length>60? 60 : (int)length), bytes);
}
@@ -832,8 +829,7 @@ TclReleaseLiteral(
}
globalTablePtr = &iPtr->literalTable;
- bytes = TclGetString(objPtr);
- length = objPtr->length;
+ bytes = TclGetStringFromObj(objPtr, &length);
index = HashString(bytes, length) & globalTablePtr->mask;
/*
@@ -1004,8 +1000,7 @@ RebuildLiteralTable(
for (oldChainPtr=oldBuckets ; oldSize>0 ; oldSize--,oldChainPtr++) {
for (entryPtr=*oldChainPtr ; entryPtr!=NULL ; entryPtr=*oldChainPtr) {
- bytes = TclGetString(entryPtr->objPtr);
- length = entryPtr->objPtr->length;
+ bytes = TclGetStringFromObj(entryPtr->objPtr, &length);
index = (HashString(bytes, length) & tablePtr->mask);
*oldChainPtr = entryPtr->nextPtr;
@@ -1176,8 +1171,7 @@ TclVerifyLocalLiteralTable(
localPtr=localPtr->nextPtr) {
count++;
if (localPtr->refCount != TCL_AUTO_LENGTH) {
- bytes = TclGetString(localPtr->objPtr);
- length = localPtr->objPtr->length;
+ bytes = TclGetStringFromObj(localPtr->objPtr, &length);
Tcl_Panic("%s: local literal \"%.*s\" had bad refCount %" TCL_Z_MODIFIER "u",
"TclVerifyLocalLiteralTable",
(length>60? 60 : (int) length), bytes, localPtr->refCount);
@@ -1226,8 +1220,7 @@ TclVerifyGlobalLiteralTable(
globalPtr=globalPtr->nextPtr) {
count++;
if (globalPtr->refCount + 1 < 2) {
- bytes = TclGetString(globalPtr->objPtr);
- length = globalPtr->objPtr->length;
+ bytes = TclGetStringFromObj(globalPtr->objPtr, &length);
Tcl_Panic("%s: global literal \"%.*s\" had bad refCount %" TCL_Z_MODIFIER "d",
"TclVerifyGlobalLiteralTable",
(length>60? 60 : (int)length), bytes, globalPtr->refCount);
diff --git a/generic/tclObj.c b/generic/tclObj.c
index d6a6c80..5cf35b4 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -1396,7 +1396,7 @@ TclFreeObj(
*/
TclInvalidateStringRep(objPtr);
- objPtr->length = -1;
+ objPtr->length = TCL_AUTO_LENGTH;
if (!objPtr->typePtr || !objPtr->typePtr->freeIntRepProc) {
/*
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 7259567..a3defec 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -927,7 +927,7 @@ TclParseBackslash(
} else {
char utfBytes[TCL_UTF_MAX];
- memcpy(utfBytes, p, (size_t) (numBytes - 1));
+ memcpy(utfBytes, p, numBytes - 1);
utfBytes[numBytes - 1] = '\0';
count = TclUtfToUniChar(utfBytes, &unichar) + 1;
}
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index b500c7e..4344c2d 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -576,8 +576,8 @@ TclPathPart(
* the standardPath code.
*/
- const char *rest = TclGetString(fsPathPtr->normPathPtr);
- size_t numBytes = fsPathPtr->normPathPtr->length;
+ size_t numBytes;
+ const char *rest = TclGetStringFromObj(fsPathPtr->normPathPtr, &numBytes);
if (strchr(rest, '/') != NULL) {
goto standardPath;
@@ -613,8 +613,8 @@ TclPathPart(
* we don't, and instead just use the standardPath code.
*/
- const char *rest = TclGetString(fsPathPtr->normPathPtr);
- size_t numBytes = fsPathPtr->normPathPtr->length;
+ size_t numBytes;
+ const char *rest = TclGetStringFromObj(fsPathPtr->normPathPtr, &numBytes);
if (strchr(rest, '/') != NULL) {
goto standardPath;
@@ -1362,6 +1362,7 @@ AppendPath(
{
const char *bytes;
Tcl_Obj *copy = Tcl_DuplicateObj(head);
+ size_t length;
/*
* This is likely buggy when dealing with virtual filesystem drivers
@@ -1371,8 +1372,8 @@ AppendPath(
* intrep produce the same results; that is, bugward compatibility. If
* we need to fix that bug here, it needs fixing in TclJoinPath() too.
*/
- bytes = TclGetString(tail);
- if (tail->length == 0) {
+ bytes = TclGetStringFromObj(tail, &length);
+ if (length == 0) {
Tcl_AppendToObj(copy, "/", 1);
} else {
TclpNativeJoinPath(copy, bytes);
diff --git a/generic/tclProc.c b/generic/tclProc.c
index d12e0f2..f2a52a7 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -354,8 +354,7 @@ Tcl_ProcObjCmd(
* The argument list is just "args"; check the body
*/
- procBody = TclGetString(objv[3]);
- numBytes = objv[3]->length;
+ procBody = TclGetStringFromObj(objv[3], &numBytes);
if (TclParseAllWhiteSpace(procBody, numBytes) < numBytes) {
goto done;
}
@@ -510,7 +509,8 @@ TclCreateProc(
for (i = 0; i < numArgs; i++) {
const char *argname, *argnamei, *argnamelast;
- int fieldCount, nameLength;
+ int fieldCount;
+ size_t nameLength;
Tcl_Obj **fieldValues;
/*
@@ -602,10 +602,9 @@ TclCreateProc(
*/
if (localPtr->defValuePtr != NULL) {
- const char *tmpPtr = TclGetString(localPtr->defValuePtr);
- size_t tmpLength = localPtr->defValuePtr->length;
- const char *value = TclGetString(fieldValues[1]);
- size_t valueLength = fieldValues[1]->length;
+ size_t tmpLength, valueLength;
+ const char *tmpPtr = TclGetStringFromObj(localPtr->defValuePtr, &tmpLength);
+ const char *value = TclGetStringFromObj(fieldValues[1], &valueLength);
if ((valueLength != tmpLength)
|| memcmp(value, tmpPtr, tmpLength) != 0
diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c
index 65bc94e..5a4638d 100644
--- a/generic/tclRegexp.c
+++ b/generic/tclRegexp.c
@@ -264,7 +264,7 @@ Tcl_RegExpRange(
if (index > regexpPtr->re.re_nsub) {
*startPtr = *endPtr = NULL;
- } else if (regexpPtr->matches[index].rm_so < 0) {
+ } else if (regexpPtr->matches[index].rm_so == (size_t)-1) {
*startPtr = *endPtr = NULL;
} else {
if (regexpPtr->objPtr) {
diff --git a/generic/tclResult.c b/generic/tclResult.c
index a4df031..e7cc40f 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -383,12 +383,13 @@ Tcl_AppendElement(
Tcl_Obj *elementPtr = Tcl_NewStringObj(element, -1);
Tcl_Obj *listPtr = Tcl_NewListObj(1, &elementPtr);
const char *bytes;
+ size_t length;
if (Tcl_IsShared(iPtr->objResultPtr)) {
Tcl_SetObjResult(interp, Tcl_DuplicateObj(iPtr->objResultPtr));
}
- bytes = TclGetString(iPtr->objResultPtr);
- if (TclNeedSpace(bytes, bytes+iPtr->objResultPtr->length)) {
+ bytes = TclGetStringFromObj(iPtr->objResultPtr, &length);
+ if (TclNeedSpace(bytes, bytes + length)) {
Tcl_AppendToObj(iPtr->objResultPtr, " ", 1);
}
Tcl_AppendObjToObj(iPtr->objResultPtr, listPtr);
@@ -778,8 +779,10 @@ TclProcessReturn(
Tcl_DictObjGet(NULL, iPtr->returnOpts, keys[KEY_ERRORINFO],
&valuePtr);
if (valuePtr != NULL) {
- (void) TclGetString(valuePtr);
- if (valuePtr->length) {
+ size_t length;
+
+ (void) TclGetStringFromObj(valuePtr, &length);
+ if (length) {
iPtr->errorInfo = valuePtr;
Tcl_IncrRefCount(iPtr->errorInfo);
iPtr->flags |= ERR_ALREADY_LOGGED;
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 0bae9f0..c8a87b2 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -141,10 +141,8 @@ GrowStringBuffer(
objPtr->bytes = NULL;
}
if (flag == 0 || stringPtr->allocated > 0) {
- if (needed <= STRING_MAXCHARS / 2) {
- attempt = 2 * needed;
- ptr = Tcl_AttemptRealloc(objPtr->bytes, attempt + 1);
- }
+ attempt = 2 * needed;
+ ptr = Tcl_AttemptRealloc(objPtr->bytes, attempt + 1);
if (ptr == NULL) {
/*
* Take care computing the amount of modest growth to avoid
@@ -180,7 +178,6 @@ GrowUnicodeBuffer(
* Pre-conditions:
* objPtr->typePtr == &tclStringType
* needed > stringPtr->maxChars
- * needed < STRING_MAXCHARS
*/
String *ptr = NULL, *stringPtr = GET_STRING(objPtr);
@@ -191,22 +188,18 @@ GrowUnicodeBuffer(
* Subsequent appends - apply the growth algorithm.
*/
- if (needed <= STRING_MAXCHARS / 2) {
- attempt = 2 * needed;
- ptr = stringAttemptRealloc(stringPtr, attempt);
- }
+ attempt = 2 * needed;
+ ptr = stringAttemptRealloc(stringPtr, attempt);
if (ptr == NULL) {
/*
* Take care computing the amount of modest growth to avoid
* overflow into invalid argument values for attempt.
*/
- size_t limit = STRING_MAXCHARS - needed;
size_t extra = needed - stringPtr->numChars
+ TCL_MIN_UNICHAR_GROWTH;
- size_t growth = (extra > limit) ? limit : extra;
- attempt = needed + growth;
+ attempt = needed + extra;
ptr = stringAttemptRealloc(stringPtr, attempt);
}
}
@@ -854,11 +847,6 @@ Tcl_SetObjLength(
stringPtr->numChars = TCL_AUTO_LENGTH;
stringPtr->hasUnicode = 0;
} else {
- /*
- * Changing length of pure unicode string.
- */
-
- stringCheckLimits(length);
if (length > stringPtr->maxChars) {
stringPtr = stringRealloc(stringPtr, length);
SET_STRING(objPtr, stringPtr);
@@ -960,9 +948,6 @@ Tcl_AttemptSetObjLength(
* Changing length of pure unicode string.
*/
- if (length > STRING_MAXCHARS) {
- return 0;
- }
if (length > stringPtr->maxChars) {
stringPtr = stringAttemptRealloc(stringPtr, length);
if (stringPtr == NULL) {
@@ -1030,7 +1015,6 @@ UnicodeLength(
numChars++;
}
}
- stringCheckLimits(numChars);
return numChars;
}
@@ -1052,7 +1036,6 @@ SetUnicodeObj(
* Allocate enough space for the String structure + Unicode string.
*/
- stringCheckLimits(numChars);
stringPtr = stringAlloc(numChars);
SET_STRING(objPtr, stringPtr);
objPtr->typePtr = &tclStringType;
@@ -1419,7 +1402,6 @@ AppendUnicodeToUnicodeRep(
*/
numChars = stringPtr->numChars + appendNumChars;
- stringCheckLimits(numChars);
if (numChars > stringPtr->maxChars) {
size_t offset = TCL_AUTO_LENGTH;
@@ -3004,7 +2986,7 @@ TclStringCat(
if ((objPtr->bytes == NULL) || (objPtr->length)) {
size_t numChars;
- TclGetUnicodeFromObj(objPtr, &numChars); /* PANIC? */
+ (void)TclGetUnicodeFromObj(objPtr, &numChars); /* PANIC? */
if (numChars) {
last = objc - oc;
if (length == 0) {
@@ -3061,8 +3043,7 @@ TclStringCat(
do {
Tcl_Obj *objPtr = *ov++;
- TclGetString(objPtr); /* PANIC? */
- numBytes = objPtr->length;
+ (void)TclGetStringFromObj(objPtr, &numBytes); /* PANIC? */
} while (--oc && numBytes == 0 && pendingPtr->bytes == NULL);
if (numBytes) {
@@ -3154,7 +3135,7 @@ TclStringCat(
objResultPtr = *objv++; objc--;
/* Ugly interface! Force resize of the unicode array. */
- TclGetUnicodeFromObj(objResultPtr, &start);
+ (void)TclGetUnicodeFromObj(objResultPtr, &start);
Tcl_InvalidateStringRep(objResultPtr);
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
if (interp) {
@@ -3239,7 +3220,7 @@ TclStringCat(
size_t more;
char *src = TclGetStringFromObj(objPtr, &more);
- memcpy(dst, src, (size_t) more);
+ memcpy(dst, src, more);
dst += more;
}
}
@@ -3429,7 +3410,7 @@ TclStringCmp(
* length only.
*/
- match = memCmpFn(s1, s2, (size_t) length);
+ match = memCmpFn(s1, s2, length);
}
if ((match == 0) && (reqlength > length)) {
match = s1len - s2len;
@@ -3959,7 +3940,6 @@ ExtendUnicodeRepWithString(
TclNumUtfChars(numAppendChars, bytes, numBytes);
}
needed = numOrigChars + numAppendChars;
- stringCheckLimits(needed);
if (needed > stringPtr->maxChars) {
GrowUnicodeBuffer(objPtr, needed);
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index a8b3b08..73ccad6 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -31,6 +31,10 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
+
+#ifndef _TCLSTRINGREP
+#define _TCLSTRINGREP
+
/*
* The following structure is the internal rep for a String object. It keeps
@@ -64,17 +68,8 @@ typedef struct {
* field above. */
} String;
-#define STRING_MAXCHARS \
- ((UINT_MAX - sizeof(String))/sizeof(Tcl_UniChar))
#define STRING_SIZE(numChars) \
(sizeof(String) + ((numChars) * sizeof(Tcl_UniChar)))
-#define stringCheckLimits(numChars) \
- do { \
- if ((size_t)(numChars) > STRING_MAXCHARS) { \
- Tcl_Panic("max length for a Tcl unicode value (%" TCL_Z_MODIFIER "u chars) exceeded", \
- STRING_MAXCHARS); \
- } \
- } while (0)
#define stringAttemptAlloc(numChars) \
(String *) Tcl_AttemptAlloc(STRING_SIZE(numChars))
#define stringAlloc(numChars) \
@@ -89,6 +84,7 @@ typedef struct {
((objPtr)->internalRep.twoPtrValue.ptr2 = NULL), \
((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (stringPtr))
+#endif /* _TCLSTRINGREP */
/*
* Local Variables:
* mode: c
diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c
index db4ee0d..64858cb 100644
--- a/generic/tclThreadTest.c
+++ b/generic/tclThreadTest.c
@@ -294,7 +294,7 @@ ThreadObjCmd(
script = Tcl_GetStringFromObj(objv[2], &len);
if ((len > 1) && (script[0] == '-') && (script[1] == 'j') &&
- (0 == strncmp(script, "-joinable", (size_t) len))) {
+ (0 == strncmp(script, "-joinable", len))) {
joinable = 1;
script = "testthread wait"; /* Just enter event loop */
} else {
@@ -311,7 +311,7 @@ ThreadObjCmd(
script = Tcl_GetStringFromObj(objv[2], &len);
joinable = ((len > 1) && (script[0] == '-') && (script[1] == 'j')
- && (0 == strncmp(script, "-joinable", (size_t) len)));
+ && (0 == strncmp(script, "-joinable", len)));
script = Tcl_GetString(objv[3]);
} else {
Tcl_WrongNumArgs(interp, 2, objv, "?-joinable? ?script?");
diff --git a/generic/tclTrace.c b/generic/tclTrace.c
index c60babb..7932b50 100644
--- a/generic/tclTrace.c
+++ b/generic/tclTrace.c
@@ -1306,7 +1306,7 @@ TraceCommandProc(
*/
Tcl_DStringInit(&cmd);
- Tcl_DStringAppend(&cmd, tcmdPtr->command, (int) tcmdPtr->length);
+ Tcl_DStringAppend(&cmd, tcmdPtr->command, tcmdPtr->length);
Tcl_DStringAppendElement(&cmd, oldName);
Tcl_DStringAppendElement(&cmd, (newName ? newName : ""));
if (flags & TCL_TRACE_RENAME) {
@@ -1823,7 +1823,7 @@ TraceExecutionProc(
int i, saveInterpFlags;
Tcl_DStringInit(&cmd);
- Tcl_DStringAppend(&cmd, tcmdPtr->command, (int)tcmdPtr->length);
+ Tcl_DStringAppend(&cmd, tcmdPtr->command, tcmdPtr->length);
/*
* Append command with arguments.
@@ -1992,14 +1992,14 @@ TraceVarProc(
result = NULL;
if ((tvarPtr->flags & flags) && !Tcl_InterpDeleted(interp)
&& !Tcl_LimitExceeded(interp)) {
- if (tvarPtr->length != (size_t) 0) {
+ if (tvarPtr->length) {
/*
* Generate a command to execute by appending list elements for
* the two variable names and the operation.
*/
Tcl_DStringInit(&cmd);
- Tcl_DStringAppend(&cmd, tvarPtr->command, (int) tvarPtr->length);
+ Tcl_DStringAppend(&cmd, tvarPtr->command, tvarPtr->length);
Tcl_DStringAppendElement(&cmd, name1);
Tcl_DStringAppendElement(&cmd, (name2 ? name2 : ""));
#ifndef TCL_REMOVE_OBSOLETE_TRACES
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 6b73a8f..9903c8c 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -88,7 +88,7 @@ static const unsigned char totalBytes[256] = {
*---------------------------------------------------------------------------
*/
-int
+size_t
TclUtfCount(
int ch) /* The Unicode character whose size is returned. */
{
@@ -575,7 +575,8 @@ Tcl_UtfFindFirst(
const char *src, /* The UTF-8 string to be searched. */
int ch) /* The Unicode character to search for. */
{
- int len, fullchar;
+ size_t len;
+ int fullchar;
Tcl_UniChar find = 0;
while (1) {
@@ -621,7 +622,8 @@ Tcl_UtfFindLast(
const char *src, /* The UTF-8 string to be searched. */
int ch) /* The Unicode character to search for. */
{
- int len, fullchar;
+ size_t len;
+ int fullchar;
Tcl_UniChar find = 0;
const char *last;
@@ -670,7 +672,7 @@ Tcl_UtfNext(
const char *src) /* The current location in the string. */
{
Tcl_UniChar ch = 0;
- int len = TclUtfToUniChar(src, &ch);
+ size_t len = TclUtfToUniChar(src, &ch);
#if TCL_UTF_MAX <= 4
if (len == 0) {
@@ -755,7 +757,7 @@ Tcl_UniCharAtIndex(
Tcl_UniChar ch = 0;
int fullchar = 0;
#if TCL_UTF_MAX <= 4
- int len = 1;
+ size_t len = 1;
#endif
src += TclUtfToUniChar(src, &ch);
@@ -803,7 +805,7 @@ Tcl_UtfAtIndex(
{
Tcl_UniChar ch = 0;
#if TCL_UTF_MAX <= 4
- int len = 1;
+ size_t len = 1;
#endif
if (index != TCL_AUTO_LENGTH) {
@@ -901,7 +903,7 @@ Tcl_UtfToUpper(
Tcl_UniChar ch = 0;
int upChar;
char *src, *dst;
- int bytes;
+ size_t bytes;
/*
* Iterate over the string until we hit the terminating null.
@@ -928,7 +930,7 @@ Tcl_UtfToUpper(
*/
if ((bytes < TclUtfCount(upChar)) || ((upChar & 0xF800) == 0xD800)) {
- memcpy(dst, src, (size_t) bytes);
+ memcpy(dst, src, bytes);
dst += bytes;
} else {
dst += Tcl_UniCharToUtf(upChar, dst);
@@ -964,7 +966,7 @@ Tcl_UtfToLower(
Tcl_UniChar ch = 0;
int lowChar;
char *src, *dst;
- int bytes;
+ size_t bytes;
/*
* Iterate over the string until we hit the terminating null.
@@ -991,7 +993,7 @@ Tcl_UtfToLower(
*/
if ((bytes < TclUtfCount(lowChar)) || ((lowChar & 0xF800) == 0xD800)) {
- memcpy(dst, src, (size_t) bytes);
+ memcpy(dst, src, bytes);
dst += bytes;
} else {
dst += Tcl_UniCharToUtf(lowChar, dst);
@@ -1028,7 +1030,7 @@ Tcl_UtfToTitle(
Tcl_UniChar ch = 0;
int titleChar, lowChar;
char *src, *dst;
- int bytes;
+ size_t bytes;
/*
* Capitalize the first character and then lowercase the rest of the
@@ -1051,7 +1053,7 @@ Tcl_UtfToTitle(
titleChar = Tcl_UniCharToTitle(titleChar);
if ((bytes < TclUtfCount(titleChar)) || ((titleChar & 0xF800) == 0xD800)) {
- memcpy(dst, src, (size_t) bytes);
+ memcpy(dst, src, bytes);
dst += bytes;
} else {
dst += Tcl_UniCharToUtf(titleChar, dst);
@@ -1075,7 +1077,7 @@ Tcl_UtfToTitle(
}
if ((bytes < TclUtfCount(lowChar)) || ((lowChar & 0xF800) == 0xD800)) {
- memcpy(dst, src, (size_t) bytes);
+ memcpy(dst, src, bytes);
dst += bytes;
} else {
dst += Tcl_UniCharToUtf(lowChar, dst);
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 6481283..4b3a5cb 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -1027,7 +1027,7 @@ TclScanElement(
int extra = 0; /* Count of number of extra bytes needed for
* formatted element, assuming we use escape
* sequences in formatting. */
- int bytesNeeded; /* Buffer length computed to complete the
+ size_t bytesNeeded; /* Buffer length computed to complete the
* element formatting in the selected mode. */
#if COMPAT
int preferEscape = 0; /* Use preferences to track whether to use */
@@ -1197,7 +1197,7 @@ TclScanElement(
bytesNeeded++;
}
*flagPtr = CONVERT_ESCAPE;
- goto overflowCheck;
+ return bytesNeeded;
}
if (*flagPtr & CONVERT_ANY) {
/*
@@ -1245,7 +1245,7 @@ TclScanElement(
bytesNeeded += braceCount;
}
*flagPtr = CONVERT_MASK;
- goto overflowCheck;
+ return bytesNeeded;
}
#endif /* COMPAT */
if (*flagPtr & TCL_DONT_USE_BRACES) {
@@ -1271,7 +1271,7 @@ TclScanElement(
bytesNeeded += 2;
}
*flagPtr = CONVERT_BRACE;
- goto overflowCheck;
+ return bytesNeeded;
}
/*
@@ -1286,11 +1286,6 @@ TclScanElement(
bytesNeeded += 2;
}
*flagPtr = CONVERT_NONE;
-
- overflowCheck:
- if (bytesNeeded < 0) {
- Tcl_Panic("TclScanElement: string length overflow");
- }
return bytesNeeded;
}
@@ -1669,15 +1664,15 @@ UtfWellFormedEnd(
*----------------------------------------------------------------------
*/
-static inline int
+static inline size_t
TrimRight(
const char *bytes, /* String to be trimmed... */
- int numBytes, /* ...and its length in bytes */
+ size_t numBytes, /* ...and its length in bytes */
const char *trim, /* String of trim characters... */
- int numTrim) /* ...and its length in bytes */
+ size_t numTrim) /* ...and its length in bytes */
{
const char *p = bytes + numBytes;
- int pInc;
+ size_t pInc;
Tcl_UniChar ch1 = 0, ch2 = 0;
/*
@@ -1686,7 +1681,7 @@ TrimRight(
do {
const char *q = trim;
- int bytesLeft = numTrim;
+ size_t bytesLeft = numTrim;
p = Tcl_UtfPrev(p, bytes);
pInc = TclUtfToUniChar(p, &ch1);
@@ -1696,7 +1691,7 @@ TrimRight(
*/
do {
- int qInc = TclUtfToUniChar(q, &ch2);
+ size_t qInc = TclUtfToUniChar(q, &ch2);
if (ch1 == ch2) {
break;
@@ -1783,16 +1778,16 @@ TrimLeft(
*/
do {
- int pInc = TclUtfToUniChar(p, &ch1);
+ size_t pInc = TclUtfToUniChar(p, &ch1);
const char *q = trim;
- int bytesLeft = numTrim;
+ size_t bytesLeft = numTrim;
/*
* Inner loop: scan trim string for match to current character.
*/
do {
- int qInc = TclUtfToUniChar(q, &ch2);
+ size_t qInc = TclUtfToUniChar(q, &ch2);
if (ch1 == ch2) {
break;
@@ -1992,7 +1987,7 @@ Tcl_Concat(
if (needSpace) {
*p++ = ' ';
}
- memcpy(p, element, (size_t) elemLength);
+ memcpy(p, element, elemLength);
p += elemLength;
needSpace = 1;
}
@@ -2041,8 +2036,7 @@ Tcl_ConcatObj(
if (TclListObjIsCanonical(objPtr)) {
continue;
}
- TclGetString(objPtr);
- length = objPtr->length;
+ (void)TclGetStringFromObj(objPtr, &length);
if (length > 0) {
break;
}
@@ -2079,8 +2073,7 @@ Tcl_ConcatObj(
*/
for (i = 0; i < objc; i++) {
- element = TclGetString(objv[i]);
- elemLength = objv[i]->length;
+ element = TclGetStringFromObj(objv[i], &elemLength);
bytesNeeded += elemLength;
}
@@ -2097,8 +2090,7 @@ Tcl_ConcatObj(
for (i = 0; i < objc; i++) {
size_t triml, trimr;
- element = TclGetString(objv[i]);
- elemLength = objv[i]->length;
+ element = TclGetStringFromObj(objv[i], &elemLength);
/* Trim away the leading/trailing whitespace. */
triml = TclTrim(element, elemLength, CONCAT_TRIM_SET,
@@ -2741,9 +2733,10 @@ TclDStringAppendObj(
Tcl_DString *dsPtr,
Tcl_Obj *objPtr)
{
- char *bytes = TclGetString(objPtr);
+ size_t length;
+ const char *bytes = TclGetStringFromObj(objPtr, &length);
- return Tcl_DStringAppend(dsPtr, bytes, objPtr->length);
+ return Tcl_DStringAppend(dsPtr, bytes, length);
}
char *
@@ -3637,13 +3630,13 @@ TclGetIntForIndex(
Tcl_WideInt wide;
/* Use platform-related size_t to wide-int to consider negative value
- * ((size_t)-1) if wide-int and size_t have different dimensions. */
+ * TCL_INDEX_NONE if wide-int and size_t have different dimensions. */
if (GetWideForIndex(interp, objPtr, TclWideIntFromSize(endValue),
- &wide) == TCL_ERROR) {
+ &wide) == TCL_ERROR) {
return TCL_ERROR;
}
if (wide < 0) {
- *indexPtr = -1;
+ *indexPtr = TCL_INDEX_NONE;
} else if (wide > INT_MAX) {
*indexPtr = INT_MAX;
} else {
@@ -3825,7 +3818,7 @@ TclIndexEncode(
/* We parsed a value in the range WIDE_MIN...WIDE_MAX */
wide = (*(Tcl_WideInt *)cd);
integerEncode:
- if (wide < TCL_INDEX_START) {
+ if (wide < 0) {
/* All negative absolute indices are "before the beginning" */
idx = before;
} else if (wide >= INT_MAX) {
@@ -3845,13 +3838,13 @@ TclIndexEncode(
* All end+positive or end-negative expressions
* always indicate "after the end".
*/
- idx = after;
- } else if (wide < INT_MIN - TCL_INDEX_END) {
+ idx = (int) after;
+ } else if (wide < INT_MIN - (int) TCL_INDEX_END) {
/* These indices always indicate "before the beginning */
- idx = before;
+ idx = (int) before;
} else {
/* Encoded end-positive (or end+negative) are offset */
- idx = (int)wide + TCL_INDEX_END;
+ idx = (int) wide + (int) TCL_INDEX_END;
}
/* TODO: Consider flag to suppress repeated end-offset parse. */
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 308af04..972e1f6 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -6395,7 +6395,7 @@ CompareVarKeys(
Tcl_Obj *objPtr1 = (Tcl_Obj *)keyPtr;
Tcl_Obj *objPtr2 = hPtr->key.objPtr;
register const char *p1, *p2;
- register int l1, l2;
+ register size_t l1, l2;
/*
* If the object pointers are the same then they match.
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 2c91161..90e8671 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -4190,8 +4190,7 @@ ZipFSMatchInDirectoryProc(
* The (normalized) path we're searching.
*/
- path = TclGetString(normPathPtr);
- len = normPathPtr->length;
+ path = TclGetStringFromObj(normPathPtr, &len);
Tcl_DStringInit(&dsPref);
Tcl_DStringAppend(&dsPref, prefix, prefixLen);
@@ -4363,13 +4362,11 @@ ZipFSPathInFilesystemProc(
return -1;
}
- path = TclGetString(pathPtr);
+ path = TclGetStringFromObj(pathPtr, &len);
if (strncmp(path, ZIPFS_VOLUME, ZIPFS_VOLUME_LEN) != 0) {
return -1;
}
- len = pathPtr->length;
-
ReadLock();
hPtr = Tcl_FindHashEntry(&ZipFS.fileHash, path);
if (hPtr) {
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index ef5eab3..33ab2e5 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -422,6 +422,7 @@ GenerateHeader(
{
Tcl_Obj *value;
int len, result = TCL_ERROR;
+ size_t length;
const char *valueStr;
Tcl_Encoding latin1enc;
static const char *const types[] = {
@@ -440,8 +441,8 @@ GenerateHeader(
if (GetValue(interp, dictObj, "comment", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
- valueStr = TclGetString(value);
- Tcl_UtfToExternal(NULL, latin1enc, valueStr, value->length, 0, NULL,
+ valueStr = TclGetStringFromObj(value, &length);
+ Tcl_UtfToExternal(NULL, latin1enc, valueStr, length, 0, NULL,
headerPtr->nativeCommentBuf, MAX_COMMENT_LEN-1, NULL, &len,
NULL);
headerPtr->nativeCommentBuf[len] = '\0';
@@ -461,8 +462,8 @@ GenerateHeader(
if (GetValue(interp, dictObj, "filename", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
- valueStr = TclGetString(value);
- Tcl_UtfToExternal(NULL, latin1enc, valueStr, value->length, 0, NULL,
+ valueStr = TclGetStringFromObj(value, &length);
+ Tcl_UtfToExternal(NULL, latin1enc, valueStr, length, 0, NULL,
headerPtr->nativeFilenameBuf, MAXPATHLEN-1, NULL, &len, NULL);
headerPtr->nativeFilenameBuf[len] = '\0';
headerPtr->header.name = (Bytef *) headerPtr->nativeFilenameBuf;
@@ -3397,9 +3398,10 @@ ZlibTransformGetOption(
}
} else {
if (cd->compDictObj) {
- const char *str = TclGetString(cd->compDictObj);
+ size_t length;
+ const char *str = TclGetStringFromObj(cd->compDictObj, &length);
- Tcl_DStringAppend(dsPtr, str, cd->compDictObj->length);
+ Tcl_DStringAppend(dsPtr, str, length);
}
return TCL_OK;
}
diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c
index ab9b74f..f6d39e1 100644
--- a/macosx/tclMacOSXFCmd.c
+++ b/macosx/tclMacOSXFCmd.c
@@ -639,9 +639,10 @@ SetOSTypeFromAny(
int result = TCL_OK;
Tcl_DString ds;
Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
+ size_t length;
- string = TclGetString(objPtr);
- Tcl_UtfToExternalDString(encoding, string, objPtr->length, &ds);
+ string = TclGetStringFromObj(objPtr, &length);
+ Tcl_UtfToExternalDString(encoding, string, length, &ds);
if (Tcl_DStringLength(&ds) > 4) {
if (interp) {
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 1dd2340..29fc03e 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -252,7 +252,7 @@ FileInputProc(
* nonblocking, the read will never block.
*/
- bytesRead = read(fsPtr->fd, buf, (size_t) toRead);
+ bytesRead = read(fsPtr->fd, buf, toRead);
if (bytesRead > -1) {
return bytesRead;
}
@@ -299,7 +299,7 @@ FileOutputProc(
return 0;
}
- written = write(fsPtr->fd, buf, (size_t) toWrite);
+ written = write(fsPtr->fd, buf, toWrite);
if (written > -1) {
return written;
}
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index cb2ecdb..ff398be 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -612,7 +612,7 @@ TclUnixCopyFile(
}
buffer = Tcl_Alloc(blockSize);
while (1) {
- nread = (size_t) read(srcFd, buffer, blockSize);
+ nread = read(srcFd, buffer, blockSize);
if ((nread == TCL_IO_FAILURE) || (nread == 0)) {
break;
}
@@ -1507,10 +1507,11 @@ SetGroupAttribute(
Tcl_DString ds;
struct group *groupPtr = NULL;
const char *string;
+ size_t length;
- string = TclGetString(attributePtr);
+ string = TclGetStringFromObj(attributePtr, &length);
- native = Tcl_UtfToExternalDString(NULL, string, attributePtr->length, &ds);
+ native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
groupPtr = TclpGetGrNam(native); /* INTL: Native. */
Tcl_DStringFree(&ds);
@@ -1573,10 +1574,11 @@ SetOwnerAttribute(
Tcl_DString ds;
struct passwd *pwPtr = NULL;
const char *string;
+ size_t length;
- string = TclGetString(attributePtr);
+ string = TclGetStringFromObj(attributePtr, &length);
- native = Tcl_UtfToExternalDString(NULL, string, attributePtr->length, &ds);
+ native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
pwPtr = TclpGetPwNam(native); /* INTL: Native. */
Tcl_DStringFree(&ds);
@@ -1945,8 +1947,8 @@ TclpObjNormalizePath(
{
const char *currentPathEndPosition;
char cur;
- const char *path = TclGetString(pathPtr);
- size_t pathLen = pathPtr->length;
+ size_t pathLen;
+ const char *path = TclGetStringFromObj(pathPtr, &pathLen);
Tcl_DString ds;
const char *nativePath;
#ifndef NO_REALPATH
@@ -2176,14 +2178,15 @@ TclUnixOpenTemporaryFile(
Tcl_DString template, tmp;
const char *string;
int fd;
+ size_t length;
/*
* We should also check against making more then TMP_MAX of these.
*/
if (dirObj) {
- string = TclGetString(dirObj);
- Tcl_UtfToExternalDString(NULL, string, dirObj->length, &template);
+ string = TclGetStringFromObj(dirObj, &length);
+ Tcl_UtfToExternalDString(NULL, string, length, &template);
} else {
Tcl_DStringInit(&template);
Tcl_DStringAppend(&template, DefaultTempDir(), -1); /* INTL: native */
@@ -2192,8 +2195,8 @@ TclUnixOpenTemporaryFile(
TclDStringAppendLiteral(&template, "/");
if (basenameObj) {
- string = TclGetString(basenameObj);
- Tcl_UtfToExternalDString(NULL, string, basenameObj->length, &tmp);
+ string = TclGetStringFromObj(basenameObj, &length);
+ Tcl_UtfToExternalDString(NULL, string, length, &tmp);
TclDStringAppendDString(&template, &tmp);
Tcl_DStringFree(&tmp);
} else {
@@ -2204,8 +2207,8 @@ TclUnixOpenTemporaryFile(
#ifdef HAVE_MKSTEMPS
if (extensionObj) {
- string = TclGetString(extensionObj);
- Tcl_UtfToExternalDString(NULL, string, extensionObj->length, &tmp);
+ string = TclGetStringFromObj(extensionObj, &length);
+ Tcl_UtfToExternalDString(NULL, string, length, &tmp);
TclDStringAppendDString(&template, &tmp);
fd = mkstemps(Tcl_DStringValue(&template), Tcl_DStringLength(&tmp));
Tcl_DStringFree(&tmp);
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 3da84e0..352c04e 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -269,8 +269,7 @@ TclpMatchInDirectory(
Tcl_DString dsOrig; /* utf-8 encoding of dir */
Tcl_DStringInit(&dsOrig);
- dirName = TclGetString(fileNamePtr);
- dirLength = fileNamePtr->length;
+ dirName = TclGetStringFromObj(fileNamePtr, &dirLength);
Tcl_DStringAppend(&dsOrig, dirName, dirLength);
/*
@@ -940,6 +939,7 @@ TclpObjLink(
if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
Tcl_DString ds;
Tcl_Obj *transPtr;
+ size_t length;
/*
* Now we don't want to link to the absolute, normalized path.
@@ -951,8 +951,8 @@ TclpObjLink(
if (transPtr == NULL) {
return NULL;
}
- target = TclGetString(transPtr);
- target = Tcl_UtfToExternalDString(NULL, target, transPtr->length, &ds);
+ target = TclGetStringFromObj(transPtr, &length);
+ target = Tcl_UtfToExternalDString(NULL, target, length, &ds);
Tcl_DecrRefCount(transPtr);
if (symlink(target, src) != 0) {
@@ -1105,8 +1105,7 @@ TclNativeCreateNativeRep(
Tcl_IncrRefCount(validPathPtr);
}
- str = TclGetString(validPathPtr);
- len = validPathPtr->length;
+ str = TclGetStringFromObj(validPathPtr, &len);
Tcl_UtfToExternalDString(NULL, str, len, &ds);
len = Tcl_DStringLength(&ds) + sizeof(char);
if (strlen(Tcl_DStringValue(&ds)) < len - sizeof(char)) {
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index eacf157..2e54e72 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -537,8 +537,7 @@ TclpInitLibraryPath(
Tcl_DStringFree(&buffer);
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
- str = TclGetString(pathPtr);
- *lengthPtr = pathPtr->length;
+ str = TclGetStringFromObj(pathPtr, lengthPtr);
*valuePtr = Tcl_Alloc(*lengthPtr + 1);
memcpy(*valuePtr, str, *lengthPtr + 1);
Tcl_DecrRefCount(pathPtr);
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index 0623648..dfeee0c 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -1059,7 +1059,7 @@ PipeInputProc(
*/
do {
- bytesRead = read(GetFd(psPtr->inFile), buf, (size_t) toRead);
+ bytesRead = read(GetFd(psPtr->inFile), buf, toRead);
} while ((bytesRead < 0) && (errno == EINTR));
if (bytesRead < 0) {
@@ -1105,7 +1105,7 @@ PipeOutputProc(
*/
do {
- written = write(GetFd(psPtr->outFile), buf, (size_t) toWrite);
+ written = write(GetFd(psPtr->outFile), buf, toWrite);
} while ((written < 0) && (errno == EINTR));
if (written < 0) {
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index d53b3de..09ed008 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -241,7 +241,7 @@ InitializeHostName(
if (dot != NULL) {
char *node = Tcl_Alloc(dot - u.nodename + 1);
- memcpy(node, u.nodename, (size_t) (dot - u.nodename));
+ memcpy(node, u.nodename, dot - u.nodename);
node[dot - u.nodename] = '\0';
hp = TclpGetHostByName(node);
Tcl_Free(node);
@@ -541,7 +541,7 @@ TcpInputProc(
if (WaitForConnect(statePtr, errorCodePtr) != 0) {
return -1;
}
- bytesRead = recv(statePtr->fds.fd, buf, (size_t) bufSize, 0);
+ bytesRead = recv(statePtr->fds.fd, buf, bufSize, 0);
if (bytesRead > -1) {
return bytesRead;
}
@@ -591,7 +591,7 @@ TcpOutputProc(
if (WaitForConnect(statePtr, errorCodePtr) != 0) {
return -1;
}
- written = send(statePtr->fds.fd, buf, (size_t) toWrite, 0);
+ written = send(statePtr->fds.fd, buf, toWrite, 0);
if (written > -1) {
return written;
diff --git a/unix/tclXtNotify.c b/unix/tclXtNotify.c
index 80202d3..56fe840 100644
--- a/unix/tclXtNotify.c
+++ b/unix/tclXtNotify.c
@@ -268,7 +268,7 @@ static void
SetTimer(
const Tcl_Time *timePtr) /* Timeout value, may be NULL. */
{
- long timeout;
+ unsigned long timeout;
if (!initialized) {
InitNotifier();
@@ -281,7 +281,7 @@ SetTimer(
if (timePtr) {
timeout = timePtr->sec * 1000 + timePtr->usec / 1000;
notifier.currentTimeout = XtAppAddTimeOut(notifier.appContext,
- (unsigned long) timeout, TimerProc, NULL);
+ timeout, TimerProc, NULL);
} else {
notifier.currentTimeout = 0;
}
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c
index d281c22..1465549 100644
--- a/win/tclWinFCmd.c
+++ b/win/tclWinFCmd.c
@@ -1524,8 +1524,8 @@ GetWinFileAttributes(
* We test for, and fix that case, here.
*/
- const char *str = TclGetString(fileName);
- size_t len = fileName->length;
+ size_t len;
+ const char *str = TclGetStringFromObj(fileName, &len);
if (len < 4) {
if (len == 0) {
@@ -1586,6 +1586,7 @@ ConvertFileNameFormat(
{
int pathc, i;
Tcl_Obj *splitPath;
+ size_t length;
splitPath = Tcl_FSSplitPath(fileName, &pathc);
@@ -1613,8 +1614,8 @@ ConvertFileNameFormat(
Tcl_ListObjIndex(NULL, splitPath, i, &elt);
- pathv = TclGetString(elt);
- if ((pathv[0] == '/') || ((elt->length == 3) && (pathv[1] == ':'))
+ pathv = TclGetStringFromObj(elt, &length);
+ if ((pathv[0] == '/') || ((length == 3) && (pathv[1] == ':'))
|| (strcmp(pathv, ".") == 0) || (strcmp(pathv, "..") == 0)) {
/*
* Handle "/", "//machine/export", "c:/", "." or ".." by just
@@ -1649,8 +1650,8 @@ ConvertFileNameFormat(
* likely to lead to infinite loops.
*/
- tempString = TclGetString(tempPath);
- nativeName = Tcl_WinUtfToTChar(tempString, tempPath->length, &ds);
+ tempString = TclGetStringFromObj(tempPath, &length);
+ nativeName = Tcl_WinUtfToTChar(tempString, length, &ds);
Tcl_DecrRefCount(tempPath);
handle = FindFirstFile(nativeName, &data);
if (handle == INVALID_HANDLE_VALUE) {
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 7ff8b9b..3910f3d 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -913,7 +913,8 @@ TclpMatchInDirectory(
DWORD attr;
WIN32_FILE_ATTRIBUTE_DATA data;
- const char *str = TclGetString(norm);
+ size_t length;
+ const char *str = TclGetStringFromObj(norm, &length);
native = Tcl_FSGetNativePath(pathPtr);
@@ -923,7 +924,7 @@ TclpMatchInDirectory(
}
attr = data.dwFileAttributes;
- if (NativeMatchType(WinIsDrive(str,norm->length), attr, native, types)) {
+ if (NativeMatchType(WinIsDrive(str, length), attr, native, types)) {
Tcl_ListObjAppendElement(interp, resultPtr, pathPtr);
}
}
@@ -2733,12 +2734,13 @@ TclpObjNormalizePath(
char *path;
Tcl_Obj *tmpPathPtr;
+ size_t length;
tmpPathPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds),
nextCheckpoint);
Tcl_AppendToObj(tmpPathPtr, lastValidPathEnd, -1);
- path = TclGetString(tmpPathPtr);
- Tcl_SetStringObj(pathPtr, path, tmpPathPtr->length);
+ path = TclGetStringFromObj(tmpPathPtr, &length);
+ Tcl_SetStringObj(pathPtr, path, length);
Tcl_DecrRefCount(tmpPathPtr);
} else {
/*
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index e7ecd72..80bb210 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -268,7 +268,7 @@ AppendEnvironment(
for (shortlib = (char *) &lib[strlen(lib)-1]; shortlib>lib ; shortlib--) {
if (*shortlib == '/') {
- if ((unsigned)(shortlib - lib) == strlen(lib) - 1) {
+ if ((size_t)(shortlib - lib) == strlen(lib) - 1) {
Tcl_Panic("last character in lib cannot be '/'");
}
shortlib++;
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index bd97c6c..5d0004d 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -1834,7 +1834,7 @@ TclGetAndDetachPids(
TclNewObj(pidsObj);
for (i = 0; i < pipePtr->numPids; i++) {
Tcl_ListObjAppendElement(NULL, pidsObj,
- Tcl_NewWideIntObj((unsigned)
+ Tcl_NewWideIntObj(
TclpGetPid(pipePtr->pidPtr[i])));
Tcl_DetachPids(1, &pipePtr->pidPtr[i]);
}