Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f10f52b83 | ||
|
|
205080aae1 | ||
|
|
8d6c85039e | ||
|
|
6c33183ede | ||
|
|
1fe9b336da |
+2
-7
@@ -3515,12 +3515,7 @@ Tcl_LsearchObjCmd(
|
||||
*/
|
||||
|
||||
if (start >= (size_t)listc) {
|
||||
if (allMatches || inlineReturn) {
|
||||
Tcl_ResetResult(interp);
|
||||
} else {
|
||||
TclNewIndexObj(itemPtr, TCL_INDEX_NONE);
|
||||
Tcl_SetObjResult(interp, itemPtr);
|
||||
}
|
||||
Tcl_ResetResult(interp);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -3841,7 +3836,7 @@ Tcl_LsearchObjCmd(
|
||||
Tcl_SetObjResult(interp, itemPtr);
|
||||
} else {
|
||||
Tcl_Obj *elObj;
|
||||
TclNewIndexObj(elObj, index);
|
||||
TclNewIndexObj(elObj, (size_t)index);
|
||||
Tcl_SetObjResult(interp, elObj);
|
||||
}
|
||||
} else if (index < 0) {
|
||||
|
||||
+12
-10
@@ -357,7 +357,7 @@ Tcl_RegexpObjCmd(
|
||||
|
||||
objc = info.nsubs + 1;
|
||||
if (all <= 1) {
|
||||
resultPtr = Tcl_NewObj();
|
||||
TclNewObj(resultPtr);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < objc; i++) {
|
||||
@@ -384,22 +384,23 @@ Tcl_RegexpObjCmd(
|
||||
if (end + 1 >= offset + 1) {
|
||||
end--;
|
||||
}
|
||||
TclNewIndexObj(objs[0], start);
|
||||
TclNewIndexObj(objs[1], end);
|
||||
|
||||
newPtr = Tcl_NewListObj(2, objs);
|
||||
} else {
|
||||
start = TCL_INDEX_NONE;
|
||||
end = TCL_INDEX_NONE;
|
||||
TclNewObj(newPtr);
|
||||
}
|
||||
|
||||
TclNewIndexObj(objs[0], start);
|
||||
TclNewIndexObj(objs[1], end);
|
||||
|
||||
newPtr = Tcl_NewListObj(2, objs);
|
||||
} else {
|
||||
if (i <= (int)info.nsubs) {
|
||||
newPtr = Tcl_GetRange(objPtr,
|
||||
offset + info.matches[i].start,
|
||||
offset + info.matches[i].end - 1);
|
||||
} else {
|
||||
newPtr = Tcl_NewObj();
|
||||
TclNewObj(newPtr);
|
||||
}
|
||||
}
|
||||
if (doinline) {
|
||||
@@ -3788,17 +3789,18 @@ TclNRSwitchObjCmd(
|
||||
if (info.matches[j].end + 1 > 1) {
|
||||
TclNewIndexObj(rangeObjAry[0], info.matches[j].start);
|
||||
TclNewIndexObj(rangeObjAry[1], info.matches[j].end-1);
|
||||
Tcl_ListObjAppendElement(NULL, indicesObj,
|
||||
Tcl_NewListObj(2, rangeObjAry));
|
||||
} else {
|
||||
TclNewIndexObj(rangeObjAry[1], TCL_INDEX_NONE);
|
||||
rangeObjAry[0] = rangeObjAry[1];
|
||||
TclNewObj(rangeObjAry[0]);
|
||||
Tcl_ListObjAppendElement(NULL, indicesObj,
|
||||
rangeObjAry[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Never fails; the object is always clean at this point.
|
||||
*/
|
||||
|
||||
Tcl_ListObjAppendElement(NULL, indicesObj,
|
||||
Tcl_NewListObj(2, rangeObjAry));
|
||||
}
|
||||
|
||||
if (matchVarObj != NULL) {
|
||||
|
||||
+4
-3
@@ -2694,6 +2694,7 @@ MODULE_SCOPE const Tcl_ObjType tclBooleanType;
|
||||
MODULE_SCOPE const Tcl_ObjType tclByteArrayType;
|
||||
MODULE_SCOPE const Tcl_ObjType tclByteCodeType;
|
||||
MODULE_SCOPE const Tcl_ObjType tclDoubleType;
|
||||
MODULE_SCOPE const Tcl_ObjType tclEndOffsetType;
|
||||
MODULE_SCOPE const Tcl_ObjType tclIntType;
|
||||
MODULE_SCOPE const Tcl_ObjType tclListType;
|
||||
MODULE_SCOPE const Tcl_ObjType tclDictType;
|
||||
@@ -4821,8 +4822,8 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
|
||||
TclAllocObjStorage(objPtr); \
|
||||
(objPtr)->refCount = 0; \
|
||||
(objPtr)->bytes = NULL; \
|
||||
(objPtr)->internalRep.wideValue = ((_w) == TCL_INDEX_NONE) ? -1 : (Tcl_WideInt)(_w); \
|
||||
(objPtr)->typePtr = &tclIntType; \
|
||||
(objPtr)->internalRep.wideValue = (Tcl_WideInt)(((w) == TCL_INDEX_NONE) ? WIDE_MIN : (w)); \
|
||||
(objPtr)->typePtr = ((w) == TCL_INDEX_NONE) ? &tclEndOffsetType : &tclIntType; \
|
||||
TCL_DTRACE_OBJ_CREATE(objPtr); \
|
||||
} while (0)
|
||||
|
||||
@@ -4852,7 +4853,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
|
||||
(objPtr) = Tcl_NewWideIntObj(w)
|
||||
|
||||
#define TclNewIndexObj(objPtr, w) \
|
||||
(objPtr) = ((w) == TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideIntObj(w)
|
||||
(objPtr) = ((w) == TCL_INDEX_NONE) ? Tcl_NewObj() : Tcl_NewWideIntObj(w)
|
||||
|
||||
#define TclNewDoubleObj(objPtr, d) \
|
||||
(objPtr) = Tcl_NewDoubleObj(d)
|
||||
|
||||
@@ -1411,11 +1411,12 @@ TclLsetList(
|
||||
/*
|
||||
* Determine whether the index arg designates a list or a single index.
|
||||
* We have to be careful about the order of the checks to avoid repeated
|
||||
* shimmering; see TIP #22 and #23 for details.
|
||||
* shimmering; see TIP #22 and #23 for details. Don't allow "" as single
|
||||
* index here, since it cannot be distinguished from an empty list.
|
||||
*/
|
||||
|
||||
ListGetIntRep(indexArgPtr, listRepPtr);
|
||||
if (listRepPtr == NULL
|
||||
if (listRepPtr == NULL && Tcl_GetString(indexArgPtr)[0]
|
||||
&& TclGetIntForIndexM(NULL, indexArgPtr, (size_t)WIDE_MAX - 1, &index) == TCL_OK) {
|
||||
/*
|
||||
* indexArgPtr designates a single index.
|
||||
|
||||
@@ -154,6 +154,10 @@ static const Tcl_ObjType nsNameType = {
|
||||
* "namespace" command.
|
||||
*/
|
||||
|
||||
/* Those two cannot be compiled due to invalid handling of "" index */
|
||||
#define TclCompileNamespaceQualifiersCmd NULL
|
||||
#define TclCompileNamespaceTailCmd NULL
|
||||
|
||||
static const EnsembleImplMap defaultNamespaceMap[] = {
|
||||
{"children", NamespaceChildrenCmd, TclCompileBasic0To2ArgCmd, NULL, NULL, 0},
|
||||
{"code", NamespaceCodeCmd, TclCompileNamespaceCodeCmd, NULL, NULL, 0},
|
||||
|
||||
@@ -669,12 +669,6 @@ TclRegAbout(
|
||||
|
||||
Tcl_ResetResult(interp);
|
||||
|
||||
/*
|
||||
* Assume that there will never be more than INT_MAX subexpressions. This
|
||||
* is a pretty reasonable assumption; the RE engine doesn't scale _that_
|
||||
* well and Tcl has other limits that constrain things as well...
|
||||
*/
|
||||
|
||||
TclNewObj(resultObj);
|
||||
TclNewIndexObj(infoObj, regexpPtr->re.re_nsub);
|
||||
Tcl_ListObjAppendElement(NULL, resultObj, infoObj);
|
||||
|
||||
+1
-9
@@ -1088,15 +1088,7 @@ Tcl_ScanObjCmd(
|
||||
}
|
||||
if (code == TCL_OK) {
|
||||
if (underflow && (nconversions == 0)) {
|
||||
if (numVars) {
|
||||
TclNewIndexObj(objPtr, TCL_INDEX_NONE);
|
||||
} else {
|
||||
if (objPtr) {
|
||||
Tcl_SetListObj(objPtr, 0, NULL);
|
||||
} else {
|
||||
TclNewObj(objPtr);
|
||||
}
|
||||
}
|
||||
TclNewObj(objPtr);
|
||||
} else if (numVars) {
|
||||
TclNewIntObj(objPtr, result);
|
||||
}
|
||||
|
||||
+24
-8
@@ -117,16 +117,27 @@ static int FindElement(Tcl_Interp *interp, const char *string,
|
||||
* performance optimization in Tcl_GetIntForIndex. The internal rep is
|
||||
* stored directly in the wideValue, so no memory management is required
|
||||
* for it. This is a caching intrep, keeping the result of a parse
|
||||
* around. This type is only created from a pre-existing string, so an
|
||||
* updateStringProc will never be called and need not exist. The type
|
||||
* is unregistered, so has no need of a setFromAnyProc either.
|
||||
* around. The type is unregistered, so has no need of a setFromAnyProc.
|
||||
*/
|
||||
|
||||
static const Tcl_ObjType endOffsetType = {
|
||||
static void
|
||||
UpdateStringOfIndex(
|
||||
Tcl_Obj *objPtr) /* Index object whose string rep to update. */
|
||||
{
|
||||
/* The only situation that the string rep can be missing is when it
|
||||
* represents TCL_INDEX_NONE. In all other situations, the string
|
||||
* rep is never thrown away. See TclNewIndexObj() */
|
||||
if ((objPtr)->internalRep.wideValue != WIDE_MIN) {
|
||||
Tcl_Panic("String rep of \"end-offset\" lost");
|
||||
}
|
||||
TclInitStringRep(objPtr, NULL, 0);
|
||||
}
|
||||
|
||||
const Tcl_ObjType tclEndOffsetType = {
|
||||
"end-offset", /* name */
|
||||
NULL, /* freeIntRepProc */
|
||||
NULL, /* dupIntRepProc */
|
||||
NULL, /* updateStringProc */
|
||||
UpdateStringOfIndex, /* updateStringProc */
|
||||
NULL /* setFromAnyProc */
|
||||
};
|
||||
|
||||
@@ -3449,7 +3460,7 @@ GetEndOffsetFromObj(
|
||||
Tcl_WideInt offset = -1; /* Offset in the "end-offset" expression - 1 */
|
||||
ClientData cd;
|
||||
|
||||
while ((irPtr = TclFetchIntRep(objPtr, &endOffsetType)) == NULL) {
|
||||
while ((irPtr = TclFetchIntRep(objPtr, &tclEndOffsetType)) == NULL) {
|
||||
Tcl_ObjIntRep ir;
|
||||
size_t length;
|
||||
const char *bytes = TclGetStringFromObj(objPtr, &length);
|
||||
@@ -3461,6 +3472,11 @@ GetEndOffsetFromObj(
|
||||
|
||||
/* Value doesn't start with "e" */
|
||||
|
||||
if (length == 0) {
|
||||
offset = WIDE_MIN;
|
||||
goto parseOK;
|
||||
}
|
||||
|
||||
/* If we reach here, the string rep of objPtr exists. */
|
||||
|
||||
/*
|
||||
@@ -3635,7 +3651,7 @@ GetEndOffsetFromObj(
|
||||
parseOK:
|
||||
/* Success. Store the new internal rep. */
|
||||
ir.wideValue = offset;
|
||||
Tcl_StoreIntRep(objPtr, &endOffsetType, &ir);
|
||||
Tcl_StoreIntRep(objPtr, &tclEndOffsetType, &ir);
|
||||
}
|
||||
|
||||
offset = irPtr->wideValue;
|
||||
@@ -3739,7 +3755,7 @@ TclIndexEncode(
|
||||
int idx;
|
||||
|
||||
if (TCL_OK == GetWideForIndex(interp, objPtr, (unsigned)TCL_INDEX_END , &wide)) {
|
||||
const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &endOffsetType);
|
||||
const Tcl_ObjIntRep *irPtr = TclFetchIntRep(objPtr, &tclEndOffsetType);
|
||||
if (irPtr && irPtr->wideValue >= 0) {
|
||||
/* "int[+-]int" syntax, works the same here as "int" */
|
||||
irPtr = NULL;
|
||||
|
||||
+9
-9
@@ -54,7 +54,7 @@ namespace eval ::tcl {
|
||||
# tcl_wordBreakAfter --
|
||||
#
|
||||
# This procedure returns the index of the first word boundary after the
|
||||
# starting point in the given string, or -1 if there are no more boundaries in
|
||||
# starting point in the given string, or "" if there are no more boundaries in
|
||||
# the given string. The index returned refers to the first character of the
|
||||
# pair that comprises a boundary.
|
||||
#
|
||||
@@ -64,7 +64,7 @@ namespace eval ::tcl {
|
||||
|
||||
proc tcl_wordBreakAfter {str start} {
|
||||
variable ::tcl::WordBreakRE
|
||||
set result {-1 -1}
|
||||
set result {}
|
||||
regexp -indices -start $start -- $WordBreakRE(after) $str result
|
||||
return [lindex $result 1]
|
||||
}
|
||||
@@ -72,7 +72,7 @@ proc tcl_wordBreakAfter {str start} {
|
||||
# tcl_wordBreakBefore --
|
||||
#
|
||||
# This procedure returns the index of the first word boundary before the
|
||||
# starting point in the given string, or -1 if there are no more boundaries in
|
||||
# starting point in the given string, or " if there are no more boundaries in
|
||||
# the given string. The index returned refers to the second character of the
|
||||
# pair that comprises a boundary.
|
||||
#
|
||||
@@ -82,7 +82,7 @@ proc tcl_wordBreakAfter {str start} {
|
||||
|
||||
proc tcl_wordBreakBefore {str start} {
|
||||
variable ::tcl::WordBreakRE
|
||||
set result {-1 -1}
|
||||
set result {}
|
||||
regexp -indices -- $WordBreakRE(before) [string range $str 0 $start] result
|
||||
return [lindex $result 1]
|
||||
}
|
||||
@@ -92,7 +92,7 @@ proc tcl_wordBreakBefore {str start} {
|
||||
# This procedure returns the index of the first end-of-word location after a
|
||||
# starting index in the given string. An end-of-word location is defined to be
|
||||
# the first whitespace character following the first non-whitespace character
|
||||
# after the starting point. Returns -1 if there are no more words after the
|
||||
# after the starting point. Returns "" if there are no more words after the
|
||||
# starting point.
|
||||
#
|
||||
# Arguments:
|
||||
@@ -101,7 +101,7 @@ proc tcl_wordBreakBefore {str start} {
|
||||
|
||||
proc tcl_endOfWord {str start} {
|
||||
variable ::tcl::WordBreakRE
|
||||
set result {-1 -1}
|
||||
set result {}
|
||||
regexp -indices -start $start -- $WordBreakRE(end) $str result
|
||||
return [lindex $result 1]
|
||||
}
|
||||
@@ -110,7 +110,7 @@ proc tcl_endOfWord {str start} {
|
||||
#
|
||||
# This procedure returns the index of the first start-of-word location after a
|
||||
# starting index in the given string. A start-of-word location is defined to
|
||||
# be a non-whitespace character following a whitespace character. Returns -1
|
||||
# be a non-whitespace character following a whitespace character. Returns ""
|
||||
# if there are no more start-of-word locations after the starting point.
|
||||
#
|
||||
# Arguments:
|
||||
@@ -119,7 +119,7 @@ proc tcl_endOfWord {str start} {
|
||||
|
||||
proc tcl_startOfNextWord {str start} {
|
||||
variable ::tcl::WordBreakRE
|
||||
set result {-1 -1}
|
||||
set result {}
|
||||
regexp -indices -start $start -- $WordBreakRE(next) $str result
|
||||
return [lindex $result 1]
|
||||
}
|
||||
@@ -135,7 +135,7 @@ proc tcl_startOfNextWord {str start} {
|
||||
|
||||
proc tcl_startOfPreviousWord {str start} {
|
||||
variable ::tcl::WordBreakRE
|
||||
set word {-1 -1}
|
||||
set word {}
|
||||
if {$start > 0} {
|
||||
regexp -indices -- $WordBreakRE(previous) [string range $str 0 $start-1] \
|
||||
result word
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ test lpop-1.6 {error conditions} -returnCodes error -body {
|
||||
test lpop-1.7 {error conditions} -returnCodes error -body {
|
||||
set l "x y"
|
||||
lpop l {}
|
||||
} -match glob -result {bad index *}
|
||||
} -match glob -result {index "" out of range}
|
||||
test lpop-1.8 {error conditions} -returnCodes error -body {
|
||||
set l "x y"
|
||||
lpop l 0 0 0 0 1
|
||||
|
||||
+27
-27
@@ -21,8 +21,8 @@ test lsearch-1.1 {lsearch command} {
|
||||
lsearch $x 123
|
||||
} 2
|
||||
test lsearch-1.2 {lsearch command} {
|
||||
lsearch $x 3456
|
||||
} -1
|
||||
expr {[lsearch $x 3456]<0}
|
||||
} 1
|
||||
test lsearch-1.3 {lsearch command} {
|
||||
lsearch $x *5
|
||||
} 4
|
||||
@@ -37,11 +37,11 @@ test lsearch-2.2 {search modes} {
|
||||
lsearch -exact {b.x ^bc xy bcx} ^bc
|
||||
} 1
|
||||
test lsearch-2.3 {search modes} {
|
||||
lsearch -exact {foo bar cat} ba
|
||||
} -1
|
||||
expr {[lsearch -exact {foo bar cat} ba]<0}
|
||||
} 1
|
||||
test lsearch-2.4 {search modes} {
|
||||
lsearch -exact {foo bar cat} bart
|
||||
} -1
|
||||
expr {[lsearch -exact {foo bar cat} bart]<0}
|
||||
} 1
|
||||
test lsearch-2.5 {search modes} {
|
||||
lsearch -exact {foo bar cat} bar
|
||||
} 1
|
||||
@@ -293,8 +293,8 @@ test lsearch-10.1 {offset searching} {
|
||||
lsearch -start 2 {a b c a b c} a
|
||||
} 3
|
||||
test lsearch-10.2 {offset searching} {
|
||||
lsearch -start 2 {a b c d e f} a
|
||||
} -1
|
||||
expr {[lsearch -start 2 {a b c d e f} a]<0}
|
||||
} 1
|
||||
test lsearch-10.3 {offset searching} {
|
||||
lsearch -start end-4 {a b c a b c} a
|
||||
} 3
|
||||
@@ -310,15 +310,15 @@ test lsearch-10.6 {binary search with offset} {
|
||||
lappend res [lsearch -integer -start 2 -sorted $increasingIntegers $i]
|
||||
}
|
||||
set res
|
||||
} [concat -1 -1 [lrange $increasingIntegers 2 end]]
|
||||
} [concat {{}} {{}} [lrange $increasingIntegers 2 end]]
|
||||
test lsearch-10.7 {offset searching with an empty list} {
|
||||
# Stop bug #694232 from reocurring
|
||||
lsearch -start 0 {} x
|
||||
} -1
|
||||
expr {[lsearch -start 0 {} x]<0}
|
||||
} 1
|
||||
test lsearch-10.8 {offset searching past the end of the list} {
|
||||
# Stop [Bug 1374778] from reoccurring
|
||||
lsearch -start 10 {a b c} c
|
||||
} -1
|
||||
expr {[lsearch -start 10 {a b c} c]<0}
|
||||
} 1
|
||||
test lsearch-10.9 {offset searching past the end of the list} {
|
||||
# Stop [Bug 1374778] from reoccurring
|
||||
lsearch -start 10 -all {a b c} c
|
||||
@@ -332,8 +332,8 @@ test lsearch-11.1 {negated searches} {
|
||||
lsearch -not {a a a b a a a} a
|
||||
} 3
|
||||
test lsearch-11.2 {negated searches} {
|
||||
lsearch -not {a a a a a a a} a
|
||||
} -1
|
||||
expr {[lsearch -not {a a a a a a a} a]<0}
|
||||
} 1
|
||||
|
||||
test lsearch-12.1 {return values instead of indices} {
|
||||
lsearch -glob -inline {a1 b2 c3 d4} c*
|
||||
@@ -514,7 +514,7 @@ test lsearch-22.1 {lsearch -bisect} -setup {
|
||||
lappend res [lsearch -bisect -integer {1 4 5 7 9 15} $i]
|
||||
}
|
||||
return $res
|
||||
} -result {-1 0 2 2 3 3 5 5}
|
||||
} -result {{} 0 2 2 3 3 5 5}
|
||||
test lsearch-22.2 {lsearch -bisect, last of equals} -setup {
|
||||
set res {}
|
||||
} -body {
|
||||
@@ -530,7 +530,7 @@ test lsearch-22.3 {lsearch -bisect decreasing order} -setup {
|
||||
lappend res [lsearch -bisect -integer -decreasing {15 9 7 5 4 1} $i]
|
||||
}
|
||||
return $res
|
||||
} -result {5 5 3 2 2 1 0 -1}
|
||||
} -result {5 5 3 2 2 1 0 {}}
|
||||
test lsearch-22.4 {lsearch -bisect, last of equals, decreasing} -setup {
|
||||
set res {}
|
||||
} -body {
|
||||
@@ -565,14 +565,14 @@ test lsearch-23.5 {lsearch -stride option, errors} -body {
|
||||
} -result 0
|
||||
|
||||
test lsearch-24.1 {lsearch -stride option} -body {
|
||||
lsearch -stride 2 {a b c d e f g h} d
|
||||
} -result -1
|
||||
expr {[lsearch -stride 2 {a b c d e f g h} d]<0}
|
||||
} -result 1
|
||||
test lsearch-24.2 {lsearch -stride option} -body {
|
||||
lsearch -stride 2 {a b c d e f g h} e
|
||||
} -result 4
|
||||
test lsearch-24.3 {lsearch -stride option} -body {
|
||||
lsearch -stride 3 {a b c d e f g h i} e
|
||||
} -result -1
|
||||
expr {[lsearch -stride 3 {a b c d e f g h i} e]<0}
|
||||
} -result 1
|
||||
test lsearch-24.4 {lsearch -stride option} -body {
|
||||
# Result points first in group
|
||||
lsearch -stride 3 -index 1 {a b c d e f g h i} e
|
||||
@@ -665,20 +665,20 @@ test lsearch-28.1 {lsearch -sorted with -stride} -body {
|
||||
lsearch -sorted -stride 2 {5 3 7 8 9 2} 5
|
||||
} -result 0
|
||||
test lsearch-28.2 {lsearch -sorted with -stride} -body {
|
||||
lsearch -sorted -stride 2 {5 3 7 8 9 2} 3
|
||||
} -result -1
|
||||
expr {[lsearch -sorted -stride 2 {5 3 7 8 9 2} 3]<0}
|
||||
} -result 1
|
||||
test lsearch-28.3 {lsearch -sorted with -stride} -body {
|
||||
lsearch -sorted -stride 2 {5 3 7 8 9 2} 7
|
||||
} -result 2
|
||||
test lsearch-28.4 {lsearch -sorted with -stride} -body {
|
||||
lsearch -sorted -stride 2 {5 3 7 8 9 2} 8
|
||||
} -result -1
|
||||
expr {[lsearch -sorted -stride 2 {5 3 7 8 9 2} 8]<0}
|
||||
} -result 1
|
||||
test lsearch-28.5 {lsearch -sorted with -stride} -body {
|
||||
lsearch -sorted -stride 2 {5 3 7 8 9 2} 9
|
||||
} -result 4
|
||||
test lsearch-28.6 {lsearch -sorted with -stride} -body {
|
||||
lsearch -sorted -stride 2 {5 3 7 8 9 2} 2
|
||||
} -result -1
|
||||
expr {[lsearch -sorted -stride 2 {5 3 7 8 9 2} 2]<0}
|
||||
} -result 1
|
||||
test lsearch-28.7 {lsearch -sorted with -stride} -body {
|
||||
lsearch -sorted -stride 2 -index 0 -subindices {5 3 7 8 9 2} 9
|
||||
} -result 4
|
||||
|
||||
+11
-11
@@ -187,11 +187,11 @@ test regexp-3.5 {-indices option to regexp} {
|
||||
test regexp-3.6 {getting substrings back from regexp} {
|
||||
set foo 2; set f2 2; set f3 2; set f4 2
|
||||
list [regexp -indices (a)(b)? xay foo f2 f3 f4] $foo $f2 $f3 $f4
|
||||
} {1 {1 1} {1 1} {-1 -1} {-1 -1}}
|
||||
} {1 {1 1} {1 1} {} {}}
|
||||
test regexp-3.7 {getting substrings back from regexp} {
|
||||
set foo 1; set f2 1; set f3 1; set f4 1
|
||||
list [regexp -indices (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4
|
||||
} {1 {1 2} {1 1} {-1 -1} {2 2}}
|
||||
} {1 {1 2} {1 1} {} {2 2}}
|
||||
test regexp-3.8a {-indices by multi-byte utf-8} {
|
||||
regexp -inline -indices {(\w+)-(\w+)} \
|
||||
"gr\u00FC\u00DF-\u043F\u0440\u0438\u0432\u0435\u0442"
|
||||
@@ -752,7 +752,7 @@ test regexp-18.11 {regexp -all} {
|
||||
} {a}
|
||||
test regexp-18.12 {regexp -all -inline -indices} {
|
||||
regexp -all -inline -indices a(b(c)d|e(f)g)h abcdhaefgh
|
||||
} {{0 4} {1 3} {2 2} {-1 -1} {5 9} {6 8} {-1 -1} {7 7}}
|
||||
} {{0 4} {1 3} {2 2} {} {5 9} {6 8} {} {7 7}}
|
||||
|
||||
test regexp-19.1 {regsub null replacement} {
|
||||
regsub -all {@} {@hel@lo@} "\0a\0" result
|
||||
@@ -815,7 +815,7 @@ test regexp-21.12 {multiple matches handle newlines} {
|
||||
} "\#\n\#\n\#"
|
||||
test regexp-21.13 {multiple matches handle newlines} {
|
||||
regexp -all -inline -indices -line -- ^ "a\nb\nc"
|
||||
} {{0 -1} {2 1} {4 3}}
|
||||
} {{0 {}} {2 1} {4 3}}
|
||||
test regexp-21.14 {regsub works with empty string} {
|
||||
regsub -- ^ {} &
|
||||
} {}
|
||||
@@ -912,28 +912,28 @@ test regexp-23.1 {regexp -all and -line} {
|
||||
[regexp -all -inline -indices -line -- {^} $string] \
|
||||
[regexp -all -inline -indices -line -- {^$} $string] \
|
||||
[regexp -all -inline -indices -line -- {$} $string]
|
||||
} {{{0 -1}} {{0 -1}} {{0 -1}}}
|
||||
} {{{0 {}}} {{0 {}}} {{0 {}}}}
|
||||
test regexp-23.2 {regexp -all and -line} {
|
||||
set string "\n"
|
||||
list \
|
||||
[regexp -all -inline -indices -line -- {^} $string] \
|
||||
[regexp -all -inline -indices -line -- {^$} $string] \
|
||||
[regexp -all -inline -indices -line -- {$} $string]
|
||||
} {{{0 -1}} {{0 -1}} {{0 -1}}}
|
||||
} {{{0 {}}} {{0 {}}} {{0 {}}}}
|
||||
test regexp-23.3 {regexp -all and -line} {
|
||||
set string "\n\n"
|
||||
list \
|
||||
[regexp -all -inline -indices -line -- {^} $string] \
|
||||
[regexp -all -inline -indices -line -- {^$} $string] \
|
||||
[regexp -all -inline -indices -line -- {$} $string]
|
||||
} {{{0 -1} {1 0}} {{0 -1} {1 0}} {{0 -1} {1 0}}}
|
||||
} {{{0 {}} {1 0}} {{0 {}} {1 0}} {{0 {}} {1 0}}}
|
||||
test regexp-23.4 {regexp -all and -line} {
|
||||
set string "a"
|
||||
list \
|
||||
[regexp -all -inline -indices -line -- {^} $string] \
|
||||
[regexp -all -inline -indices -line -- {^.*$} $string] \
|
||||
[regexp -all -inline -indices -line -- {$} $string]
|
||||
} {{{0 -1}} {{0 0}} {{1 0}}}
|
||||
} {{{0 {}}} {{0 0}} {{1 0}}}
|
||||
test regexp-23.5 {regexp -all and -line} {knownBug} {
|
||||
set string "a\n"
|
||||
list \
|
||||
@@ -947,7 +947,7 @@ test regexp-23.6 {regexp -all and -line} {
|
||||
[regexp -all -inline -indices -line -- {^} $string] \
|
||||
[regexp -all -inline -indices -line -- {^.*$} $string] \
|
||||
[regexp -all -inline -indices -line -- {$} $string]
|
||||
} {{{0 -1} {1 0}} {{0 -1} {1 1}} {{0 -1} {2 1}}}
|
||||
} {{{0 {}} {1 0}} {{0 {}} {1 1}} {{0 {}} {2 1}}}
|
||||
test regexp-23.7 {regexp -all and -line} {knownBug} {
|
||||
set string "ab\n"
|
||||
list \
|
||||
@@ -961,7 +961,7 @@ test regexp-23.8 {regexp -all and -line} {
|
||||
[regexp -all -inline -indices -line -- {^} $string] \
|
||||
[regexp -all -inline -indices -line -- {^.*$} $string] \
|
||||
[regexp -all -inline -indices -line -- {$} $string]
|
||||
} {{{0 -1} {2 1}} {{0 0} {2 2}} {{1 0} {3 2}}}
|
||||
} {{{0 {}} {2 1}} {{0 0} {2 2}} {{1 0} {3 2}}}
|
||||
test regexp-23.9 {regexp -all and -line} {knownBug} {
|
||||
set string "a\nb\n"
|
||||
list \
|
||||
@@ -975,7 +975,7 @@ test regexp-23.10 {regexp -all and -line} {
|
||||
[regexp -all -inline -indices -line -- {^} $string] \
|
||||
[regexp -all -inline -indices -line -- {^.*$} $string] \
|
||||
[regexp -all -inline -indices -line -- {$} $string]
|
||||
} {{{0 -1} {2 1} {4 3}} {{0 0} {2 2} {4 4}} {{1 0} {3 2} {5 4}}}
|
||||
} {{{0 {}} {2 1} {4 3}} {{0 0} {2 2} {4 4}} {{1 0} {3 2} {5 4}}}
|
||||
test regexp-23.11 {regexp -all and -line} {
|
||||
regexp -all -inline -indices -line -- {b} "abb\nb"
|
||||
} {{1 1} {2 2} {4 4}}
|
||||
|
||||
@@ -226,13 +226,13 @@ test regexpComp-3.6 {getting substrings back from regexp} {
|
||||
set foo 2; set f2 2; set f3 2; set f4 2
|
||||
list [regexp -indices (a)(b)? xay foo f2 f3 f4] $foo $f2 $f3 $f4
|
||||
}
|
||||
} {1 {1 1} {1 1} {-1 -1} {-1 -1}}
|
||||
} {1 {1 1} {1 1} {} {}}
|
||||
test regexpComp-3.7 {getting substrings back from regexp} {
|
||||
evalInProc {
|
||||
set foo 1; set f2 1; set f3 1; set f4 1
|
||||
list [regexp -indices (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4
|
||||
}
|
||||
} {1 {1 2} {1 1} {-1 -1} {2 2}}
|
||||
} {1 {1 2} {1 1} {} {2 2}}
|
||||
|
||||
test regexpComp-4.1 {-nocase option to regexp} {
|
||||
evalInProc {
|
||||
@@ -782,7 +782,7 @@ test regexpComp-18.12 {regexp -all -inline -indices} {
|
||||
evalInProc {
|
||||
regexp -all -inline -indices a(b(c)d|e(f)g)h abcdhaefgh
|
||||
}
|
||||
} {{0 4} {1 3} {2 2} {-1 -1} {5 9} {6 8} {-1 -1} {7 7}}
|
||||
} {{0 4} {1 3} {2 2} {} {5 9} {6 8} {} {7 7}}
|
||||
|
||||
test regexpComp-19.1 {regsub null replacement} {
|
||||
evalInProc {
|
||||
|
||||
@@ -157,10 +157,10 @@ test safe-stock-9.8 {test auto-loading in safe interpreters, was safe-5.1} -setu
|
||||
catch {safe::interpDelete a}
|
||||
safe::interpCreate a
|
||||
} -body {
|
||||
interp eval a {tcl_endOfWord "" 0}
|
||||
expr {[interp eval a {tcl_endOfWord "" 0}]<0}
|
||||
} -cleanup {
|
||||
safe::interpDelete a
|
||||
} -result -1
|
||||
} -result 1
|
||||
test safe-stock-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, uses pkg opt and tcl::idna} -setup {
|
||||
} -body {
|
||||
set i [safe::interpCreate -accessPath [list $tcl_library \
|
||||
|
||||
+10
-10
@@ -206,20 +206,20 @@ test scan-4.13 {Tcl_ScanObjCmd, width specifiers} {
|
||||
} {5 abc 123 456.0 789 012}
|
||||
test scan-4.14 {Tcl_ScanObjCmd, underflow} {
|
||||
set x {}
|
||||
list [scan {a} {a%d} x] $x
|
||||
} {-1 {}}
|
||||
list [expr {[scan {a} {a%d} x]<0}] $x
|
||||
} {1 {}}
|
||||
test scan-4.15 {Tcl_ScanObjCmd, underflow} {
|
||||
set x {}
|
||||
list [scan {} {a%d} x] $x
|
||||
} {-1 {}}
|
||||
list [expr {[scan {} {a%d} x]<0}] $x
|
||||
} {1 {}}
|
||||
test scan-4.16 {Tcl_ScanObjCmd, underflow} {
|
||||
set x {}
|
||||
list [scan {ab} {a%d} x] $x
|
||||
} {0 {}}
|
||||
test scan-4.17 {Tcl_ScanObjCmd, underflow} {
|
||||
set x {}
|
||||
list [scan {a } {a%d} x] $x
|
||||
} {-1 {}}
|
||||
list [expr {[scan {a } {a%d} x]<0}] $x
|
||||
} {1 {}}
|
||||
test scan-4.18 {Tcl_ScanObjCmd, skipping whitespace} {
|
||||
list [scan { b} {%c%s} x y] $x $y
|
||||
} {2 32 b}
|
||||
@@ -348,8 +348,8 @@ test scan-4.43 {Tcl_ScanObjCmd, integer scanning, odd cases} -setup {
|
||||
test scan-4.44 {Tcl_ScanObjCmd, integer scanning, odd cases} -setup {
|
||||
set x {}
|
||||
} -body {
|
||||
list [scan {+} {%i} x] $x
|
||||
} -result {-1 {}}
|
||||
list [expr {[scan {+} {%i} x]<0}] $x
|
||||
} -result {1 {}}
|
||||
test scan-4.45 {Tcl_ScanObjCmd, integer scanning, odd cases} -setup {
|
||||
set x {}
|
||||
} -body {
|
||||
@@ -395,8 +395,8 @@ test scan-4.54 {Tcl_ScanObjCmd, float scanning} {
|
||||
test scan-4.55 {Tcl_ScanObjCmd, odd cases} -setup {
|
||||
set x {}
|
||||
} -body {
|
||||
list [scan {+} %f x] $x
|
||||
} -result {-1 {}}
|
||||
list [expr {[scan {+} %f x]<0}] $x
|
||||
} -result {1 {}}
|
||||
test scan-4.56 {Tcl_ScanObjCmd, odd cases} -setup {
|
||||
set x {}
|
||||
} -body {
|
||||
|
||||
+20
-20
@@ -388,8 +388,8 @@ test string-4.7.$noComp {string first} {
|
||||
run {string first xxx x123xx345xxx789xxx012}
|
||||
} 9
|
||||
test string-4.8.$noComp {string first} {
|
||||
run {string first "" x123xx345xxx789xxx012}
|
||||
} -1
|
||||
run {expr {[string first "" x123xx345xxx789xxx012]<0}}
|
||||
} 1
|
||||
test string-4.9.$noComp {string first, unicode} {
|
||||
run {string first x abc\u7266x}
|
||||
} 4
|
||||
@@ -400,8 +400,8 @@ test string-4.11.$noComp {string first, start index} {
|
||||
run {string first \u7266 abc\u7266x 3}
|
||||
} 3
|
||||
test string-4.12.$noComp {string first, start index} -body {
|
||||
run {string first \u7266 abc\u7266x 4}
|
||||
} -result -1
|
||||
run {expr {[string first \u7266 abc\u7266x 4]<0}}
|
||||
} -result 1
|
||||
test string-4.13.$noComp {string first, start index} -body {
|
||||
run {string first \u7266 abc\u7266x end-2}
|
||||
} -result 3
|
||||
@@ -423,8 +423,8 @@ test string-4.16.$noComp {string first, normal string vs pure unicode string} -b
|
||||
[string first $m $s]}
|
||||
} -result {{string 1} {string 0} 2}
|
||||
test string-4.17.$noComp {string first, corner case} -body {
|
||||
run {string first a aaa 4294967295}
|
||||
} -result {-1}
|
||||
run {expr {[string first a aaa 4294967295]<0}}
|
||||
} -result 1
|
||||
test string-4.18.$noComp {string first, corner case} -body {
|
||||
run {string first a aaa -1}
|
||||
} -result {0}
|
||||
@@ -435,11 +435,11 @@ test string-4.20.$noComp {string last, corner case} -body {
|
||||
run {string last a aaa 4294967295}
|
||||
} -result {2}
|
||||
test string-4.21.$noComp {string last, corner case} -body {
|
||||
run {string last a aaa -1}
|
||||
} -result {-1}
|
||||
test string-4.22.$noComp {string last, corner case} {
|
||||
run {string last a aaa end-5}
|
||||
} {-1}
|
||||
run {expr {[string last a aaa -1]<0}}
|
||||
} -result 1
|
||||
test string-4.22.$noComp {string last, corner case} -body {
|
||||
run {expr {[string last a aaa end-5]<0}}
|
||||
} -result 1
|
||||
|
||||
test string-5.1.$noComp {string index} {
|
||||
list [catch {run {string index}} msg] $msg
|
||||
@@ -864,8 +864,8 @@ test string-6.101.$noComp {string is wideinteger, false} {
|
||||
list [run {string is wideinteger -fail var 123abc}] $var
|
||||
} {0 3}
|
||||
test string-6.102.$noComp {string is wideinteger, false on overflow} {
|
||||
list [run {string is wideinteger -fail var +[largest_int]0}] $var
|
||||
} {0 -1}
|
||||
list [run {string is wideinteger -fail var +[largest_int]0}] [expr {$var<0}]
|
||||
} {0 1}
|
||||
test string-6.103.$noComp {string is wideinteger, false} {
|
||||
list [run {string is wideinteger -fail var [expr double(1)]}] $var
|
||||
} {0 1}
|
||||
@@ -1007,8 +1007,8 @@ test string-7.11.$noComp {string last, start index} {
|
||||
run {string last \u7266 abc\u7266x 3}
|
||||
} 3
|
||||
test string-7.12.$noComp {string last, start index} {
|
||||
run {string last \u7266 abc\u7266x 2}
|
||||
} -1
|
||||
run {expr {[string last \u7266 abc\u7266x 2]<0}}
|
||||
} 1
|
||||
test string-7.13.$noComp {string last, start index} {
|
||||
## Constrain to last 'a' should work
|
||||
run {string last ba badbad end-1}
|
||||
@@ -1018,8 +1018,8 @@ test string-7.14.$noComp {string last, start index} {
|
||||
run {string last ba badbad end-2}
|
||||
} 0
|
||||
test string-7.15.$noComp {string last, start index} {
|
||||
run {string last \334a \334ad\334ad 0}
|
||||
} -1
|
||||
run {expr {[string last \334a \334ad\334ad 0]<0}}
|
||||
} 1
|
||||
test string-7.16.$noComp {string last, start index} {
|
||||
run {string last \334a \334ad\334ad end-1}
|
||||
} 3
|
||||
@@ -2513,9 +2513,9 @@ test string-32.9.$noComp {string is dict} {
|
||||
list [string is dict -failindex x {a b c d}] $x
|
||||
} {1 {}}
|
||||
test string-32.9a.$noComp {string is dict} {
|
||||
set x {}
|
||||
list [string is dict -failindex x {a b c}] $x
|
||||
} {0 -1}
|
||||
set x 0
|
||||
list [string is dict -failindex x {a b c}] [expr {$x<0}]
|
||||
} {0 1}
|
||||
test string-32.10.$noComp {string is dict} {
|
||||
set x {}
|
||||
list [string is dict -failindex x "a \{b c d"] $x
|
||||
|
||||
+1
-1
@@ -569,7 +569,7 @@ test switch-12.8 {-indexvar and matched empty strings} {
|
||||
} {{0 2} {3 2}}
|
||||
test switch-12.9 {-indexvar and unmatched strings} {
|
||||
switch -regexp -indexvar x -- abcdef ^...(x)? {return $x}
|
||||
} {{0 2} {-1 -1}}
|
||||
} {{0 2} {}}
|
||||
|
||||
test switch-13.1 {-indexvar -matchvar combinations} {
|
||||
switch -regexp -indexvar x -matchvar y abc {
|
||||
|
||||
+1
-1
@@ -614,7 +614,7 @@ test util-9.18 {Tcl_GetIntForIndex} {
|
||||
} b
|
||||
test util-9.19 {Tcl_GetIntForIndex} -body {
|
||||
string index a {}
|
||||
} -returnCodes error -match glob -result *
|
||||
} -result {}
|
||||
test util-9.20 {Tcl_GetIntForIndex} -body {
|
||||
string index a { }
|
||||
} -returnCodes error -match glob -result *
|
||||
|
||||
Reference in New Issue
Block a user