diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2013-12-29 18:49:20 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2013-12-29 18:49:20 (GMT) |
commit | baee0eaba1888de8367491cb10aad0bca2a0c09a (patch) | |
tree | a3105918183c56f7ff4721885d87f89e5e7c2def /generic/tclCompCmdsSZ.c | |
parent | c3ba85a17b5051093a6ed4290f7b8f3e424be236 (diff) | |
parent | 295782408448c9a034b86367186e93bc84f0ce7b (diff) | |
download | tcl-baee0eaba1888de8367491cb10aad0bca2a0c09a.zip tcl-baee0eaba1888de8367491cb10aad0bca2a0c09a.tar.gz tcl-baee0eaba1888de8367491cb10aad0bca2a0c09a.tar.bz2 |
Improved general case of [string replace] implementation.
Diffstat (limited to 'generic/tclCompCmdsSZ.c')
-rw-r--r-- | generic/tclCompCmdsSZ.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 110476e..649a76a 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -765,12 +765,25 @@ TclCompileStringReplaceCmd( } else { /* - * Too complicated to optimize, but we know the number of arguments is - * correct so we can issue a call of the "standard" implementation. + * Need to process indices at runtime. This could be because the + * indices are not constants, or because we need to resolve them to + * absolute indices to work out if a replacement is going to happen. + * In any case, to runtime it is. */ genericReplace: - return TclCompileBasicMin0ArgCmd(interp, parsePtr, cmdPtr, envPtr); + CompileWord(envPtr, valueTokenPtr, interp, 1); + tokenPtr = TokenAfter(valueTokenPtr); + CompileWord(envPtr, tokenPtr, interp, 2); + tokenPtr = TokenAfter(tokenPtr); + CompileWord(envPtr, tokenPtr, interp, 3); + if (replacementTokenPtr != NULL) { + CompileWord(envPtr, replacementTokenPtr, interp, 4); + } else { + PUSH( ""); + } + OP( STR_REPLACE); + return TCL_OK; } } |