diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-02-04 22:46:56 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-02-04 22:46:56 (GMT) |
| commit | d50da922b1c1a3043e6ee9f24282a638ee143b48 (patch) | |
| tree | 937d8b4d10f30a85b1657a2af519b72b243bd63e /generic/tclCompCmdsSZ.c | |
| parent | 795fcf4f08882df1123a1ab6228a6cdf31fbb3eb (diff) | |
| parent | 73b6b4eab6a4b0a4ecf0f0c6bcf00bd815c34dd5 (diff) | |
| download | tcl-d50da922b1c1a3043e6ee9f24282a638ee143b48.zip tcl-d50da922b1c1a3043e6ee9f24282a638ee143b48.tar.gz tcl-d50da922b1c1a3043e6ee9f24282a638ee143b48.tar.bz2 | |
merge 8.7
Diffstat (limited to 'generic/tclCompCmdsSZ.c')
| -rw-r--r-- | generic/tclCompCmdsSZ.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 8b54a99..daab0d5 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -946,7 +946,7 @@ TclCompileStringRangeCmd( * Parse the two indices. */ - if (TclGetIndexFromToken(fromTokenPtr, TCL_INDEX_START, TCL_INDEX_AFTER, + if (TclGetIndexFromToken(fromTokenPtr, TCL_INDEX_START, TCL_INDEX_NONE, &idx1) != TCL_OK) { goto nonConstantIndices; } @@ -955,14 +955,14 @@ TclCompileStringRangeCmd( * the string the same as the start of the string. */ - if (idx1 == TCL_INDEX_AFTER) { + if (idx1 == TCL_INDEX_NONE) { /* [string range $s end+1 $last] must be empty string */ OP( POP); PUSH( ""); return TCL_OK; } - if (TclGetIndexFromToken(toTokenPtr, TCL_INDEX_BEFORE, TCL_INDEX_END, + if (TclGetIndexFromToken(toTokenPtr, TCL_INDEX_NONE, TCL_INDEX_END, &idx2) != TCL_OK) { goto nonConstantIndices; } @@ -970,7 +970,7 @@ TclCompileStringRangeCmd( * Token parsed as an index expression. We treat all indices after * the string the same as the end of the string. */ - if (idx2 == TCL_INDEX_BEFORE) { + if (idx2 == TCL_INDEX_NONE) { /* [string range $s $first -1] must be empty string */ OP( POP); PUSH( ""); @@ -1020,7 +1020,7 @@ TclCompileStringReplaceCmd( * Check for first index known and useful at compile time. */ tokenPtr = TokenAfter(valueTokenPtr); - if (TclGetIndexFromToken(tokenPtr, TCL_INDEX_BEFORE, TCL_INDEX_AFTER, + if (TclGetIndexFromToken(tokenPtr, TCL_INDEX_START, TCL_INDEX_NONE, &first) != TCL_OK) { goto genericReplace; } @@ -1029,7 +1029,7 @@ TclCompileStringReplaceCmd( * Check for last index known and useful at compile time. */ tokenPtr = TokenAfter(tokenPtr); - if (TclGetIndexFromToken(tokenPtr, TCL_INDEX_BEFORE, TCL_INDEX_AFTER, + if (TclGetIndexFromToken(tokenPtr, TCL_INDEX_NONE, TCL_INDEX_END, &last) != TCL_OK) { goto genericReplace; } @@ -1048,8 +1048,8 @@ TclCompileStringReplaceCmd( * compile direct to bytecode implementing the no-op. */ - if ((last == TCL_INDEX_BEFORE) /* Know (last < 0) */ - || (first == TCL_INDEX_AFTER) /* Know (first > end) */ + if ((last == TCL_INDEX_NONE) /* Know (last < 0) */ + || (first == TCL_INDEX_NONE) /* Know (first > end) */ /* * Tricky to determine when runtime (last < first) can be @@ -1057,20 +1057,17 @@ TclCompileStringReplaceCmd( * cases... * * (first <= TCL_INDEX_END) && - * (last == TCL_INDEX_AFTER) => cannot tell REJECT * (last <= TCL_INDEX END) && (last < first) => ACCEPT * else => cannot tell REJECT */ || ((first <= TCL_INDEX_END) && (last <= TCL_INDEX_END) && (last < first)) /* Know (last < first) */ /* - * (first == TCL_INDEX_BEFORE) && - * (last == TCL_INDEX_AFTER) => (first < last) REJECT + * (first == TCL_INDEX_NONE) && * (last <= TCL_INDEX_END) => cannot tell REJECT * else => (first < last) REJECT * * else [[first >= TCL_INDEX_START]] && - * (last == TCL_INDEX_AFTER) => cannot tell REJECT * (last <= TCL_INDEX_END) => cannot tell REJECT * else [[last >= TCL_INDEX START]] && (last < first) => ACCEPT */ @@ -1103,34 +1100,34 @@ TclCompileStringReplaceCmd( * (first <= end) * * The encoded indices (first <= TCL_INDEX END) and - * (first == TCL_INDEX_BEFORE) always meets this condition, but + * (first == TCL_INDEX_NONE) always meets this condition, but * any other encoded first index has some list for which it fails. * * We also need, second: * * (last >= 0) * - * The encoded indices (last >= TCL_INDEX_START) and - * (last == TCL_INDEX_AFTER) always meet this condition but any - * other encoded last index has some list for which it fails. + * The encoded index (last >= TCL_INDEX_START) always meet this + * condition but any other encoded last index has some list for + * which it fails. * * Finally we need, third: * * (first <= last) * * Considered in combination with the constraints we already have, - * we see that we can proceed when (first == TCL_INDEX_BEFORE) - * or (last == TCL_INDEX_AFTER). These also permit simplification - * of the prefix|replace|suffix construction. The other constraints, - * though, interfere with getting a guarantee that first <= last. + * we see that we can proceed when (first == TCL_INDEX_NONE). + * These also permit simplification of the prefix|replace|suffix + * construction. The other constraints, though, interfere with + * getting a guarantee that first <= last. */ - if ((first == TCL_INDEX_BEFORE) && (last >= TCL_INDEX_START)) { + if ((first == TCL_INDEX_START) && (last >= TCL_INDEX_START)) { /* empty prefix */ tokenPtr = TokenAfter(tokenPtr); CompileWord(envPtr, tokenPtr, interp, 4); OP4( REVERSE, 2); - if (last == TCL_INDEX_AFTER) { + if (last == INT_MAX) { OP( POP); /* Pop original */ } else { OP44( STR_RANGE_IMM, last + 1, TCL_INDEX_END); @@ -1139,7 +1136,7 @@ TclCompileStringReplaceCmd( return TCL_OK; } - if ((last == TCL_INDEX_AFTER) && (first <= TCL_INDEX_END)) { + if ((last == TCL_INDEX_NONE) && (first <= TCL_INDEX_END)) { OP44( STR_RANGE_IMM, 0, first-1); tokenPtr = TokenAfter(tokenPtr); CompileWord(envPtr, tokenPtr, interp, 4); @@ -1156,10 +1153,10 @@ TclCompileStringReplaceCmd( * are harmless when they are replaced by another empty string. */ - if ((first == TCL_INDEX_BEFORE) || (first == TCL_INDEX_START)) { + if (first == TCL_INDEX_START) { /* empty prefix - build suffix only */ - if ((last == TCL_INDEX_END) || (last == TCL_INDEX_AFTER)) { + if (last == TCL_INDEX_END) { /* empty suffix too => empty result */ OP( POP); /* Pop original */ PUSH ( ""); @@ -1168,7 +1165,7 @@ TclCompileStringReplaceCmd( OP44( STR_RANGE_IMM, last + 1, TCL_INDEX_END); return TCL_OK; } else { - if ((last == TCL_INDEX_END) || (last == TCL_INDEX_AFTER)) { + if (last == TCL_INDEX_END) { /* empty suffix - build prefix only */ OP44( STR_RANGE_IMM, 0, first-1); return TCL_OK; |
