aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2014-03-14 10:12:16 +1000
committerSteve Bennett <steveb@workware.net.au>2014-03-14 10:12:16 +1000
commit4045ca4084c04c83b797e7c898f0190194745593 (patch)
treef8ca456f4c4a8f9acd080a0025b0e5cda5f8f653
parenta62aed5a50e8e7fe98cbd671e1287a101b093c00 (diff)
downloadjimtcl-4045ca4084c04c83b797e7c898f0190194745593.zip
jimtcl-4045ca4084c04c83b797e7c898f0190194745593.tar.gz
jimtcl-4045ca4084c04c83b797e7c898f0190194745593.tar.bz2
jim.c: preserve source info on interpolation
Preserve the source info for an interpolated script where possible. e.g. set script "puts $x" Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--jim.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/jim.c b/jim.c
index 590cc7c..e09db07 100644
--- a/jim.c
+++ b/jim.c
@@ -3141,7 +3141,7 @@ static void JimSetSourceInfo(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *fileNameObj, int lineNumber)
{
JimPanic((Jim_IsShared(objPtr), "JimSetSourceInfo called with shared object"));
- JimPanic((objPtr->typePtr == &sourceObjType, "JimSetSourceInfo called with non-source object"));
+ JimPanic((objPtr->typePtr != NULL, "JimSetSourceInfo called with typed object"));
Jim_IncrRefCount(fileNameObj);
objPtr->internalRep.sourceValue.fileNameObj = fileNameObj;
objPtr->internalRep.sourceValue.lineNumber = lineNumber;
@@ -10340,6 +10340,11 @@ static Jim_Obj *JimInterpolateTokens(Jim_Interp *interp, const ScriptToken * tok
objPtr->internalRep.dictSubstValue.indexObjPtr = intv[2];
Jim_IncrRefCount(intv[2]);
}
+ else if (tokens && intv[0] && intv[0]->typePtr == &sourceObjType) {
+ /* The first interpolated token is source, so preserve the source info */
+ JimSetSourceInfo(interp, objPtr, intv[0]->internalRep.sourceValue.fileNameObj, intv[0]->internalRep.sourceValue.lineNumber);
+ }
+
s = objPtr->bytes = Jim_Alloc(totlen + 1);
objPtr->length = totlen;