diff options
author | dgp <dgp@users.sourceforge.net> | 2018-03-06 17:38:44 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2018-03-06 17:38:44 (GMT) |
commit | da8fbb89c41229c79b8f373f955ce1fb59cb4233 (patch) | |
tree | f37be34041ea93f859a6537dea1a14ebe6489877 /generic/tclCompCmdsSZ.c | |
parent | 465d28aa75b2835484face7df25b073b09f81f7c (diff) | |
download | tcl-da8fbb89c41229c79b8f373f955ce1fb59cb4233.zip tcl-da8fbb89c41229c79b8f373f955ce1fb59cb4233.tar.gz tcl-da8fbb89c41229c79b8f373f955ce1fb59cb4233.tar.bz2 |
various bits of ranting commentary
Diffstat (limited to 'generic/tclCompCmdsSZ.c')
-rw-r--r-- | generic/tclCompCmdsSZ.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index fb0981d..6f0cc8f 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -1005,6 +1005,14 @@ TclCompileStringReplaceCmd( * We handle these replacements specially: first character (where * idx1=idx2=0) and last character (where idx1=idx2=TCL_INDEX_END). Anything * else and the semantics get rather screwy. + * + * TODO: These seem to be very narrow cases. They are not even + * covered by the test suite, and any programming that ends up + * here could have been coded by the programmer using [string range] + * and [string cat]. [*] Not clear at all to me that the bytecode + * generated here is worthwhile. + * + * [*] Except for the empty string exceptions. UGGGGHHHH. */ if (idx1 == 0 && idx2 == 0) { @@ -1022,6 +1030,14 @@ TclCompileStringReplaceCmd( } /* Replace first */ CompileWord(envPtr, replacementTokenPtr, interp, 4); + + /* + * NOTE: The following tower of bullshit is present because + * [string replace] was boneheadedly defined not to replace + * empty strings, so we actually have to detect the empty + * string case and treat it differently. + */ + OP4( OVER, 1); PUSH( ""); OP( STR_EQ); @@ -1051,6 +1067,9 @@ TclCompileStringReplaceCmd( } /* Replace last */ CompileWord(envPtr, replacementTokenPtr, interp, 4); + + /* More bullshit; see NOTE above. */ + OP4( OVER, 1); PUSH( ""); OP( STR_EQ); |