summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2017-11-09 14:44:57 (GMT)
committerdgp <dgp@users.sourceforge.net>2017-11-09 14:44:57 (GMT)
commit29dda71bad5e67eb3ada1ce9f836ca43bde1c216 (patch)
tree967b1560c397b13b2394f8090b166f5b813325e2 /generic
parent42764c99bec23aaae227ff1aba60c1ff9e7d9230 (diff)
parent0faadee83ceeb72ae3634429f88f0defcb607169 (diff)
downloadtcl-29dda71bad5e67eb3ada1ce9f836ca43bde1c216.zip
tcl-29dda71bad5e67eb3ada1ce9f836ca43bde1c216.tar.gz
tcl-29dda71bad5e67eb3ada1ce9f836ca43bde1c216.tar.bz2
merge trunk
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h88
-rw-r--r--generic/tclBasic.c111
-rw-r--r--generic/tclDecls.h10
-rw-r--r--generic/tclDictObj.c18
-rw-r--r--generic/tclExecute.c18
-rw-r--r--generic/tclHash.c13
-rw-r--r--generic/tclHistory.c7
-rw-r--r--generic/tclInt.h78
-rw-r--r--generic/tclListObj.c593
-rw-r--r--generic/tclLoad.c11
-rw-r--r--generic/tclOO.c5
-rw-r--r--generic/tclObj.c31
-rw-r--r--generic/tclProc.c96
-rw-r--r--generic/tclResult.c375
-rw-r--r--generic/tclScan.c12
-rwxr-xr-x[-rw-r--r--]generic/tclStrToD.c65
-rw-r--r--generic/tclStringObj.c6
-rw-r--r--generic/tclStubLib.c4
-rw-r--r--generic/tclTest.c8
-rw-r--r--generic/tclUtil.c185
-rw-r--r--generic/tclVar.c12
21 files changed, 514 insertions, 1232 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 07d841d..d261b02 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -52,13 +52,13 @@ extern "C" {
* tools/tcl.hpj.in (not patchlevel, for windows installer)
*/
-#define TCL_MAJOR_VERSION 8
-#define TCL_MINOR_VERSION 7
+#define TCL_MAJOR_VERSION 9
+#define TCL_MINOR_VERSION 0
#define TCL_RELEASE_LEVEL TCL_ALPHA_RELEASE
-#define TCL_RELEASE_SERIAL 2
+#define TCL_RELEASE_SERIAL 0
-#define TCL_VERSION "8.7"
-#define TCL_PATCH_LEVEL "8.7a2"
+#define TCL_VERSION "9.0"
+#define TCL_PATCH_LEVEL "9.0a0"
#if !defined(TCL_NO_DEPRECATED) || defined(RC_INVOKED)
/*
@@ -492,39 +492,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
* accessed with Tcl_GetObjResult() and Tcl_SetObjResult().
*/
-typedef struct Tcl_Interp
-#ifndef TCL_NO_DEPRECATED
-{
- /* TIP #330: Strongly discourage extensions from using the string
- * result. */
-#ifdef USE_INTERP_RESULT
- char *result TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult");
- /* If the last command returned a string
- * result, this points to it. */
- void (*freeProc) (char *blockPtr)
- TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult");
- /* Zero means the string result is statically
- * allocated. TCL_DYNAMIC means it was
- * allocated with ckalloc and should be freed
- * with ckfree. Other values give the address
- * of function to invoke to free the result.
- * Tcl_Eval must free it before executing next
- * command. */
-#else
- char *resultDontUse; /* Don't use in extensions! */
- void (*freeProcDontUse) (char *); /* Don't use in extensions! */
-#endif
-#ifdef USE_INTERP_ERRORLINE
- int errorLine TCL_DEPRECATED_API("use Tcl_GetErrorLine/Tcl_SetErrorLine");
- /* When TCL_ERROR is returned, this gives the
- * line number within the command where the
- * error occurred (1 if first line). */
-#else
- int errorLineDontUse; /* Don't use in extensions! */
-#endif
-}
-#endif /* !TCL_NO_DEPRECATED */
-Tcl_Interp;
+typedef struct Tcl_Interp Tcl_Interp;
typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler;
typedef struct Tcl_Channel_ *Tcl_Channel;
@@ -673,8 +641,6 @@ typedef struct stat *Tcl_OldStat_;
#define TCL_BREAK 3
#define TCL_CONTINUE 4
-#define TCL_RESULT_SIZE 200
-
/*
*----------------------------------------------------------------------------
* Flags to control what substitutions are performed by Tcl_SubstObj():
@@ -859,20 +825,11 @@ int Tcl_IsShared(Tcl_Obj *objPtr);
/*
*----------------------------------------------------------------------------
- * The following structure contains the state needed by Tcl_SaveResult. No-one
- * outside of Tcl should access any of these fields. This structure is
- * typically allocated on the stack.
+ * The following type contains the state needed by Tcl_SaveResult. It
+ * is typically allocated on the stack.
*/
-typedef struct Tcl_SavedResult {
- char *result;
- Tcl_FreeProc *freeProc;
- Tcl_Obj *objResultPtr;
- char *appendResult;
- int appendAvl;
- int appendUsed;
- char resultSpace[TCL_RESULT_SIZE+1];
-} Tcl_SavedResult;
+typedef Tcl_Obj *Tcl_SavedResult;
/*
*----------------------------------------------------------------------------
@@ -1344,8 +1301,8 @@ typedef struct Tcl_HashSearch {
typedef struct {
void *next; /* Search position for underlying hash
* table. */
- int epoch; /* Epoch marker for dictionary being searched,
- * or -1 if search has terminated. */
+ unsigned int epoch; /* Epoch marker for dictionary being searched,
+ * or 0 if search has terminated. */
Tcl_Dict dictionaryPtr; /* Reference to dictionary being searched. */
} Tcl_DictSearch;
@@ -2409,14 +2366,27 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
const char *version, int epoch, int revision);
#ifdef USE_TCL_STUBS
-#define Tcl_InitStubs(interp, version, exact) \
- (Tcl_InitStubs)(interp, version, \
+#if TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE
+# define Tcl_InitStubs(interp, version, exact) \
+ (Tcl_InitStubs)(interp, version, \
(exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16), \
TCL_STUB_MAGIC)
#else
-#define Tcl_InitStubs(interp, version, exact) \
- Tcl_PkgInitStubsCheck(interp, version, \
- (exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16))
+# define Tcl_InitStubs(interp, version, exact) \
+ (Tcl_InitStubs)(interp, TCL_PATCH_LEVEL, \
+ 1|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16), \
+ TCL_STUB_MAGIC)
+#endif
+#else
+#if TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE
+# define Tcl_InitStubs(interp, version, exact) \
+ Tcl_PkgInitStubsCheck(interp, version, \
+ (exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16))
+#else
+# define Tcl_InitStubs(interp, version, exact) \
+ Tcl_PkgInitStubsCheck(interp, TCL_PATCH_LEVEL, \
+ 1|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16))
+#endif
#endif
/*
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index f84b420..2c84e63 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -510,13 +510,12 @@ Tcl_CreateInterp(void)
iPtr = ckalloc(sizeof(Interp));
interp = (Tcl_Interp *) iPtr;
-#ifdef TCL_NO_DEPRECATED
- iPtr->result = &tclEmptyString;
-#else
- iPtr->result = iPtr->resultSpace;
-#endif
- iPtr->freeProc = NULL;
+ iPtr->legacyResult = NULL;
+ /* Special invalid value: Any attempt to free the legacy result
+ * will cause a crash. */
+ iPtr->legacyFreeProc = (void (*) (void))-1;
iPtr->errorLine = 0;
+ iPtr->stubTable = &tclStubs;
iPtr->objResultPtr = Tcl_NewObj();
Tcl_IncrRefCount(iPtr->objResultPtr);
iPtr->handle = TclHandleCreate(iPtr);
@@ -574,12 +573,6 @@ Tcl_CreateInterp(void)
iPtr->rootFramePtr = NULL; /* Initialise as soon as :: is available */
iPtr->lookupNsPtr = NULL;
-#ifndef TCL_NO_DEPRECATED
- iPtr->appendResult = NULL;
- iPtr->appendAvl = 0;
- iPtr->appendUsed = 0;
-#endif
-
Tcl_InitHashTable(&iPtr->packageTable, TCL_STRING_KEYS);
iPtr->packageUnknown = NULL;
@@ -608,9 +601,6 @@ Tcl_CreateInterp(void)
iPtr->emptyObjPtr = Tcl_NewObj();
/* Another empty object. */
Tcl_IncrRefCount(iPtr->emptyObjPtr);
-#ifndef TCL_NO_DEPRECATED
- iPtr->resultSpace[0] = 0;
-#endif
iPtr->threadId = Tcl_GetCurrentThread();
/* TIP #378 */
@@ -721,12 +711,6 @@ Tcl_CreateInterp(void)
#endif /* TCL_COMPILE_STATS */
/*
- * Initialise the stub table pointer.
- */
-
- iPtr->stubTable = &tclStubs;
-
- /*
* Initialize the ensemble error message rewriting support.
*/
@@ -1521,7 +1505,6 @@ DeleteInterpProc(
*/
Tcl_FreeResult(interp);
- iPtr->result = NULL;
Tcl_DecrRefCount(iPtr->objResultPtr);
iPtr->objResultPtr = NULL;
Tcl_DecrRefCount(iPtr->ecVar);
@@ -1543,12 +1526,6 @@ DeleteInterpProc(
if (iPtr->returnOpts) {
Tcl_DecrRefCount(iPtr->returnOpts);
}
-#ifndef TCL_NO_DEPRECATED
- if (iPtr->appendResult != NULL) {
- ckfree(iPtr->appendResult);
- iPtr->appendResult = NULL;
- }
-#endif
TclFreePackageInfo(iPtr);
while (iPtr->tracePtr != NULL) {
Tcl_DeleteTrace((Tcl_Interp *) iPtr, (Tcl_Trace) iPtr->tracePtr);
@@ -2482,7 +2459,7 @@ TclInvokeStringCommand(
* in the Command structure.
*
* Results:
- * A standard Tcl string result value.
+ * A standard Tcl result value.
*
* Side effects:
* Besides those side effects of the called Tcl_ObjCmdProc,
@@ -2523,13 +2500,6 @@ TclInvokeObjectCommand(
}
/*
- * Move the interpreter's object result to the string result, then reset
- * the object result.
- */
-
- (void) Tcl_GetStringResult(interp);
-
- /*
* Decrement the ref counts for the argument objects created above, then
* free the objv array if malloc'ed storage was used.
*/
@@ -3583,7 +3553,6 @@ OldMathFuncProc(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"argument to math function didn't have numeric value",
-1));
- TclCheckBadOctal(interp, TclGetString(valuePtr));
ckfree(args);
return TCL_ERROR;
}
@@ -3833,7 +3802,7 @@ Tcl_ListMathFuncs(
* otherwise.
*
* Side effects:
- * The interpreters object and string results are cleared.
+ * The interpreter's result is cleared.
*
*----------------------------------------------------------------------
*/
@@ -3845,8 +3814,8 @@ TclInterpReady(
register Interp *iPtr = (Interp *) interp;
/*
- * Reset both the interpreter's string and object results and clear out
- * any previous error information.
+ * Reset the interpreter's result and clear out any previous error
+ * information.
*/
Tcl_ResetResult(interp);
@@ -4426,24 +4395,9 @@ TclNRRunCallbacks(
/* All callbacks down to rootPtr not inclusive
* are to be run. */
{
- Interp *iPtr = (Interp *) interp;
NRE_callback *callbackPtr;
Tcl_NRPostProc *procPtr;
- /*
- * If the interpreter has a non-empty string result, the result object is
- * either empty or stale because some function set interp->result
- * directly. If so, move the string result to the result object, then
- * reset the string result.
- *
- * This only needs to be done for the first item in the list: all other
- * are for NR function calls, and those are Tcl_Obj based.
- */
-
- if (*(iPtr->result) != 0) {
- (void) Tcl_GetObjResult(interp);
- }
-
while (TOP_CB(interp) != rootPtr) {
callbackPtr = TOP_CB(interp);
procPtr = callbackPtr->procPtr;
@@ -5911,16 +5865,7 @@ Tcl_Eval(
* previous call to Tcl_CreateInterp). */
const char *script) /* Pointer to TCL command to execute. */
{
- int code = Tcl_EvalEx(interp, script, -1, 0);
-
- /*
- * For backwards compatibility with old C code that predates the object
- * system in Tcl 8.0, we have to mirror the object result back into the
- * string result (some callers may expect it there).
- */
-
- (void) Tcl_GetStringResult(interp);
- return code;
+ return Tcl_EvalEx(interp, script, -1, 0);
}
/*
@@ -6343,9 +6288,6 @@ Tcl_ExprLong(
Tcl_IncrRefCount(exprPtr);
result = Tcl_ExprLongObj(interp, exprPtr, ptr);
Tcl_DecrRefCount(exprPtr);
- if (result != TCL_OK) {
- (void) Tcl_GetStringResult(interp);
- }
}
return result;
}
@@ -6372,9 +6314,6 @@ Tcl_ExprDouble(
result = Tcl_ExprDoubleObj(interp, exprPtr, ptr);
Tcl_DecrRefCount(exprPtr);
/* Discard the expression object. */
- if (result != TCL_OK) {
- (void) Tcl_GetStringResult(interp);
- }
}
return result;
}
@@ -6400,14 +6339,6 @@ Tcl_ExprBoolean(
Tcl_IncrRefCount(exprPtr);
result = Tcl_ExprBooleanObj(interp, exprPtr, ptr);
Tcl_DecrRefCount(exprPtr);
- if (result != TCL_OK) {
- /*
- * Move the interpreter's object result to the string result, then
- * reset the object result.
- */
-
- (void) Tcl_GetStringResult(interp);
- }
return result;
}
}
@@ -6721,12 +6652,6 @@ Tcl_ExprString(
Tcl_DecrRefCount(resultPtr);
}
}
-
- /*
- * Force the string rep of the interp result.
- */
-
- (void) Tcl_GetStringResult(interp);
return code;
}
@@ -6833,19 +6758,7 @@ Tcl_AddObjErrorInfo(
iPtr->flags |= ERR_LEGACY_COPY;
if (iPtr->errorInfo == NULL) {
- if (iPtr->result[0] != 0) {
- /*
- * The interp's string result is set, apparently by some extension
- * making a deprecated direct write to it. That extension may
- * expect interp->result to continue to be set, so we'll take
- * special pains to avoid clearing it, until we drop support for
- * interp->result completely.
- */
-
- iPtr->errorInfo = Tcl_NewStringObj(iPtr->result, -1);
- } else {
- iPtr->errorInfo = iPtr->objResultPtr;
- }
+ iPtr->errorInfo = iPtr->objResultPtr;
Tcl_IncrRefCount(iPtr->errorInfo);
if (!iPtr->errorCode) {
Tcl_SetErrorCode(interp, "NONE", NULL);
@@ -6923,7 +6836,7 @@ Tcl_VarEvalVA(
*
* Results:
* A standard Tcl return result. An error message or other result may be
- * left in interp->result.
+ * left in the interp.
*
* Side effects:
* Depends on what was done by the command.
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 464fc0f..17d60a8 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -3888,20 +3888,20 @@ extern const TclStubs *tclStubsPtr;
#undef Tcl_SaveResult
#define Tcl_SaveResult(interp, statePtr) \
do { \
- (statePtr)->objResultPtr = Tcl_GetObjResult(interp); \
- Tcl_IncrRefCount((statePtr)->objResultPtr); \
+ *(statePtr) = Tcl_GetObjResult(interp); \
+ Tcl_IncrRefCount(*(statePtr)); \
Tcl_SetObjResult(interp, Tcl_NewObj()); \
} while(0)
#undef Tcl_RestoreResult
#define Tcl_RestoreResult(interp, statePtr) \
do { \
Tcl_ResetResult(interp); \
- Tcl_SetObjResult(interp, (statePtr)->objResultPtr); \
- Tcl_DecrRefCount((statePtr)->objResultPtr); \
+ Tcl_SetObjResult(interp, *(statePtr)); \
+ Tcl_DecrRefCount(*(statePtr)); \
} while(0)
#undef Tcl_DiscardResult
#define Tcl_DiscardResult(statePtr) \
- Tcl_DecrRefCount((statePtr)->objResultPtr)
+ Tcl_DecrRefCount(*(statePtr))
#undef Tcl_SetResult
#define Tcl_SetResult(interp, result, freeProc) \
do { \
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index 1c74c5f..b1962e6 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -141,7 +141,7 @@ typedef struct Dict {
* the dictionary. Used for doing traversal of
* the entries in the order that they are
* created. */
- int epoch; /* Epoch counter */
+ unsigned int epoch; /* Epoch counter */
size_t refCount; /* Reference counter (see above) */
Tcl_Obj *chain; /* Linked list used for invalidating the
* string representations of updated nested
@@ -390,7 +390,7 @@ DupDictInternalRep(
* Initialise other fields.
*/
- newDict->epoch = 0;
+ newDict->epoch = 1;
newDict->chain = NULL;
newDict->refCount = 1;
@@ -710,7 +710,7 @@ SetDictFromAny(
*/
TclFreeIntRep(objPtr);
- dict->epoch = 0;
+ dict->epoch = 1;
dict->chain = NULL;
dict->refCount = 1;
DICT(objPtr) = dict;
@@ -1109,7 +1109,7 @@ Tcl_DictObjFirst(
dict = DICT(dictPtr);
cPtr = dict->entryChainHead;
if (cPtr == NULL) {
- searchPtr->epoch = -1;
+ searchPtr->epoch = 0;
*donePtr = 1;
} else {
*donePtr = 0;
@@ -1170,7 +1170,7 @@ Tcl_DictObjNext(
* If the searh is done; we do no work.
*/
- if (searchPtr->epoch == -1) {
+ if (!searchPtr->epoch) {
*donePtr = 1;
return;
}
@@ -1227,8 +1227,8 @@ Tcl_DictObjDone(
{
Dict *dict;
- if (searchPtr->epoch != -1) {
- searchPtr->epoch = -1;
+ if (searchPtr->epoch) {
+ searchPtr->epoch = 0;
dict = (Dict *) searchPtr->dictionaryPtr;
if (dict->refCount-- <= 1) {
DeleteDict(dict);
@@ -1380,7 +1380,7 @@ Tcl_NewDictObj(void)
TclInvalidateStringRep(dictPtr);
dict = ckalloc(sizeof(Dict));
InitChainTable(dict);
- dict->epoch = 0;
+ dict->epoch = 1;
dict->chain = NULL;
dict->refCount = 1;
DICT(dictPtr) = dict;
@@ -1430,7 +1430,7 @@ Tcl_DbNewDictObj(
TclInvalidateStringRep(dictPtr);
dict = ckalloc(sizeof(Dict));
InitChainTable(dict);
- dict->epoch = 0;
+ dict->epoch = 1;
dict->chain = NULL;
dict->refCount = 1;
DICT(dictPtr) = dict;
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 68056c6..46bcb8c 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1277,12 +1277,12 @@ TclStackAlloc(
int numBytes)
{
Interp *iPtr = (Interp *) interp;
- int numWords = (numBytes + (sizeof(Tcl_Obj *) - 1))/sizeof(Tcl_Obj *);
+ int numWords;
if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
return (void *) ckalloc(numBytes);
}
-
+ numWords = (numBytes + (sizeof(Tcl_Obj *) - 1))/sizeof(Tcl_Obj *);
return (void *) StackAllocWords(interp, numWords);
}
@@ -9272,16 +9272,7 @@ IllegalExprOperandType(
}
if (GetNumberFromObj(NULL, opndPtr, &ptr, &type) != TCL_OK) {
- int numBytes;
- const char *bytes = TclGetStringFromObj(opndPtr, &numBytes);
-
- if (numBytes == 0) {
- description = "empty string";
- } else if (TclCheckBadOctal(NULL, bytes)) {
- description = "invalid octal number";
- } else {
- description = "non-numeric string";
- }
+ description = "non-numeric string";
} else if (type == TCL_NUMBER_NAN) {
description = "non-numeric floating-point value";
} else if (type == TCL_NUMBER_DOUBLE) {
@@ -9292,7 +9283,8 @@ IllegalExprOperandType(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't use %s as operand of \"%s\"", description, operator));
+ "can't use %s \"%s\" as operand of \"%s\"", description,
+ Tcl_GetString(opndPtr), operator));
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", description, NULL);
}
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 3c820c0..32c9aec 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -985,12 +985,18 @@ static void
RebuildTable(
register Tcl_HashTable *tablePtr) /* Table to enlarge. */
{
- int oldSize, count, index;
- Tcl_HashEntry **oldBuckets;
+ int count, index, oldSize = tablePtr->numBuckets;
+ Tcl_HashEntry **oldBuckets = tablePtr->buckets;
register Tcl_HashEntry **oldChainPtr, **newChainPtr;
register Tcl_HashEntry *hPtr;
const Tcl_HashKeyType *typePtr;
+ /* Avoid outgrowing capability of the memory allocators */
+ if (oldSize > (int)(UINT_MAX / (4 * sizeof(Tcl_HashEntry *)))) {
+ tablePtr->rebuildSize = INT_MAX;
+ return;
+ }
+
if (tablePtr->keyType == TCL_STRING_KEYS) {
typePtr = &tclStringHashKeyType;
} else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) {
@@ -1002,9 +1008,6 @@ RebuildTable(
typePtr = &tclArrayHashKeyType;
}
- oldSize = tablePtr->numBuckets;
- oldBuckets = tablePtr->buckets;
-
/*
* Allocate and initialize the new bucket array, and set up hashing
* constants for new array size.
diff --git a/generic/tclHistory.c b/generic/tclHistory.c
index 47806d4..0c8201a 100644
--- a/generic/tclHistory.c
+++ b/generic/tclHistory.c
@@ -74,13 +74,6 @@ Tcl_RecordAndEval(
result = Tcl_RecordAndEvalObj(interp, cmdPtr, flags);
/*
- * Move the interpreter's object result to the string result, then
- * reset the object result.
- */
-
- (void) Tcl_GetStringResult(interp);
-
- /*
* Discard the Tcl object created to hold the command.
*/
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 10938dd..17e5c87 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -1773,41 +1773,31 @@ typedef struct AllocCache {
typedef struct Interp {
/*
- * Note: the first three fields must match exactly the fields in a
- * Tcl_Interp struct (see tcl.h). If you change one, be sure to change the
- * other.
- *
- * The interpreter's result is held in both the string and the
- * objResultPtr fields. These fields hold, respectively, the result's
- * string or object value. The interpreter's result is always in the
- * result field if that is non-empty, otherwise it is in objResultPtr.
- * The two fields are kept consistent unless some C code sets
- * interp->result directly. Programs should not access result and
- * objResultPtr directly; instead, they should always get and set the
- * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult, and
- * Tcl_GetStringResult. See the SetResult man page for details.
+ * The first two fields were named "result" and "freeProc" in earlier
+ * versions of Tcl. They are no longer used within Tcl, and are no
+ * longer available to be accessed by extensions. However, they cannot
+ * be removed. Why? There is a deployed base of stub-enabled extensions
+ * that query the value of iPtr->stubTable. For them to continue to work,
+ * the location of the field "stubTable" within the Interp struct cannot
+ * change. The most robust way to assure that is to leave all fields up to
+ * that one undisturbed.
*/
- char *result; /* If the last command returned a string
- * result, this points to it. Should not be
- * accessed directly; see comment above. */
- Tcl_FreeProc *freeProc; /* Zero means a string result is statically
- * allocated. TCL_DYNAMIC means string result
- * was allocated with ckalloc and should be
- * freed with ckfree. Other values give
- * address of procedure to invoke to free the
- * string result. Tcl_Eval must free it before
- * executing next command. */
+ const char *legacyResult;
+ void (*legacyFreeProc) (void);
int errorLine; /* When TCL_ERROR is returned, this gives the
* line number in the command where the error
* occurred (1 means first line). */
const struct TclStubs *stubTable;
- /* Pointer to the exported Tcl stub table. On
- * previous versions of Tcl this is a pointer
- * to the objResultPtr or a pointer to a
- * buckets array in a hash table. We therefore
- * have to do some careful checking before we
- * can use this. */
+ /* Pointer to the exported Tcl stub table. In
+ * ancient pre-8.1 versions of Tcl this was a
+ * pointer to the objResultPtr or a pointer to a
+ * buckets array in a hash table. Deployed stubs
+ * enabled extensions check for a NULL pointer value
+ * and for a TCL_STUBS_MAGIC value to verify they
+ * are not [load]ing into one of those pre-stubs
+ * interps.
+ */
TclHandle handle; /* Handle used to keep track of when this
* interp is deleted. */
@@ -1858,25 +1848,6 @@ typedef struct Interp {
* TCL_EVAL_INVOKE call to Tcl_EvalObjv. */
/*
- * Information used by Tcl_AppendResult to keep track of partial results.
- * See Tcl_AppendResult code for details.
- */
-
-#ifndef TCL_NO_DEPRECATED
- char *appendResult; /* Storage space for results generated by
- * Tcl_AppendResult. Ckalloc-ed. NULL means
- * not yet allocated. */
- int appendAvl; /* Total amount of space available at
- * partialResult. */
- int appendUsed; /* Number of non-null bytes currently stored
- * at partialResult. */
-#else
- char *appendResultDontUse;
- int appendAvlDontUse;
- int appendUsedDontUse;
-#endif
-
- /*
* Information about packages. Used only in tclPkg.c.
*/
@@ -1898,7 +1869,6 @@ typedef struct Interp {
* Normally zero, but may be set before
* calling Tcl_Eval. See below for valid
* values. */
- int unused1; /* No longer used (was termOffset) */
LiteralTable literalTable; /* Contains LiteralEntry's describing all Tcl
* objects holding literals of scripts
* compiled by the interpreter. Indexed by the
@@ -1936,12 +1906,6 @@ typedef struct Interp {
* string. Returned by Tcl_ObjSetVar2 when
* variable traces change a variable in a
* gross way. */
-#ifndef TCL_NO_DEPRECATED
- char resultSpace[TCL_RESULT_SIZE+1];
- /* Static space holding small results. */
-#else
- char resultSpaceDontUse[TCL_RESULT_SIZE+1];
-#endif
Tcl_Obj *objResultPtr; /* If the last command returned an object
* result, this points to it. Should not be
* accessed directly; see comment above. */
@@ -2887,8 +2851,6 @@ MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string,
MODULE_SCOPE double TclCeil(const mp_int *a);
MODULE_SCOPE void TclChannelPreserve(Tcl_Channel chan);
MODULE_SCOPE void TclChannelRelease(Tcl_Channel chan);
-MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp,
- const char *value);
MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp,
Tcl_Channel chan);
MODULE_SCOPE Tcl_ObjCmdProc TclChannelNamesCmd;
@@ -4468,7 +4430,7 @@ MODULE_SCOPE int TclIsPureByteArray(Tcl_Obj *objPtr);
/*
*----------------------------------------------------------------
- * Macro used by the Tcl core to increment a namespace's export export epoch
+ * Macro used by the Tcl core to increment a namespace's export epoch
* counter. The ANSI C "prototype" for this macro is:
*
* MODULE_SCOPE void TclInvalidateNsCmdLookup(Namespace *nsPtr);
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 11374cc..f94433b 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -55,20 +55,22 @@ const Tcl_ObjType tclListType = {
*
* NewListIntRep --
*
- * Creates a list internal rep with space for objc elements. objc
- * must be > 0. If objv!=NULL, initializes with the first objc values
- * in that array. If objv==NULL, initalize list internal rep to have
- * 0 elements, with space to add objc more. Flag value "p" indicates
+ * Creates a 'List' structure with space for 'objc' elements. 'objc' must
+ * be > 0. If 'objv' is not NULL, The list is initialized with first
+ * 'objc' values in that array. Otherwise the list is initialized to have
+ * 0 elements, with space to add 'objc' more. Flag value 'p' indicates
* how to behave on failure.
*
- * Results:
- * A new List struct with refCount 0 is returned. If some failure
- * prevents this then if p=0, NULL is returned and otherwise the
- * routine panics.
+ * Value
*
- * Side effects:
- * The ref counts of the elements in objv are incremented since the
- * resulting list now refers to them.
+ * A new 'List' structure with refCount 0. If some failure
+ * prevents this NULL is returned if 'p' is 0 , and 'Tcl_Panic'
+ * is called if it is not.
+ *
+ * Effect
+ *
+ * The refCount of each value in 'objv' is incremented as it is added
+ * to the list.
*
*----------------------------------------------------------------------
*/
@@ -132,22 +134,10 @@ NewListIntRep(
/*
*----------------------------------------------------------------------
*
- * AttemptNewList --
- *
- * Creates a list internal rep with space for objc elements. objc
- * must be > 0. If objv!=NULL, initializes with the first objc values
- * in that array. If objv==NULL, initalize list internal rep to have
- * 0 elements, with space to add objc more.
- *
- * Results:
- * A new List struct with refCount 0 is returned. If some failure
- * prevents this then NULL is returned, and an error message is left
- * in the interp result, unless interp is NULL.
- *
- * Side effects:
- * The ref counts of the elements in objv are incremented since the
- * resulting list now refers to them.
+ * AttemptNewList --
*
+ * Like NewListIntRep, but additionally sets an error message on failure.
+ *
*----------------------------------------------------------------------
*/
@@ -179,23 +169,20 @@ AttemptNewList(
*
* Tcl_NewListObj --
*
- * This function is normally called when not debugging: i.e., when
- * TCL_MEM_DEBUG is not defined. It creates a new list object from an
- * (objc,objv) array: that is, each of the objc elements of the array
- * referenced by objv is inserted as an element into a new Tcl object.
+ * Creates a new list object and adds values to it. When TCL_MEM_DEBUG is
+ * defined, 'Tcl_DbNewListObj' is called instead.
*
- * When TCL_MEM_DEBUG is defined, this function just returns the result
- * of calling the debugging version Tcl_DbNewListObj.
+ * Value
*
- * Results:
- * A new list object is returned that is initialized from the object
- * pointers in objv. If objc is less than or equal to zero, an empty
- * object is returned. The new object's string representation is left
- * NULL. The resulting new list object has ref count 0.
+ * A new list 'Tcl_Obj' to which is appended values from 'objv', or if
+ * 'objc' is less than or equal to zero, a list 'Tcl_Obj' having no
+ * elements. The string representation of the new 'Tcl_Obj' is set to
+ * NULL. The refCount of the list is 0.
*
- * Side effects:
- * The ref counts of the elements in objv are incremented since the
- * resulting list now refers to them.
+ * Effect
+ *
+ * The refCount of each elements in 'objv' is incremented as it is added
+ * to the list.
*
*----------------------------------------------------------------------
*/
@@ -246,28 +233,14 @@ Tcl_NewListObj(
/*
*----------------------------------------------------------------------
*
- * Tcl_DbNewListObj --
- *
- * This function is normally called when debugging: i.e., when
- * TCL_MEM_DEBUG is defined. It creates new list objects. It is the same
- * as the Tcl_NewListObj function above except that it calls
- * Tcl_DbCkalloc directly with the file name and line number from its
- * caller. This simplifies debugging since then the [memory active]
- * command will report the correct file name and line number when
- * reporting objects that haven't been freed.
- *
- * When TCL_MEM_DEBUG is not defined, this function just returns the
- * result of calling Tcl_NewListObj.
- *
- * Results:
- * A new list object is returned that is initialized from the object
- * pointers in objv. If objc is less than or equal to zero, an empty
- * object is returned. The new object's string representation is left
- * NULL. The new list object has ref count 0.
- *
- * Side effects:
- * The ref counts of the elements in objv are incremented since the
- * resulting list now refers to them.
+ * Tcl_DbNewListObj --
+ *
+ * Like 'Tcl_NewListObj', but it calls Tcl_DbCkalloc directly with the
+ * file name and line number from its caller. This simplifies debugging
+ * since the [memory active] command will report the correct file
+ * name and line number when reporting objects that haven't been freed.
+ *
+ * When TCL_MEM_DEBUG is not defined, 'Tcl_NewListObj' is called instead.
*
*----------------------------------------------------------------------
*/
@@ -328,19 +301,8 @@ Tcl_DbNewListObj(
*
* Tcl_SetListObj --
*
- * Modify an object to be a list containing each of the objc elements of
- * the object array referenced by objv.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The object is made a list object and is initialized from the object
- * pointers in objv. If objc is less than or equal to zero, an empty
- * object is returned. The new object's string representation is left
- * NULL. The ref counts of the elements in objv are incremented since the
- * list now refers to them. The object's old string and internal
- * representations are freed and its type is set NULL.
+ * Like 'Tcl_NewListObj', but operates on an existing 'Tcl_Obj'instead of
+ * creating a new one.
*
*----------------------------------------------------------------------
*/
@@ -384,18 +346,20 @@ Tcl_SetListObj(
*
* TclListObjCopy --
*
- * Makes a "pure list" copy of a list value. This provides for the C
- * level a counterpart of the [lrange $list 0 end] command, while using
- * internals details to be as efficient as possible.
+ * Creates a new 'Tcl_Obj' which is a pure copy of a list value. This
+ * provides for the C level a counterpart of the [lrange $list 0 end]
+ * command, while using internals details to be as efficient as possible.
+ *
+ * Value
*
- * Results:
- * Normally returns a pointer to a new Tcl_Obj, that contains the same
- * list value as *listPtr does. The returned Tcl_Obj has a refCount of
- * zero. If *listPtr does not hold a list, NULL is returned, and if
- * interp is non-NULL, an error message is recorded there.
+ * The address of the new 'Tcl_Obj' which shares its internal
+ * representation with 'listPtr', and whose refCount is 0. If 'listPtr'
+ * is not actually a list, the value is NULL, and an error message is left
+ * in 'interp' if it is not NULL.
*
- * Side effects:
- * None.
+ * Effect
+ *
+ * 'listPtr' is converted to a list if it isn't one already.
*
*----------------------------------------------------------------------
*/
@@ -425,27 +389,30 @@ TclListObjCopy(
*
* Tcl_ListObjGetElements --
*
- * This function returns an (objc,objv) array of the elements in a list
- * object.
+ * Retreive the elements in a list 'Tcl_Obj'.
+ *
+ * Value
+ *
+ * TCL_OK
+ *
+ * A count of list elements is stored, 'objcPtr', And a pointer to the
+ * array of elements in the list is stored in 'objvPtr'.
*
- * Results:
- * The return value is normally TCL_OK; in this case *objcPtr is set to
- * the count of list elements and *objvPtr is set to a pointer to an
- * array of (*objcPtr) pointers to each list element. If listPtr does not
- * refer to a list object and the object can not be converted to one,
- * TCL_ERROR is returned and an error message will be left in the
- * interpreter's result if interp is not NULL.
+ * The elements accessible via 'objvPtr' should be treated as readonly
+ * and the refCount for each object is _not_ incremented; the caller
+ * must do that if it holds on to a reference. Furthermore, the
+ * pointer and length returned by this function may change as soon as
+ * any function is called on the list object. Be careful about
+ * retaining the pointer in a local data structure.
*
- * The objects referenced by the returned array should be treated as
- * readonly and their ref counts are _not_ incremented; the caller must
- * do that if it holds on to a reference. Furthermore, the pointer and
- * length returned by this function may change as soon as any function is
- * called on the list object; be careful about retaining the pointer in a
- * local data structure.
+ * TCL_ERROR
*
- * Side effects:
- * The possible conversion of the object referenced by listPtr
- * to a list object.
+ * 'listPtr' is not a valid list. An error message is left in the
+ * interpreter's result if 'interp' is not NULL.
+ *
+ * Effect
+ *
+ * 'listPtr' is converted to a list object if it isn't one already.
*
*----------------------------------------------------------------------
*/
@@ -486,20 +453,27 @@ Tcl_ListObjGetElements(
*
* Tcl_ListObjAppendList --
*
- * This function appends the elements in the list value referenced by
- * elemListPtr to the list value referenced by listPtr.
+ * Appends the elements of elemListPtr to those of listPtr.
+ *
+ * Value
+ *
+ * TCL_OK
+ *
+ * Success.
*
- * Results:
- * The return value is normally TCL_OK. If listPtr or elemListPtr do not
- * refer to list values, TCL_ERROR is returned and an error message is
- * left in the interpreter's result if interp is not NULL.
+ * TCL_ERROR
*
- * Side effects:
- * The reference counts of the elements in elemListPtr are incremented
- * since the list now refers to them. listPtr and elemListPtr are
- * converted, if necessary, to list objects. Also, appending the new
- * elements may cause listObj's array of element pointers to grow.
- * listPtr's old string representation, if any, is invalidated.
+ * 'listPtr' or 'elemListPtr' are not valid lists. An error
+ * message is left in the interpreter's result if 'interp' is not NULL.
+ *
+ * Effect
+ *
+ * The reference count of each element of 'elemListPtr' as it is added to
+ * 'listPtr'. 'listPtr' and 'elemListPtr' are converted to 'tclListType'
+ * if they are not already. Appending the new elements may cause the
+ * array of element pointers in 'listObj' to grow. If any objects are
+ * appended to 'listPtr'. Any preexisting string representation of
+ * 'listPtr' is invalidated.
*
*----------------------------------------------------------------------
*/
@@ -538,24 +512,27 @@ Tcl_ListObjAppendList(
*
* Tcl_ListObjAppendElement --
*
- * This function is a special purpose version of Tcl_ListObjAppendList:
- * it appends a single object referenced by objPtr to the list object
- * referenced by listPtr. If listPtr is not already a list object, an
- * attempt will be made to convert it to one.
- *
- * Results:
- * The return value is normally TCL_OK; in this case objPtr is added to
- * the end of listPtr's list. If listPtr does not refer to a list object
- * and the object can not be converted to one, TCL_ERROR is returned and
- * an error message will be left in the interpreter's result if interp is
- * not NULL.
- *
- * Side effects:
- * The ref count of objPtr is incremented since the list now refers to
- * it. listPtr will be converted, if necessary, to a list object. Also,
- * appending the new element may cause listObj's array of element
- * pointers to grow. listPtr's old string representation, if any, is
- * invalidated.
+ * Like 'Tcl_ListObjAppendList', but Appends a single value to a list.
+ *
+ * Value
+ *
+ * TCL_OK
+ *
+ * 'objPtr' is appended to the elements of 'listPtr'.
+ *
+ * TCL_ERROR
+ *
+ * listPtr does not refer to a list object and the object can not be
+ * converted to one. An error message will be left in the
+ * interpreter's result if interp is not NULL.
+ *
+ * Effect
+ *
+ * If 'listPtr' is not already of type 'tclListType', it is converted.
+ * The 'refCount' of 'objPtr' is incremented as it is added to 'listPtr'.
+ * Appending the new element may cause the the array of element pointers
+ * in 'listObj' to grow. Any preexisting string representation of
+ * 'listPtr' is invalidated.
*
*----------------------------------------------------------------------
*/
@@ -706,23 +683,27 @@ Tcl_ListObjAppendElement(
*
* Tcl_ListObjIndex --
*
- * This function returns a pointer to the index'th object from the list
- * referenced by listPtr. The first element has index 0. If index is
- * negative or greater than or equal to the number of elements in the
- * list, a NULL is returned. If listPtr is not a list object, an attempt
- * will be made to convert it to a list.
+ * Retrieve a pointer to the element of 'listPtr' at 'index'. The index
+ * of the first element is 0.
+ *
+ * Value
+ *
+ * TCL_OK
*
- * Results:
- * The return value is normally TCL_OK; in this case objPtrPtr is set to
- * the Tcl_Obj pointer for the index'th list element or NULL if index is
- * out of range. This object should be treated as readonly and its ref
- * count is _not_ incremented; the caller must do that if it holds on to
- * the reference. If listPtr does not refer to a list and can't be
- * converted to one, TCL_ERROR is returned and an error message is left
- * in the interpreter's result if interp is not NULL.
+ * A pointer to the element at 'index' is stored in 'objPtrPtr'. If
+ * 'index' is out of range, NULL is stored in 'objPtrPtr'. This
+ * object should be treated as readonly and its 'refCount' is _not_
+ * incremented. The caller must do that if it holds on to the
+ * reference.
+ *
+ * TCL_ERROR
*
- * Side effects:
- * listPtr will be converted, if necessary, to a list object.
+ * 'listPtr' is not a valid list. An an error message is left in the
+ * interpreter's result if 'interp' is not NULL.
+ *
+ * Effect
+ *
+ * If 'listPtr' is not already of type 'tclListType', it is converted.
*
*----------------------------------------------------------------------
*/
@@ -764,19 +745,20 @@ Tcl_ListObjIndex(
*
* Tcl_ListObjLength --
*
- * This function returns the number of elements in a list object. If the
- * object is not already a list object, an attempt will be made to
- * convert it to one.
+ * Retrieve the number of elements in a list.
+ *
+ * Value
+ *
+ * TCL_OK
+ *
+ * A count of list elements is stored at the address provided by
+ * 'intPtr'. If 'listPtr' is not already of type 'tclListPtr', it is
+ * converted.
*
- * Results:
- * The return value is normally TCL_OK; in this case *intPtr will be set
- * to the integer count of list elements. If listPtr does not refer to a
- * list object and the object can not be converted to one, TCL_ERROR is
- * returned and an error message will be left in the interpreter's result
- * if interp is not NULL.
+ * TCL_ERROR
*
- * Side effects:
- * The possible conversion of the argument object to a list object.
+ * 'listPtr' is not a valid list. An error message will be left in
+ * the interpreter's result if 'interp' is not NULL.
*
*----------------------------------------------------------------------
*/
@@ -812,35 +794,36 @@ Tcl_ListObjLength(
*
* Tcl_ListObjReplace --
*
- * This function replaces zero or more elements of the list referenced by
- * listPtr with the objects from an (objc,objv) array. The objc elements
- * of the array referenced by objv replace the count elements in listPtr
- * starting at first.
- *
- * If the argument first is zero or negative, it refers to the first
- * element. If first is greater than or equal to the number of elements
- * in the list, then no elements are deleted; the new elements are
- * appended to the list. Count gives the number of elements to replace.
- * If count is zero or negative then no elements are deleted; the new
- * elements are simply inserted before first.
- *
- * The argument objv refers to an array of objc pointers to the new
- * elements to be added to listPtr in place of those that were deleted.
- * If objv is NULL, no new elements are added. If listPtr is not a list
- * object, an attempt will be made to convert it to one.
- *
- * Results:
- * The return value is normally TCL_OK. If listPtr does not refer to a
- * list object and can not be converted to one, TCL_ERROR is returned and
- * an error message will be left in the interpreter's result if interp is
- * not NULL.
- *
- * Side effects:
- * The ref counts of the objc elements in objv are incremented since the
- * resulting list now refers to them. Similarly, the ref counts for
- * replaced objects are decremented. listPtr is converted, if necessary,
- * to a list object. listPtr's old string representation, if any, is
- * freed.
+ * Replace values in a list.
+ *
+ * If 'first' is zero or negative, it refers to the first element. If
+ * 'first' outside the range of elements in the list, no elements are
+ * deleted.
+ *
+ * If 'count' is zero or negative no elements are deleted, and any new
+ * elements are inserted at the beginning of the list.
+ *
+ * Value
+ *
+ * TCL_OK
+ *
+ * The first 'objc' values of 'objv' replaced 'count' elements in 'listPtr'
+ * starting at 'first'. If 'objc' 0, no new elements are added.
+ *
+ * TCL_ERROR
+ *
+ * 'listPtr' is not a valid list. An error message is left in the
+ * interpreter's result if 'interp' is not NULL.
+ *
+ * Effect
+ *
+ * If 'listPtr' is not of type 'tclListType', it is converted if possible.
+ *
+ * The 'refCount' of each element appended to the list is incremented.
+ * Similarly, the 'refCount' for each replaced element is decremented.
+ *
+ * If 'listPtr' is modified, any previous string representation is
+ * invalidated.
*
*----------------------------------------------------------------------
*/
@@ -1098,22 +1081,19 @@ Tcl_ListObjReplace(
*
* TclLindexList --
*
- * This procedure handles the 'lindex' command when objc==3.
+ * Implements the 'lindex' command when objc==3.
*
- * Results:
- * Returns a pointer to the object extracted, or NULL if an error
- * occurred. The returned object already includes one reference count for
- * the pointer returned.
+ * Implemented entirely as a wrapper around 'TclLindexFlat'. Reconfigures
+ * the argument format into required form while taking care to manage
+ * shimmering so as to tend to keep the most useful intreps
+ * and/or avoid the most expensive conversions.
*
- * Side effects:
- * None.
+ * Value
*
- * Notes:
- * This procedure is implemented entirely as a wrapper around
- * TclLindexFlat. All it does is reconfigure the argument format into the
- * form required by TclLindexFlat, while taking care to manage shimmering
- * in such a way that we tend to keep the most useful intreps and/or
- * avoid the most expensive conversions.
+ * A pointer to the specified element, with its 'refCount' incremented, or
+ * NULL if an error occurred.
+ *
+ * Notes
*
*----------------------------------------------------------------------
*/
@@ -1185,25 +1165,20 @@ TclLindexList(
/*
*----------------------------------------------------------------------
*
- * TclLindexFlat --
+ * TclLindexFlat --
+ *
+ * The core of the 'lindex' command, with all index
+ * arguments presented as a flat list.
*
- * This procedure is the core of the 'lindex' command, with all index
- * arguments presented as a flat list.
+ * Value
*
- * Results:
- * Returns a pointer to the object extracted, or NULL if an error
- * occurred. The returned object already includes one reference count for
- * the pointer returned.
+ * A pointer to the object extracted, with its 'refCount' incremented, or
+ * NULL if an error occurred. Thus, the calling code will usually do
+ * something like:
*
- * Side effects:
- * None.
+ * Tcl_SetObjResult(interp, result);
+ * Tcl_DecrRefCount(result);
*
- * Notes:
- * The reference count of the returned object includes one reference
- * corresponding to the pointer returned. Thus, the calling code will
- * usually do something like:
- * Tcl_SetObjResult(interp, result);
- * Tcl_DecrRefCount(result);
*
*----------------------------------------------------------------------
*/
@@ -1279,23 +1254,16 @@ TclLindexFlat(
*
* TclLsetList --
*
- * Core of the 'lset' command when objc == 4. Objv[2] may be either a
+ * The core of [lset] when objc == 4. Objv[2] may be either a
* scalar index or a list of indices.
*
- * Results:
- * Returns the new value of the list variable, or NULL if there was an
- * error. The returned object includes one reference count for the
- * pointer returned.
+ * Implemented entirely as a wrapper around 'TclLindexFlat', as described
+ * for 'TclLindexList'.
*
- * Side effects:
- * None.
+ * Value
*
- * Notes:
- * This procedure is implemented entirely as a wrapper around
- * TclLsetFlat. All it does is reconfigure the argument format into the
- * form required by TclLsetFlat, while taking care to manage shimmering
- * in such a way that we tend to keep the most useful intreps and/or
- * avoid the most expensive conversions.
+ * The new list, with the 'refCount' of 'valuPtr' incremented, or NULL if
+ * there was an error.
*
*----------------------------------------------------------------------
*/
@@ -1357,36 +1325,39 @@ TclLsetList(
*
* Core engine of the 'lset' command.
*
- * Results:
- * Returns the new value of the list variable, or NULL if an error
- * occurred. The returned object includes one reference count for the
- * pointer returned.
- *
- * Side effects:
- * On entry, the reference count of the variable value does not reflect
- * any references held on the stack. The first action of this function is
- * to determine whether the object is shared, and to duplicate it if it
- * is. The reference count of the duplicate is incremented. At this
- * point, the reference count will be 1 for either case, so that the
- * object will appear to be unshared.
- *
- * If an error occurs, and the object has been duplicated, the reference
- * count on the duplicate is decremented so that it is now 0: this
- * dismisses any memory that was allocated by this function.
- *
- * If no error occurs, the reference count of the original object is
- * incremented if the object has not been duplicated, and nothing is done
- * to a reference count of the duplicate. Now the reference count of an
- * unduplicated object is 2 (the returned pointer, plus the one stored in
- * the variable). The reference count of a duplicate object is 1,
- * reflecting that the returned pointer is the only active reference. The
- * caller is expected to store the returned value back in the variable
- * and decrement its reference count. (INST_STORE_* does exactly this.)
- *
- * Surgery is performed on the unshared list value to produce the result.
- * TclLsetFlat maintains a linked list of Tcl_Obj's whose string
+ * Value
+ *
+ * The resulting list
+ *
+ * The 'refCount' of 'valuePtr' is incremented. If 'listPtr' was not
+ * duplicated, its 'refCount' is incremented. The reference count of
+ * an unduplicated object is therefore 2 (one for the returned pointer
+ * and one for the variable that holds it). The reference count of a
+ * duplicate object is 1, reflecting that result is the only active
+ * reference. The caller is expected to store the result in the
+ * variable and decrement its reference count. (INST_STORE_* does
+ * exactly this.)
+ *
+ * NULL
+ *
+ * An error occurred. If 'listPtr' was duplicated, the reference
+ * count on the duplicate is decremented so that it is 0, causing any
+ * memory allocated by this function to be freed.
+ *
+ *
+ * Effect
+ *
+ * On entry, the reference count of 'listPtr' does not reflect any
+ * references held on the stack. The first action of this function is to
+ * determine whether 'listPtr' is shared and to create a duplicate
+ * unshared copy if it is. The reference count of the duplicate is
+ * incremented. At this point, the reference count is 1 in either case so
+ * that the object is considered unshared.
+ *
+ * The unshared list is altered directly to produce the result.
+ * 'TclLsetFlat' maintains a linked list of 'Tcl_Obj' values whose string
* representations must be spoilt by threading via 'ptr2' of the
- * two-pointer internal representation. On entry to TclLsetFlat, the
+ * two-pointer internal representation. On entry to 'TclLsetFlat', the
* values of 'ptr2' are immaterial; on exit, the 'ptr2' field of any
* Tcl_Obj that has been modified is set to NULL.
*
@@ -1601,26 +1572,38 @@ TclLsetFlat(
*
* TclListObjSetElement --
*
- * Set a single element of a list to a specified value
+ * Set a single element of a list to a specified value.
*
- * Results:
- * The return value is normally TCL_OK. If listPtr does not refer to a
- * list object and cannot be converted to one, TCL_ERROR is returned and
- * an error message will be left in the interpreter result if interp is
- * not NULL. Similarly, if index designates an element outside the range
- * [0..listLength-1], where listLength is the count of elements in the
- * list object designated by listPtr, TCL_ERROR is returned and an error
- * message is left in the interpreter result.
+ * It is the caller's responsibility to invalidate the string
+ * representation of the 'listPtr'.
*
- * Side effects:
- * Tcl_Panic if listPtr designates a shared object. Otherwise, attempts
- * to convert it to a list with a non-shared internal rep. Decrements the
- * ref count of the object at the specified index within the list,
- * replaces with the object designated by valuePtr, and increments the
- * ref count of the replacement object.
+ * Value
+ *
+ * TCL_OK
+ *
+ * Success.
+ *
+ * TCL_ERROR
+ *
+ * 'listPtr' does not refer to a list object and cannot be converted
+ * to one. An error message will be left in the interpreter result if
+ * interp is not NULL.
+ *
+ * TCL_ERROR
+ *
+ * An index designates an element outside the range [0..listLength-1],
+ * where 'listLength' is the count of elements in the list object
+ * designated by 'listPtr'. An error message is left in the
+ * interpreter result.
+ *
+ * Effect
+ *
+ * If 'listPtr' designates a shared object, 'Tcl_Panic' is called. If
+ * 'listPtr' is not already of type 'tclListType', it is converted and the
+ * internal representation is unshared. The 'refCount' of the element at
+ * 'index' is decremented and replaced in the list with the 'valuePtr',
+ * whose 'refCount' in turn is incremented.
*
- * It is the caller's responsibility to invalidate the string
- * representation of the object.
*
*----------------------------------------------------------------------
*/
@@ -1738,16 +1721,14 @@ TclListObjSetElement(
*
* FreeListInternalRep --
*
- * Deallocate the storage associated with a list object's internal
- * representation.
+ * Deallocate the storage associated with the internal representation of a
+ * a list object.
*
- * Results:
- * None.
+ * Effect
*
- * Side effects:
- * Frees listPtr's List* internal representation and sets listPtr's
- * internalRep.twoPtrValue.ptr1 to NULL. Decrements the ref counts of all
- * element objects, which may free them.
+ * The storage for the internal 'List' pointer of 'listPtr' is freed, the
+ * 'internalRep.twoPtrValue.ptr1' of 'listPtr' is set to NULL, and the 'refCount'
+ * of each element of the list is decremented.
*
*----------------------------------------------------------------------
*/
@@ -1776,14 +1757,12 @@ FreeListInternalRep(
*
* DupListInternalRep --
*
- * Initialize the internal representation of a list Tcl_Obj to share the
+ * Initialize the internal representation of a list 'Tcl_Obj' to share the
* internal representation of an existing list object.
*
- * Results:
- * None.
+ * Effect
*
- * Side effects:
- * The reference count of the List internal rep is incremented.
+ * The 'refCount' of the List internal rep is incremented.
*
*----------------------------------------------------------------------
*/
@@ -1803,16 +1782,20 @@ DupListInternalRep(
*
* SetListFromAny --
*
- * Attempt to generate a list internal form for the Tcl object "objPtr".
+ * Convert any object to a list.
+ *
+ * Value
*
- * Results:
- * The return value is TCL_OK or TCL_ERROR. If an error occurs during
- * conversion, an error message is left in the interpreter's result
- * unless "interp" is NULL.
+ * TCL_OK
+ *
+ * Success. The internal representation of 'objPtr' is set, and the type
+ * of 'objPtr' is 'tclListType'.
+ *
+ * TCL_ERROR
+ *
+ * An error occured during conversion. An error message is left in the
+ * interpreter's result if 'interp' is not NULL.
*
- * Side effects:
- * If no error occurs, a list is stored as "objPtr"s internal
- * representation.
*
*----------------------------------------------------------------------
*/
@@ -1937,18 +1920,16 @@ SetListFromAny(
*
* UpdateStringOfList --
*
- * Update the string representation for a list object. Note: This
- * function does not invalidate an existing old string rep so storage
- * will be lost if this has not already been done.
+ * Update the string representation for a list object.
+ *
+ * Any previously-exising string representation is not invalidated, so
+ * storage is lost if this has not been taken care of.
*
- * Results:
- * None.
+ * Effect
*
- * Side effects:
- * The object's string is set to a valid string that results from the
- * list-to-string conversion. This string will be empty if the list has
- * no elements. The list internal representation should not be NULL and
- * we assume it is not NULL.
+ * The string representation of 'listPtr' is set to the resulting string.
+ * This string will be empty if the list has no elements. It is assumed
+ * that the list internal representation is not NULL.
*
*----------------------------------------------------------------------
*/
diff --git a/generic/tclLoad.c b/generic/tclLoad.c
index e0bb5ef..4e6ee2f 100644
--- a/generic/tclLoad.c
+++ b/generic/tclLoad.c
@@ -470,6 +470,17 @@ Tcl_LoadObjCmd(
*/
if (code != TCL_OK) {
+ Interp *iPtr = (Interp *) target;
+ if (iPtr->legacyResult && !iPtr->legacyFreeProc) {
+ /*
+ * A call to Tcl_InitStubs() determined the caller extension and
+ * this interp are incompatible in their stubs mechanisms, and
+ * recorded the error in the oldest legacy place we have to do so.
+ */
+ Tcl_SetObjResult(target, Tcl_NewStringObj(iPtr->legacyResult, -1));
+ iPtr->legacyResult = NULL;
+ iPtr->legacyFreeProc = (void (*) (void))-1;
+ }
Tcl_TransferResult(target, code, interp);
goto done;
}
diff --git a/generic/tclOO.c b/generic/tclOO.c
index 51731d3..e48158c 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -538,7 +538,8 @@ KillFoundation(
* AllocObject --
*
* Allocate an object of basic type. Does not splice the object into its
- * class's instance list.
+ * class's instance list. The caller must set the classPtr on the object,
+ * either to a class or to NULL.
*
* ----------------------------------------------------------------------
*/
@@ -1701,6 +1702,8 @@ Tcl_NewObjectInstance(
AllocClass(interp, oPtr);
oPtr->selfCls = classPtr;
TclOOAddToSubclasses(oPtr->classPtr, fPtr->objectCls);
+ } else {
+ oPtr->classPtr = NULL;
}
/*
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 634f8db..5e194c7 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -2434,23 +2434,26 @@ Tcl_SetIntObj(
*
* Tcl_GetIntFromObj --
*
- * Attempt to return an int from the Tcl object "objPtr". If the object
- * is not already an int, an attempt will be made to convert it to one.
+ * Retrieve the integer value of 'objPtr'.
*
- * Integer and long integer objects share the same "integer" type
- * implementation. We store all integers as longs and Tcl_GetIntFromObj
- * checks whether the current value of the long can be represented by an
- * int.
+ * Value
*
- * Results:
- * The return value is a standard Tcl object result. If an error occurs
- * during conversion or if the long integer held by the object can not be
- * represented by an int, an error message is left in the interpreter's
- * result unless "interp" is NULL.
+ * TCL_OK
*
- * Side effects:
- * If the object is not already an int, the conversion will free any old
- * internal representation.
+ * Success.
+ *
+ * TCL_ERROR
+ *
+ * An error occurred during conversion or the integral value can not
+ * be represented as an integer (it might be too large). An error
+ * message is left in the interpreter's result if 'interp' is not
+ * NULL.
+ *
+ * Effect
+ *
+ * 'objPtr' is converted to an integer if necessary if it is not one
+ * already. The conversion frees any previously-existing internal
+ * representation.
*
*----------------------------------------------------------------------
*/
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 133f41d..6a0ed75 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -393,13 +393,13 @@ TclCreateProc(
Proc **procPtrPtr) /* Returns: pointer to proc data. */
{
Interp *iPtr = (Interp *) interp;
- const char **argArray = NULL;
register Proc *procPtr;
- int i, length, result, numArgs;
- const char *args, *bytes, *p;
+ int i, result, numArgs, plen;
+ const char *bytes, *argname, *argnamei;
+ char argnamelast;
register CompiledLocal *localPtr = NULL;
- Tcl_Obj *defPtr;
+ Tcl_Obj *defPtr, *errorObj, **argArray;
int precompiled = 0;
if (bodyPtr->typePtr == &tclProcBodyType) {
@@ -436,6 +436,7 @@ TclCreateProc(
*/
if (Tcl_IsShared(bodyPtr)) {
+ int length;
Tcl_Obj *sharedBodyPtr = bodyPtr;
bytes = TclGetStringFromObj(bodyPtr, &length);
@@ -473,12 +474,9 @@ TclCreateProc(
* argument specifier. If the body is precompiled, processing is limited
* to checking that the parsed argument is consistent with the one stored
* in the Proc.
- *
- * THIS FAILS IF THE ARG LIST OBJECT'S STRING REP CONTAINS NULS.
*/
- args = TclGetStringFromObj(argsPtr, &length);
- result = Tcl_SplitList(interp, args, &numArgs, &argArray);
+ result = Tcl_ListObjGetElements(interp , argsPtr ,&numArgs ,&argArray);
if (result != TCL_OK) {
goto procError;
}
@@ -502,28 +500,28 @@ TclCreateProc(
for (i = 0; i < numArgs; i++) {
int fieldCount, nameLength;
size_t valueLength;
- const char **fieldValues;
+ Tcl_Obj **fieldValues;
/*
* Now divide the specifier up into name and default.
*/
- result = Tcl_SplitList(interp, argArray[i], &fieldCount,
+ result = Tcl_ListObjGetElements(interp, argArray[i], &fieldCount,
&fieldValues);
if (result != TCL_OK) {
goto procError;
}
if (fieldCount > 2) {
- ckfree(fieldValues);
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "too many fields in argument specifier \"%s\"",
- argArray[i]));
+ errorObj = Tcl_NewStringObj(
+ "too many fields in argument specifier \"", -1);
+ Tcl_AppendObjToObj(errorObj, argArray[i]);
+ Tcl_AppendToObj(errorObj, "\"", -1);
+ Tcl_SetObjResult(interp, errorObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
- if ((fieldCount == 0) || (*fieldValues[0] == 0)) {
- ckfree(fieldValues);
+ if ((fieldCount == 0) || (fieldValues[0]->length == 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"argument with no name", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
@@ -531,9 +529,10 @@ TclCreateProc(
goto procError;
}
- nameLength = strlen(fieldValues[0]);
+ nameLength = Tcl_NumUtfChars(Tcl_GetString(fieldValues[0]), fieldValues[0]->length);
if (fieldCount == 2) {
- valueLength = strlen(fieldValues[1]);
+ valueLength = Tcl_NumUtfChars(Tcl_GetString(fieldValues[1]),
+ fieldValues[1]->length);
} else {
valueLength = 0;
}
@@ -542,33 +541,29 @@ TclCreateProc(
* Check that the formal parameter name is a scalar.
*/
- p = fieldValues[0];
- while (*p != '\0') {
- if (*p == '(') {
- const char *q = p;
- do {
- q++;
- } while (*q != '\0');
- q--;
- if (*q == ')') { /* We have an array element. */
+ argname = Tcl_GetStringFromObj(fieldValues[0], &plen);
+ argnamei = argname;
+ argnamelast = argname[plen-1];
+ while (plen--) {
+ if (argnamei[0] == '(') {
+ if (argnamelast == ')') { /* We have an array element. */
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"formal parameter \"%s\" is an array element",
- fieldValues[0]));
- ckfree(fieldValues);
+ Tcl_GetString(fieldValues[0])));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
- } else if ((*p == ':') && (*(p+1) == ':')) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "formal parameter \"%s\" is not a simple name",
- fieldValues[0]));
- ckfree(fieldValues);
+ } else if ((argnamei[0] == ':') && (argnamei[1] == ':')) {
+ errorObj = Tcl_NewStringObj("formal parameter \"", -1);
+ Tcl_AppendObjToObj(errorObj, fieldValues[0]);
+ Tcl_AppendToObj(errorObj, "\" is not a simple name", -1);
+ Tcl_SetObjResult(interp, errorObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"FORMALARGUMENTFORMAT", NULL);
goto procError;
}
- p++;
+ argnamei = Tcl_UtfNext(argnamei);
}
if (precompiled) {
@@ -584,7 +579,7 @@ TclCreateProc(
*/
if ((localPtr->nameLength != nameLength)
- || (strcmp(localPtr->name, fieldValues[0]))
+ || (Tcl_UtfNcmp(localPtr->name, argname, nameLength))
|| (localPtr->frameIndex != i)
|| !(localPtr->flags & VAR_ARGUMENT)
|| (localPtr->defValuePtr == NULL && fieldCount == 2)
@@ -592,7 +587,6 @@ TclCreateProc(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"procedure \"%s\": formal parameter %d is "
"inconsistent with precompiled body", procName, i));
- ckfree(fieldValues);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"BYTECODELIES", NULL);
goto procError;
@@ -607,12 +601,13 @@ TclCreateProc(
size_t tmpLength = localPtr->defValuePtr->length;
if ((valueLength != tmpLength) ||
- strncmp(fieldValues[1], tmpPtr, tmpLength)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "procedure \"%s\": formal parameter \"%s\" has "
- "default value inconsistent with precompiled body",
- procName, fieldValues[0]));
- ckfree(fieldValues);
+ Tcl_UtfNcmp(Tcl_GetString(fieldValues[1]), tmpPtr, tmpLength)) {
+ errorObj = Tcl_ObjPrintf(
+ "procedure \"%s\": formal parameter \"" ,procName);
+ Tcl_AppendObjToObj(errorObj, fieldValues[0]);
+ Tcl_AppendToObj(errorObj, "\" has "
+ "default value inconsistent with precompiled body", -1);
+ Tcl_SetObjResult(interp, errorObj);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"BYTECODELIES", NULL);
goto procError;
@@ -632,7 +627,7 @@ TclCreateProc(
* local variables for the argument.
*/
- localPtr = ckalloc(TclOffset(CompiledLocal, name) + nameLength+1);
+ localPtr = ckalloc(TclOffset(CompiledLocal, name) + fieldValues[0]->length +1);
if (procPtr->firstLocalPtr == NULL) {
procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr;
} else {
@@ -640,19 +635,18 @@ TclCreateProc(
procPtr->lastLocalPtr = localPtr;
}
localPtr->nextPtr = NULL;
- localPtr->nameLength = nameLength;
+ localPtr->nameLength = Tcl_NumUtfChars(argname, fieldValues[0]->length);
localPtr->frameIndex = i;
localPtr->flags = VAR_ARGUMENT;
localPtr->resolveInfo = NULL;
if (fieldCount == 2) {
- localPtr->defValuePtr =
- Tcl_NewStringObj(fieldValues[1], valueLength);
+ localPtr->defValuePtr = fieldValues[1];
Tcl_IncrRefCount(localPtr->defValuePtr);
} else {
localPtr->defValuePtr = NULL;
}
- memcpy(localPtr->name, fieldValues[0], nameLength + 1);
+ memcpy(localPtr->name, argname, fieldValues[0]->length + 1);
if ((i == numArgs - 1)
&& (localPtr->nameLength == 4)
&& (localPtr->name[0] == 'a')
@@ -660,12 +654,9 @@ TclCreateProc(
localPtr->flags |= VAR_IS_ARGS;
}
}
-
- ckfree(fieldValues);
}
*procPtrPtr = procPtr;
- ckfree(argArray);
return TCL_OK;
procError:
@@ -686,9 +677,6 @@ TclCreateProc(
}
ckfree(procPtr);
}
- if (argArray != NULL) {
- ckfree(argArray);
- }
return TCL_ERROR;
}
diff --git a/generic/tclResult.c b/generic/tclResult.c
index 57a6de5..5a8ef61 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -27,9 +27,6 @@ enum returnKeys {
static Tcl_Obj ** GetKeys(void);
static void ReleaseKeys(ClientData clientData);
static void ResetObjResult(Interp *iPtr);
-#ifndef TCL_NO_DEPRECATED
-static void SetupAppendBuffer(Interp *iPtr, int newSpace);
-#endif /* !TCL_NO_DEPRECATED */
/*
* This structure is used to take a snapshot of the interpreter state in
@@ -247,47 +244,9 @@ Tcl_SaveResult(
* reference. Put an empty object into the interpreter.
*/
- statePtr->objResultPtr = iPtr->objResultPtr;
+ *statePtr = iPtr->objResultPtr;
iPtr->objResultPtr = Tcl_NewObj();
Tcl_IncrRefCount(iPtr->objResultPtr);
-
- /*
- * Save the string result.
- */
-
- statePtr->freeProc = iPtr->freeProc;
- if (iPtr->result == iPtr->resultSpace) {
- /*
- * Copy the static string data out of the interp buffer.
- */
-
- statePtr->result = statePtr->resultSpace;
- strcpy(statePtr->result, iPtr->result);
- statePtr->appendResult = NULL;
- } else if (iPtr->result == iPtr->appendResult) {
- /*
- * Move the append buffer out of the interp.
- */
-
- statePtr->appendResult = iPtr->appendResult;
- statePtr->appendAvl = iPtr->appendAvl;
- statePtr->appendUsed = iPtr->appendUsed;
- statePtr->result = statePtr->appendResult;
- iPtr->appendResult = NULL;
- iPtr->appendAvl = 0;
- iPtr->appendUsed = 0;
- } else {
- /*
- * Move the dynamic or static string out of the interpreter.
- */
-
- statePtr->result = iPtr->result;
- statePtr->appendResult = NULL;
- }
-
- iPtr->result = iPtr->resultSpace;
- iPtr->resultSpace[0] = 0;
- iPtr->freeProc = 0;
}
/*
@@ -319,44 +278,11 @@ Tcl_RestoreResult(
Tcl_ResetResult(interp);
/*
- * Restore the string result.
- */
-
- iPtr->freeProc = statePtr->freeProc;
- if (statePtr->result == statePtr->resultSpace) {
- /*
- * Copy the static string data into the interp buffer.
- */
-
- iPtr->result = iPtr->resultSpace;
- strcpy(iPtr->result, statePtr->result);
- } else if (statePtr->result == statePtr->appendResult) {
- /*
- * Move the append buffer back into the interp.
- */
-
- if (iPtr->appendResult != NULL) {
- ckfree(iPtr->appendResult);
- }
-
- iPtr->appendResult = statePtr->appendResult;
- iPtr->appendAvl = statePtr->appendAvl;
- iPtr->appendUsed = statePtr->appendUsed;
- iPtr->result = iPtr->appendResult;
- } else {
- /*
- * Move the dynamic or static string back into the interpreter.
- */
-
- iPtr->result = statePtr->result;
- }
-
- /*
* Restore the object result.
*/
Tcl_DecrRefCount(iPtr->objResultPtr);
- iPtr->objResultPtr = statePtr->objResultPtr;
+ iPtr->objResultPtr = *statePtr;
}
/*
@@ -382,15 +308,7 @@ void
Tcl_DiscardResult(
Tcl_SavedResult *statePtr) /* State returned by Tcl_SaveResult. */
{
- TclDecrRefCount(statePtr->objResultPtr);
-
- if (statePtr->result == statePtr->appendResult) {
- ckfree(statePtr->appendResult);
- } else if (statePtr->freeProc == TCL_DYNAMIC) {
- ckfree(statePtr->result);
- } else if (statePtr->freeProc) {
- statePtr->freeProc(statePtr->result);
- }
+ Tcl_DecrRefCount(*statePtr);
}
/*
@@ -420,49 +338,15 @@ Tcl_SetResult(
* TCL_STATIC, TCL_VOLATILE, or the address of
* a Tcl_FreeProc such as free. */
{
- Interp *iPtr = (Interp *) interp;
- register Tcl_FreeProc *oldFreeProc = iPtr->freeProc;
- char *oldResult = iPtr->result;
-
- if (result == NULL) {
- iPtr->resultSpace[0] = 0;
- iPtr->result = iPtr->resultSpace;
- iPtr->freeProc = 0;
- } else if (freeProc == TCL_VOLATILE) {
- int length = strlen(result);
-
- if (length > TCL_RESULT_SIZE) {
- iPtr->result = ckalloc(length + 1);
- iPtr->freeProc = TCL_DYNAMIC;
- } else {
- iPtr->result = iPtr->resultSpace;
- iPtr->freeProc = 0;
- }
- memcpy(iPtr->result, result, (unsigned) length+1);
- } else {
- iPtr->result = (char *) result;
- iPtr->freeProc = freeProc;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(result, -1));
+ if (result == NULL || freeProc == NULL || freeProc == TCL_VOLATILE) {
+ return;
}
-
- /*
- * If the old result was dynamically-allocated, free it up. Do it here,
- * rather than at the beginning, in case the new result value was part of
- * the old result value.
- */
-
- if (oldFreeProc != 0) {
- if (oldFreeProc == TCL_DYNAMIC) {
- ckfree(oldResult);
- } else {
- oldFreeProc(oldResult);
- }
+ if (freeProc == TCL_DYNAMIC) {
+ ckfree(result);
+ } else {
+ (*freeProc)(result);
}
-
- /*
- * Reset the object result since we just set the string result.
- */
-
- ResetObjResult(iPtr);
}
#endif /* !TCL_NO_DEPRECATED */
@@ -488,20 +372,8 @@ Tcl_GetStringResult(
register Tcl_Interp *interp)/* Interpreter whose result to return. */
{
Interp *iPtr = (Interp *) interp;
-#ifdef TCL_NO_DEPRECATED
- return Tcl_GetString(iPtr->objResultPtr);
-#else
- /*
- * If the string result is empty, move the object result to the string
- * result, then reset the object result.
- */
- if (*(iPtr->result) == 0) {
- Tcl_SetResult(interp, TclGetString(Tcl_GetObjResult(interp)),
- TCL_VOLATILE);
- }
- return iPtr->result;
-#endif
+ return Tcl_GetString(iPtr->objResultPtr);
}
/*
@@ -542,23 +414,6 @@ Tcl_SetObjResult(
*/
TclDecrRefCount(oldObjResult);
-
-#ifndef TCL_NO_DEPRECATED
- /*
- * Reset the string result since we just set the result object.
- */
-
- if (iPtr->freeProc != NULL) {
- if (iPtr->freeProc == TCL_DYNAMIC) {
- ckfree(iPtr->result);
- } else {
- iPtr->freeProc(iPtr->result);
- }
- iPtr->freeProc = 0;
- }
- iPtr->result = iPtr->resultSpace;
- iPtr->resultSpace[0] = 0;
-#endif
}
/*
@@ -587,34 +442,7 @@ Tcl_GetObjResult(
Tcl_Interp *interp) /* Interpreter whose result to return. */
{
register Interp *iPtr = (Interp *) interp;
-#ifndef TCL_NO_DEPRECATED
- Tcl_Obj *objResultPtr;
- int length;
- /*
- * If the string result is non-empty, move the string result to the object
- * result, then reset the string result.
- */
-
- if (iPtr->result[0] != 0) {
- ResetObjResult(iPtr);
-
- objResultPtr = iPtr->objResultPtr;
- length = strlen(iPtr->result);
- TclInitStringRep(objResultPtr, iPtr->result, length);
-
- if (iPtr->freeProc != NULL) {
- if (iPtr->freeProc == TCL_DYNAMIC) {
- ckfree(iPtr->result);
- } else {
- iPtr->freeProc(iPtr->result);
- }
- iPtr->freeProc = 0;
- }
- iPtr->result = iPtr->resultSpace;
- iPtr->result[0] = 0;
- }
-#endif /* !TCL_NO_DEPRECATED */
return iPtr->objResultPtr;
}
@@ -651,23 +479,6 @@ Tcl_AppendResultVA(
}
Tcl_AppendStringsToObjVA(objPtr, argList);
Tcl_SetObjResult(interp, objPtr);
-
- /*
- * Strictly we should call Tcl_GetStringResult(interp) here to make sure
- * that interp->result is correct according to the old contract, but that
- * makes the performance of much code (e.g. in Tk) absolutely awful. So we
- * leave it out; code that really wants interp->result can just insert the
- * calls to Tcl_GetStringResult() itself. [Patch 1041072 discussion]
- */
-
-#ifdef USE_INTERP_RESULT
- /*
- * Ensure that the interp->result is legal so old Tcl 7.* code still
- * works. There's still embarrasingly much of it about...
- */
-
- (void) Tcl_GetStringResult(interp);
-#endif /* USE_INTERP_RESULT */
}
/*
@@ -733,7 +544,6 @@ Tcl_AppendElement(
* to result. */
{
Interp *iPtr = (Interp *) interp;
-#ifdef TCL_NO_DEPRECATED
Tcl_Obj *elementPtr = Tcl_NewStringObj(element, -1);
Tcl_Obj *listPtr = Tcl_NewListObj(1, &elementPtr);
const char *bytes;
@@ -747,134 +557,7 @@ Tcl_AppendElement(
}
Tcl_AppendObjToObj(iPtr->objResultPtr, listPtr);
Tcl_DecrRefCount(listPtr);
-#else
- char *dst;
- int size;
- int flags;
-
- /*
- * If the string result is empty, move the object result to the string
- * result, then reset the object result.
- */
-
- (void) Tcl_GetStringResult(interp);
-
- /*
- * See how much space is needed, and grow the append buffer if needed to
- * accommodate the list element.
- */
-
- size = Tcl_ScanElement(element, &flags) + 1;
- if ((iPtr->result != iPtr->appendResult)
- || (iPtr->appendResult[iPtr->appendUsed] != 0)
- || ((size + iPtr->appendUsed) >= iPtr->appendAvl)) {
- SetupAppendBuffer(iPtr, size+iPtr->appendUsed);
- }
-
- /*
- * Convert the string into a list element and copy it to the buffer that's
- * forming, with a space separator if needed.
- */
-
- dst = iPtr->appendResult + iPtr->appendUsed;
- if (TclNeedSpace(iPtr->appendResult, dst)) {
- iPtr->appendUsed++;
- *dst = ' ';
- dst++;
-
- /*
- * If we need a space to separate this element from preceding stuff,
- * then this element will not lead a list, and need not have it's
- * leading '#' quoted.
- */
-
- flags |= TCL_DONT_QUOTE_HASH;
- }
- iPtr->appendUsed += Tcl_ConvertElement(element, dst, flags);
-#endif /* !TCL_NO_DEPRECATED */
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * SetupAppendBuffer --
- *
- * This function makes sure that there is an append buffer properly
- * initialized, if necessary, from the interpreter's result, and that it
- * has at least enough room to accommodate newSpace new bytes of
- * information.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-#ifndef TCL_NO_DEPRECATED
-static void
-SetupAppendBuffer(
- Interp *iPtr, /* Interpreter whose result is being set up. */
- int newSpace) /* Make sure that at least this many bytes of
- * new information may be added. */
-{
- int totalSpace;
-
- /*
- * Make the append buffer larger, if that's necessary, then copy the
- * result into the append buffer and make the append buffer the official
- * Tcl result.
- */
-
- if (iPtr->result != iPtr->appendResult) {
- /*
- * If an oversized buffer was used recently, then free it up so we go
- * back to a smaller buffer. This avoids tying up memory forever after
- * a large operation.
- */
-
- if (iPtr->appendAvl > 500) {
- ckfree(iPtr->appendResult);
- iPtr->appendResult = NULL;
- iPtr->appendAvl = 0;
- }
- iPtr->appendUsed = strlen(iPtr->result);
- } else if (iPtr->result[iPtr->appendUsed] != 0) {
- /*
- * Most likely someone has modified a result created by
- * Tcl_AppendResult et al. so that it has a different size. Just
- * recompute the size.
- */
-
- iPtr->appendUsed = strlen(iPtr->result);
- }
-
- totalSpace = newSpace + iPtr->appendUsed;
- if (totalSpace >= iPtr->appendAvl) {
- char *new;
-
- if (totalSpace < 100) {
- totalSpace = 200;
- } else {
- totalSpace *= 2;
- }
- new = ckalloc(totalSpace);
- strcpy(new, iPtr->result);
- if (iPtr->appendResult != NULL) {
- ckfree(iPtr->appendResult);
- }
- iPtr->appendResult = new;
- iPtr->appendAvl = totalSpace;
- } else if (iPtr->result != iPtr->appendResult) {
- strcpy(iPtr->appendResult, iPtr->result);
- }
-
- Tcl_FreeResult((Tcl_Interp *) iPtr);
- iPtr->result = iPtr->appendResult;
}
-#endif /* !TCL_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -882,18 +565,17 @@ SetupAppendBuffer(
* Tcl_FreeResult --
*
* This function frees up the memory associated with an interpreter's
- * string result. It also resets the interpreter's result object.
- * Tcl_FreeResult is most commonly used when a function is about to
- * replace one result value with another.
+ * result, resetting the interpreter's result object. Tcl_FreeResult is
+ * most commonly used when a function is about to replace one result
+ * value with another.
*
* Results:
* None.
*
* Side effects:
- * Frees the memory associated with interp's string result and sets
- * interp->freeProc to zero, but does not change interp->result or clear
- * error state. Resets interp's result object to an unshared empty
- * object.
+ * Frees the memory associated with interp's result but does not change
+ * any part of the error dictionary (i.e., the errorinfo and errorcode
+ * remain the same).
*
*----------------------------------------------------------------------
*/
@@ -904,17 +586,6 @@ Tcl_FreeResult(
{
register Interp *iPtr = (Interp *) interp;
-#ifndef TCL_NO_DEPRECATED
- if (iPtr->freeProc != NULL) {
- if (iPtr->freeProc == TCL_DYNAMIC) {
- ckfree(iPtr->result);
- } else {
- iPtr->freeProc(iPtr->result);
- }
- iPtr->freeProc = 0;
- }
-
-#endif /* !TCL_NO_DEPRECATED */
ResetObjResult(iPtr);
}
@@ -944,18 +615,6 @@ Tcl_ResetResult(
register Interp *iPtr = (Interp *) interp;
ResetObjResult(iPtr);
-#ifndef TCL_NO_DEPRECATED
- if (iPtr->freeProc != NULL) {
- if (iPtr->freeProc == TCL_DYNAMIC) {
- ckfree(iPtr->result);
- } else {
- iPtr->freeProc(iPtr->result);
- }
- iPtr->freeProc = 0;
- }
- iPtr->result = iPtr->resultSpace;
- iPtr->resultSpace[0] = 0;
-#endif /* !TCL_NO_DEPRECATED */
if (iPtr->errorCode) {
/* Legacy support */
if (iPtr->flags & ERR_LEGACY_COPY) {
diff --git a/generic/tclScan.c b/generic/tclScan.c
index e1fcad4..7f71262 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -885,9 +885,17 @@ Tcl_ScanObjCmd(
* Scan a single Unicode character.
*/
- string += TclUtfToUniChar(string, &sch);
+ offset = TclUtfToUniChar(string, &sch);
+ i = (int)sch;
+#if TCL_UTF_MAX == 4
+ if (!offset) {
+ offset = Tcl_UtfToUniChar(string, &sch);
+ i = (((i<<10) & 0x0FFC00) + 0x10000) + (sch & 0x3FF);
+ }
+#endif
+ string += offset;
if (!(flags & SCAN_SUPPRESS)) {
- objPtr = Tcl_NewIntObj((int)sch);
+ objPtr = Tcl_NewIntObj(i);
Tcl_IncrRefCount(objPtr);
CLANG_ASSERT(objs);
objs[objIndex++] = objPtr;
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index ac2ca68..d36415c 100644..100755
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -483,7 +483,7 @@ TclParseNumber(
enum State {
INITIAL, SIGNUM, ZERO, ZERO_X,
ZERO_O, ZERO_B, ZERO_D, BINARY,
- HEXADECIMAL, OCTAL, BAD_OCTAL, DECIMAL,
+ HEXADECIMAL, OCTAL, DECIMAL,
LEADING_RADIX_POINT, FRACTION,
EXPONENT_START, EXPONENT_SIGNUM, EXPONENT,
sI, sIN, sINF, sINFI, sINFIN, sINFINI, sINFINIT, sINFINITY
@@ -528,7 +528,6 @@ TclParseNumber(
char d = 0; /* Last hexadecimal digit scanned; initialized
* to avoid a compiler warning. */
int shift = 0; /* Amount to shift when accumulating binary */
- int explicitOctal = 0;
#define ALL_BITS (~(Tcl_WideUInt)0)
#define MOST_BITS (ALL_BITS >> 1)
@@ -660,7 +659,6 @@ TclParseNumber(
goto zerob;
}
if (c == 'o' || c == 'O') {
- explicitOctal = 1;
state = ZERO_O;
break;
}
@@ -668,10 +666,7 @@ TclParseNumber(
state = ZERO_D;
break;
}
-#ifdef TCL_NO_DEPRECATED
goto decimal;
-#endif
- /* FALLTHROUGH */
case OCTAL:
/*
@@ -734,58 +729,6 @@ TclParseNumber(
state = OCTAL;
break;
}
- /* FALLTHROUGH */
-
- case BAD_OCTAL:
- if (explicitOctal) {
- /*
- * No forgiveness for bad digits in explicitly octal numbers.
- */
-
- goto endgame;
- }
- if (flags & TCL_PARSE_INTEGER_ONLY) {
- /*
- * No seeking floating point when parsing only integer.
- */
-
- goto endgame;
- }
-#ifndef TCL_NO_DEPRECATED
-
- /*
- * Scanned a number with a leading zero that contains an 8, 9,
- * radix point or E. This is an invalid octal number, but might
- * still be floating point.
- */
-
- if (c == '0') {
- numTrailZeros++;
- state = BAD_OCTAL;
- break;
- } else if (isdigit(UCHAR(c))) {
- if (objPtr != NULL) {
- significandOverflow = AccumulateDecimalDigit(
- (unsigned)(c-'0'), numTrailZeros,
- &significandWide, &significandBig,
- significandOverflow);
- }
- if (numSigDigs != 0) {
- numSigDigs += (numTrailZeros + 1);
- } else {
- numSigDigs = 1;
- }
- numTrailZeros = 0;
- state = BAD_OCTAL;
- break;
- } else if (c == '.') {
- state = FRACTION;
- break;
- } else if (c == 'E' || c == 'e') {
- state = EXPONENT_START;
- break;
- }
-#endif
goto endgame;
/*
@@ -900,9 +843,7 @@ TclParseNumber(
* digits.
*/
-#ifdef TCL_NO_DEPRECATED
decimal:
-#endif
acceptState = state;
acceptPoint = p;
acceptLen = len;
@@ -1186,7 +1127,6 @@ TclParseNumber(
TclFreeIntRep(objPtr);
switch (acceptState) {
case SIGNUM:
- case BAD_OCTAL:
case ZERO_X:
case ZERO_O:
case ZERO_B:
@@ -1384,9 +1324,6 @@ TclParseNumber(
Tcl_AppendLimitedToObj(msg, bytes, numBytes, 50, "");
Tcl_AppendToObj(msg, "\"", -1);
- if (state == BAD_OCTAL) {
- Tcl_AppendToObj(msg, " (looks like invalid octal number)", -1);
- }
Tcl_SetObjResult(interp, msg);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL);
}
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 3a35bcf..547f7c6 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -3462,7 +3462,6 @@ TclStringObjReverse(
* Tcl_SetObjLength into growing the unicode rep buffer.
*/
- ch = 0;
objPtr = Tcl_NewUnicodeObj(&ch, 1);
Tcl_SetObjLength(objPtr, stringPtr->numChars);
to = Tcl_GetUnicode(objPtr);
@@ -3565,7 +3564,7 @@ ExtendUnicodeRepWithString(
{
String *stringPtr = GET_STRING(objPtr);
int needed, numOrigChars = 0;
- Tcl_UniChar *dst;
+ Tcl_UniChar *dst, unichar = 0;
if (stringPtr->hasUnicode) {
numOrigChars = stringPtr->numChars;
@@ -3588,7 +3587,8 @@ ExtendUnicodeRepWithString(
numAppendChars = 0;
}
for (dst=stringPtr->unicode + numOrigChars; numAppendChars-- > 0; dst++) {
- bytes += TclUtfToUniChar(bytes, dst);
+ bytes += TclUtfToUniChar(bytes, &unichar);
+ *dst = unichar;
}
*dst = 0;
}
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index 5261591..b26fb01 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -66,8 +66,8 @@ Tcl_InitStubs(
*/
if (!stubsPtr || (stubsPtr->magic != (((exact&0xff00) >= 0x900) ? magic : TCL_STUB_MAGIC))) {
- iPtr->result = (char *)"interpreter uses an incompatible stubs mechanism";
- iPtr->freeProc = 0;
+ iPtr->legacyResult = "interpreter uses an incompatible stubs mechanism";
+ iPtr->legacyFreeProc = 0; /* TCL_STATIC */
return NULL;
}
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 834cd79..46e07fa 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -5228,7 +5228,6 @@ TestsaveresultCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
- Interp* iPtr = (Interp*) interp;
int discard, result, index;
Tcl_SavedResult state;
Tcl_Obj *objPtr;
@@ -5296,12 +5295,9 @@ TestsaveresultCmd(
}
switch ((enum options) index) {
- case RESULT_DYNAMIC: {
- int presentOrFreed = (iPtr->freeProc == TestsaveresultFree) ^ freeCount;
-
- Tcl_AppendElement(interp, presentOrFreed ? "presentOrFreed" : "missingOrLeak");
+ case RESULT_DYNAMIC:
+ Tcl_AppendElement(interp, freeCount ? "freed" : "leak");
break;
- }
case RESULT_OBJECT:
Tcl_AppendElement(interp, Tcl_GetObjResult(interp) == objPtr
? "same" : "different");
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 61a84ce..bdea37f 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -2923,86 +2923,12 @@ Tcl_DStringGetResult(
Tcl_DString *dsPtr) /* Dynamic string that is to become the result
* of interp. */
{
-#ifdef TCL_NO_DEPRECATED
- Tcl_Obj *obj = Tcl_GetObjResult(interp);
- const char *bytes = TclGetString(obj);
+ int length;
+ char *bytes = TclGetStringFromObj(Tcl_GetObjResult(interp), &length);
Tcl_DStringFree(dsPtr);
- Tcl_DStringAppend(dsPtr, bytes, obj->length);
+ Tcl_DStringAppend(dsPtr, bytes, length);
Tcl_ResetResult(interp);
-#else
- Interp *iPtr = (Interp *) interp;
-
- if (dsPtr->string != dsPtr->staticSpace) {
- ckfree(dsPtr->string);
- }
-
- /*
- * Do more efficient transfer when we know the result is a Tcl_Obj. When
- * there's no string result, we only have to deal with two cases:
- *
- * 1. When the string rep is the empty string, when we don't copy but
- * instead use the staticSpace in the DString to hold an empty string.
-
- * 2. When the string rep is not there or there's a real string rep, when
- * we use Tcl_GetString to fetch (or generate) the string rep - which
- * we know to have been allocated with ckalloc() - and use it to
- * populate the DString space. Then, we free the internal rep. and set
- * the object's string representation back to the canonical empty
- * string.
- */
-
- if (!iPtr->result[0] && iPtr->objResultPtr
- && !Tcl_IsShared(iPtr->objResultPtr)) {
- if (iPtr->objResultPtr->bytes == &tclEmptyString) {
- dsPtr->string = dsPtr->staticSpace;
- dsPtr->string[0] = 0;
- dsPtr->length = 0;
- dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE;
- } else {
- dsPtr->string = TclGetString(iPtr->objResultPtr);
- dsPtr->length = iPtr->objResultPtr->length;
- dsPtr->spaceAvl = dsPtr->length + 1;
- TclFreeIntRep(iPtr->objResultPtr);
- iPtr->objResultPtr->bytes = &tclEmptyString;
- iPtr->objResultPtr->length = 0;
- }
- return;
- }
-
- /*
- * If the string result is empty, move the object result to the string
- * result, then reset the object result.
- */
-
- (void) Tcl_GetStringResult(interp);
-
- dsPtr->length = strlen(iPtr->result);
- if (iPtr->freeProc != NULL) {
- if (iPtr->freeProc == TCL_DYNAMIC) {
- dsPtr->string = iPtr->result;
- dsPtr->spaceAvl = dsPtr->length+1;
- } else {
- dsPtr->string = ckalloc(dsPtr->length+1);
- memcpy(dsPtr->string, iPtr->result, (unsigned) dsPtr->length+1);
- iPtr->freeProc(iPtr->result);
- }
- dsPtr->spaceAvl = dsPtr->length+1;
- iPtr->freeProc = NULL;
- } else {
- if (dsPtr->length < TCL_DSTRING_STATIC_SIZE) {
- dsPtr->string = dsPtr->staticSpace;
- dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE;
- } else {
- dsPtr->string = ckalloc(dsPtr->length+1);
- dsPtr->spaceAvl = dsPtr->length + 1;
- }
- memcpy(dsPtr->string, iPtr->result, (unsigned) dsPtr->length+1);
- }
-
- iPtr->result = iPtr->resultSpace;
- iPtr->resultSpace[0] = 0;
-#endif /* !TCL_NO_DEPRECATED */
}
/*
@@ -3553,22 +3479,27 @@ TclFormatInt(
*
* TclGetIntForIndex --
*
- * This function returns an integer corresponding to the list index held
- * in a Tcl object. The Tcl object's value is expected to be in the
- * format integer([+-]integer)? or the format end([+-]integer)?.
- *
- * Results:
- * The return value is normally TCL_OK, which means that the index was
- * successfully stored into the location referenced by "indexPtr". If the
- * Tcl object referenced by "objPtr" has the value "end", the value
- * stored is "endValue". If "objPtr"s values is not of one of the
- * expected formats, TCL_ERROR is returned and, if "interp" is non-NULL,
- * an error message is left in the interpreter's result object.
- *
- * Side effects:
- * The object referenced by "objPtr" might be converted to an integer,
- * wide integer, or end-based-index object.
- *
+ * Provides an integer corresponding to the list index held in a Tcl
+ * object. The string value 'objPtr' is expected have the format
+ * integer([+-]integer)? or end([+-]integer)?.
+ *
+ * Value
+ * TCL_OK
+ *
+ * The index is stored at the address given by by 'indexPtr'. If
+ * 'objPtr' has the value "end", the value stored is 'endValue'.
+ *
+ * TCL_ERROR
+ *
+ * The value of 'objPtr' does not have one of the expected formats. If
+ * 'interp' is non-NULL, an error message is left in the interpreter's
+ * result object.
+ *
+ * Effect
+ *
+ * The object referenced by 'objPtr' is converted, as needed, to an
+ * integer, wide integer, or end-based-index object.
+ *
*----------------------------------------------------------------------
*/
@@ -3655,7 +3586,6 @@ TclGetIntForIndex(
if (!strncmp(bytes, "end-", 4)) {
bytes += 4;
}
- TclCheckBadOctal(interp, bytes);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", NULL);
}
@@ -3804,73 +3734,6 @@ SetEndOffsetFromAny(
/*
*----------------------------------------------------------------------
*
- * TclCheckBadOctal --
- *
- * This function checks for a bad octal value and appends a meaningful
- * error to the interp's result.
- *
- * Results:
- * 1 if the argument was a bad octal, else 0.
- *
- * Side effects:
- * The interpreter's result is modified.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TclCheckBadOctal(
- Tcl_Interp *interp, /* Interpreter to use for error reporting. If
- * NULL, then no error message is left after
- * errors. */
- const char *value) /* String to check. */
-{
- register const char *p = value;
-
- /*
- * A frequent mistake is invalid octal values due to an unwanted leading
- * zero. Try to generate a meaningful error message.
- */
-
- while (TclIsSpaceProc(*p)) {
- p++;
- }
- if (*p == '+' || *p == '-') {
- p++;
- }
- if (*p == '0') {
- if ((p[1] == 'o') || p[1] == 'O') {
- p += 2;
- }
- while (isdigit(UCHAR(*p))) { /* INTL: digit. */
- p++;
- }
- while (TclIsSpaceProc(*p)) {
- p++;
- }
- if (*p == '\0') {
- /*
- * Reached end of string.
- */
-
- if (interp != NULL) {
- /*
- * Don't reset the result here because we want this result to
- * be added to an existing error message as extra info.
- */
-
- Tcl_AppendToObj(Tcl_GetObjResult(interp),
- " (looks like invalid octal number)", -1);
- }
- return 1;
- }
- }
- return 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* ClearHash --
*
* Remove all the entries in the hash table *tablePtr.
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 7c8bb73..4f2d435 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -816,12 +816,8 @@ TclLookupSimpleVar(
*indexPtr = -1;
flags = (flags | TCL_GLOBAL_ONLY) & ~TCL_NAMESPACE_ONLY;
} else {
- if (flags & TCL_AVOID_RESOLVERS) {
- flags = (flags | TCL_NAMESPACE_ONLY);
- }
- if (flags & TCL_NAMESPACE_ONLY) {
- *indexPtr = -2;
- }
+ flags = (flags | TCL_NAMESPACE_ONLY);
+ *indexPtr = -2;
}
/*
@@ -5709,6 +5705,10 @@ ObjFindNamespaceVar(
* Find the namespace(s) that contain the variable.
*/
+ if (!(flags & TCL_GLOBAL_ONLY)) {
+ flags |= TCL_NAMESPACE_ONLY;
+ }
+
TclGetNamespaceForQualName(interp, name, (Namespace *) contextNsPtr,
flags, &nsPtr[0], &nsPtr[1], &cxtNsPtr, &simpleName);