diff options
author | dkf <dkf@noemail.net> | 2007-06-12 12:29:03 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2007-06-12 12:29:03 (GMT) |
commit | 50975fd836801ce4607f7ef733206666bafe0663 (patch) | |
tree | 77dcc03631a20a577c5de5bd77c2012af285e413 /generic/tclIndexObj.c | |
parent | 7aa324ea07132fe4fb64486fb9d504527f14c182 (diff) | |
download | tcl-50975fd836801ce4607f7ef733206666bafe0663.zip tcl-50975fd836801ce4607f7ef733206666bafe0663.tar.gz tcl-50975fd836801ce4607f7ef733206666bafe0663.tar.bz2 |
Improve the argument substitution behaviour of Tcl_WrongNumArgs when faced with
ensemble and interp-alias rewrites.
FossilOrigin-Name: 5acd0e47b4a741393e833e1ed4d1a54661e1dfc2
Diffstat (limited to 'generic/tclIndexObj.c')
-rw-r--r-- | generic/tclIndexObj.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index af0b444..df8d9ee 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIndexObj.c,v 1.32 2007/04/02 18:48:03 dgp Exp $ + * RCS: @(#) $Id: tclIndexObj.c,v 1.33 2007/06/12 12:29:05 dkf Exp $ */ #include "tclInt.h" @@ -449,7 +449,6 @@ Tcl_WrongNumArgs( { Tcl_Obj *objPtr; int i, len, elemLen, flags; - register IndexRep *indexRep; Interp *iPtr = (Interp *) interp; char *elementStr; @@ -521,11 +520,25 @@ Tcl_WrongNumArgs( * Add the element, quoting it if necessary. */ - elementStr = Tcl_GetStringFromObj(origObjv[i], &elemLen); + if (origObjv[i]->typePtr == &indexType) { + register IndexRep *indexRep = + origObjv[i]->internalRep.otherValuePtr; + + elementStr = EXPAND_OF(indexRep); + elemLen = strlen(elementStr); + } else if (origObjv[i]->typePtr == &tclEnsembleCmdType) { + register EnsembleCmdRep *ecrPtr = + origObjv[i]->internalRep.otherValuePtr; + + elementStr = ecrPtr->fullSubcmdName; + elemLen = strlen(elementStr); + } else { + elementStr = Tcl_GetStringFromObj(origObjv[i], &elemLen); + } len = Tcl_ScanCountedElement(elementStr, elemLen, &flags); if (MAY_QUOTE_WORD && len != elemLen) { - char *quotedElementStr = TclStackAlloc(interp, (unsigned) len); + char *quotedElementStr = TclStackAlloc(interp, (unsigned)len); len = Tcl_ConvertCountedElement(elementStr, elemLen, quotedElementStr, flags); @@ -562,8 +575,14 @@ Tcl_WrongNumArgs( */ if (objv[i]->typePtr == &indexType) { - indexRep = (IndexRep *) objv[i]->internalRep.otherValuePtr; + register IndexRep *indexRep = objv[i]->internalRep.otherValuePtr; + Tcl_AppendStringsToObj(objPtr, EXPAND_OF(indexRep), NULL); + } else if (objv[i]->typePtr == &tclEnsembleCmdType) { + register EnsembleCmdRep *ecrPtr = + objv[i]->internalRep.otherValuePtr; + + Tcl_AppendStringsToObj(objPtr, ecrPtr->fullSubcmdName, NULL); } else { /* * Quote the argument if it contains spaces (Bug 942757). |