summaryrefslogtreecommitdiffstats
path: root/generic/tclCompCmdsGR.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-03-07 21:21:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-03-07 21:21:00 (GMT)
commitb4d6691add28bb5928fd51cf76bf7f6d9c78f5cc (patch)
tree9826b49b65c0a7f4c416ad3b49082be9096d07fb /generic/tclCompCmdsGR.c
parent3492c92f3dcb820bd5f7aa833e340b6e1eb8f1c5 (diff)
parentf337281f750a928dcc07884286cc1f4cceeab809 (diff)
downloadtcl-b4d6691add28bb5928fd51cf76bf7f6d9c78f5cc.zip
tcl-b4d6691add28bb5928fd51cf76bf7f6d9c78f5cc.tar.gz
tcl-b4d6691add28bb5928fd51cf76bf7f6d9c78f5cc.tar.bz2
Merge 8.6
Diffstat (limited to 'generic/tclCompCmdsGR.c')
-rw-r--r--generic/tclCompCmdsGR.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index 0720a6b..8779a78 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -1505,7 +1505,6 @@ TclCompileLreplaceCmd(
* - integer: [0,len+1]
* - end index: TCL_INDEX_END
* - -ive offset: TCL_INDEX_END-[len-1,0]
- * - +ive offset: TCL_INDEX_END+1
*/
/*
@@ -1515,6 +1514,11 @@ TclCompileLreplaceCmd(
*/
if ((idx1 <= TCL_INDEX_END) != (idx2 <= TCL_INDEX_END)) {
+
+ /*
+ * NOTE: when idx1 == 0 and idx2 == TCL_INDEX_END,
+ * we bail out here! Yet, down below
+ */
return TCL_ERROR;
}
@@ -1531,9 +1535,11 @@ TclCompileLreplaceCmd(
if (parsePtr->numWords == 4) {
if (idx1 == 0) {
if (idx2 == TCL_INDEX_END) {
+
+ /* Here we are down below! Now look somewhere else! */
goto dropAll;
}
- idx1 = idx2 + 1;
+ idx1 = idx2 + 1; /* TODO: Overflow? */
idx2 = TCL_INDEX_END;
goto dropEnd;
} else if (idx2 == TCL_INDEX_END) {
@@ -1561,9 +1567,10 @@ TclCompileLreplaceCmd(
TclEmitInstInt4( INST_REVERSE, 2, envPtr);
if (idx1 == 0) {
if (idx2 == TCL_INDEX_END) {
+ /* Another Can't Happen. */
goto replaceAll;
}
- idx1 = idx2 + 1;
+ idx1 = idx2 + 1; /* TODO: Overflow? */
idx2 = TCL_INDEX_END;
goto replaceHead;
} else if (idx2 == TCL_INDEX_END) {
@@ -1588,6 +1595,11 @@ TclCompileLreplaceCmd(
*/
dropAll: /* This just ensures the arg is a list. */
+ /*
+ * And now we're here down below the down below where flow can never go.
+ * CONCLUSION: This code has no purpose.
+ */
+Tcl_Panic("Can not get here.");
TclEmitOpcode( INST_LIST_LENGTH, envPtr);
TclEmitOpcode( INST_POP, envPtr);
PushStringLiteral(envPtr, "");
@@ -1615,6 +1627,9 @@ TclCompileLreplaceCmd(
* Emit an error if we've been given an empty list.
*/
+/* If we're generating bytecode to report an error, we've gone wrong.
+ * Just fallback to direct invocation.
+ */
TclEmitOpcode( INST_DUP, envPtr);
TclEmitOpcode( INST_LIST_LENGTH, envPtr);
offset2 = CurrentOffset(envPtr);
@@ -1646,6 +1661,7 @@ TclCompileLreplaceCmd(
*/
replaceAll:
+Tcl_Panic("Can not get here.");
TclEmitOpcode( INST_LIST_LENGTH, envPtr);
TclEmitOpcode( INST_POP, envPtr);
goto done;
@@ -1685,6 +1701,9 @@ TclCompileLreplaceCmd(
* Emit an error if we've been given an empty list.
*/
+/* If we're generating bytecode to report an error, we've gone wrong.
+ * Just fallback to direct invocation.
+ */
TclEmitOpcode( INST_DUP, envPtr);
TclEmitOpcode( INST_LIST_LENGTH, envPtr);
offset2 = CurrentOffset(envPtr);