diff options
-rw-r--r-- | .travis.yml | 24 | ||||
-rw-r--r-- | doc/library.n | 9 | ||||
-rw-r--r-- | doc/string.n | 68 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 175 | ||||
-rw-r--r-- | generic/tclInt.decls | 2 | ||||
-rw-r--r-- | library/cookiejar/cookiejar.tcl | 3 | ||||
-rw-r--r-- | tests/info.test | 4 | ||||
-rw-r--r-- | tests/regexp.test | 4 | ||||
-rw-r--r-- | tests/regexpComp.test | 4 | ||||
-rw-r--r-- | tests/string.test | 254 |
10 files changed, 168 insertions, 379 deletions
diff --git a/.travis.yml b/.travis.yml index 50eb658..6ab1540 100644 --- a/.travis.yml +++ b/.travis.yml @@ -139,9 +139,9 @@ matrix: - BUILD_DIR=unix - CFGOPT="--enable-symbols=mem" # Testing on Mac, various styles - - name: "macOS/Xcode 11.4/Shared" + - name: "macOS/Clang/Xcode 11.5/Shared" os: osx - osx_image: xcode11.4 + osx_image: xcode11.5 env: - BUILD_DIR=macosx install: [] @@ -149,20 +149,28 @@ matrix: - make all # The styles=develop avoids some weird problems on OSX - make test styles=develop - - name: "macOS/Xcode 11.4/Shared/Unix-like" + - name: "macOS/Clang/Xcode 11.5/Shared/Unix-like" os: osx - osx_image: xcode11.4 + osx_image: xcode11.5 env: - BUILD_DIR=unix + - name: "macOS/Clang++/Xcode 11.5/Shared" + os: osx + osx_image: xcode11.5 + env: + - BUILD_DIR=unix + - CFGOPT="CC=clang++ --enable-framework CFLAGS=-Dregister=dont+use+register CPPFLAGS=-D__private_extern__=extern" + script: + - make all tcltest # Older MacOS versions - - name: "macOS/Xcode 11/Shared" + - name: "macOS/Clang/Xcode 11/Shared" os: osx osx_image: xcode11 env: - BUILD_DIR=macosx install: [] script: *mactest - - name: "macOS/Xcode 10/Shared" + - name: "macOS/Clang/Xcode 10/Shared" os: osx osx_image: xcode10.3 env: @@ -173,7 +181,7 @@ matrix: homebrew: packages: - libtommath - - name: "macOS/Xcode 9/Shared" + - name: "macOS/Clang/Xcode 9/Shared" os: osx osx_image: xcode9.2 env: @@ -184,7 +192,7 @@ matrix: homebrew: packages: - libtommath - - name: "macOS/Xcode 8/Shared" + - name: "macOS/Clang/Xcode 8/Shared" os: osx osx_image: xcode8.3 env: diff --git a/doc/library.n b/doc/library.n index 6f8f265..4dcd598 100644 --- a/doc/library.n +++ b/doc/library.n @@ -299,18 +299,13 @@ These variables are only used in the \fBtcl_endOfWord\fR, This variable contains a regular expression that is used by routines like \fBtcl_endOfWord\fR to identify whether a character is part of a word or not. If the pattern matches a character, the character is -considered to be a non-word character. On Windows platforms, spaces, -tabs, and newlines are considered non-word characters. Under Unix, -everything but numbers, letters and underscores are considered -non-word characters. +considered to be a non-word character. The default is "\\W". .TP \fBtcl_wordchars\fR This variable contains a regular expression that is used by routines like \fBtcl_endOfWord\fR to identify whether a character is part of a word or not. If the pattern matches a character, the character is -considered to be a word character. On Windows platforms, words are -comprised of any character that is not a space, tab, or newline. Under -Unix, words are comprised of numbers, letters or underscores. +considered to be a word character. The default is "\\w". .SH "SEE ALSO" env(n), info(n), re_syntax(n) .SH KEYWORDS diff --git a/doc/string.n b/doc/string.n index 44d621d..1ebedc4 100644 --- a/doc/string.n +++ b/doc/string.n @@ -33,6 +33,20 @@ and is more efficient than building a list of arguments and using \fBjoin\fR with an empty join string. .RE .TP +\fBstring charend \fIstring charIndex\fR +. +Returns the index of the next character just after position \fIcharIndex\fR +in the \fIstring\fR. \fIcharIndex\fR may be specified using the forms in +\fBSTRING INDICES\fR. If position \fIcharIndex\fR of \fIstring\fR holds a +character > U+FFFF, the returned index will be 2 higher than \fIcharIndex\fR. +.TP +\fBstring charstart \fIstring charIndex\fR +. +Returns the index of the character containing \fIcharIndex\fR in the \fIstring\fR. +\fIcharIndex\fR may be specified using the forms in \fBSTRING INDICES\fR. +Normally this will return \fIcharIndex\fR, except if position \fIcharIndex\fR-1 +holds a chraracter > U+FFFF: In that case the returned index will be one higher. +.TP \fBstring compare\fR ?\fB\-nocase\fR? ?\fB\-length\fI length\fR? \fIstring1 string2\fR . Perform a character-by-character comparison of strings \fIstring1\fR @@ -223,6 +237,24 @@ number of bytes used to store the string. If the value is a byte array value (such as those returned from reading a binary encoded channel), then this will return the actual byte length of the value. .TP +\fBstring lineend \fIstring charIndex\fR +. +Returns the index of the character just after the last one in the word +containing character \fIcharIndex\fR of \fIstring\fR. \fIcharIndex\fR +may be specified using the forms in \fBSTRING INDICES\fR. A word is +considered to be any contiguous range of alphanumeric (Unicode letters +or decimal digits) or underscore (Unicode connector punctuation) +characters, or any single character other than these. +.TP +\fBstring linestart \fIstring charIndex\fR +. +Returns the index of the first character in the word containing character +\fIcharIndex\fR of \fIstring\fR. \fIcharIndex\fR may be specified using the +forms in \fBSTRING INDICES\fR. A word is considered to be any contiguous +range of alphanumeric (Unicode letters or decimal digits) or underscore +(Unicode connector punctuation) characters, or any single character other than +these. +.TP \fBstring map\fR ?\fB\-nocase\fR? \fImapping string\fR . Replaces substrings in \fIstring\fR based on the key-value pairs in @@ -371,6 +403,24 @@ characters present in the string given by \fIchars\fR are removed. If \fIchars\fR is not specified then white space is removed (any character for which \fBstring is space\fR returns 1, and "\e0"). .TP +\fBstring wordend \fIstring charIndex\fR +. +Returns the index of the character just after the last one in the word +containing character \fIcharIndex\fR of \fIstring\fR. \fIcharIndex\fR +may be specified using the forms in \fBSTRING INDICES\fR. A word is +considered to be any contiguous range of alphanumeric (Unicode letters +or decimal digits) or underscore (Unicode connector punctuation) +characters, or any single character other than these. +.TP +\fBstring wordstart \fIstring charIndex\fR +. +Returns the index of the first character in the word containing character +\fIcharIndex\fR of \fIstring\fR. \fIcharIndex\fR may be specified using the +forms in \fBSTRING INDICES\fR. A word is considered to be any contiguous +range of alphanumeric (Unicode letters or decimal digits) or underscore +(Unicode connector punctuation) characters, or any single character other than +these. +.TP \fBstring trimright \fIstring\fR ?\fIchars\fR? . Returns a value equal to \fIstring\fR except that any trailing @@ -422,24 +472,6 @@ encoding and then apply \fBstring length\fR to that. \fBstring length\fR [encoding convertto utf-8 $theString] .CE .RE -.TP -\fBstring wordend \fIstring charIndex\fR -. -Returns the index of the character just after the last one in the word -containing character \fIcharIndex\fR of \fIstring\fR. \fIcharIndex\fR -may be specified using the forms in \fBSTRING INDICES\fR. A word is -considered to be any contiguous range of alphanumeric (Unicode letters -or decimal digits) or underscore (Unicode connector punctuation) -characters, or any single character other than these. -.TP -\fBstring wordstart \fIstring charIndex\fR -. -Returns the index of the first character in the word containing character -\fIcharIndex\fR of \fIstring\fR. \fIcharIndex\fR may be specified using the -forms in \fBSTRING INDICES\fR. A word is considered to be any contiguous -range of alphanumeric (Unicode letters or decimal digits) or underscore -(Unicode connector punctuation) characters, or any single character other than -these. .SH "STRING INDICES" .PP When referring to indices into a string (e.g., for \fBstring index\fR diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 36b2443..e15e5c8 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -2537,6 +2537,8 @@ StringStartCmd( if (cur != index) { cur += 1; } + } else { + cur = -1; } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(cur)); return TCL_OK; @@ -2545,9 +2547,9 @@ StringStartCmd( /* *---------------------------------------------------------------------- * - * StringPrevCharCmd -- + * StringCharStartCmd -- * - * This procedure is invoked to process the "string prevchar" Tcl + * This procedure is invoked to process the "string charstart" Tcl * command. See the user documentation for details on what it does. * * Results: @@ -2560,7 +2562,7 @@ StringStartCmd( */ static int -StringPrevCharCmd( +StringCharStartCmd( TCL_UNUSED(ClientData), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2590,90 +2592,7 @@ StringPrevCharCmd( Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); return TCL_OK; } - -/* - *---------------------------------------------------------------------- - * - * StringPrevWordCmd -- - * - * This procedure is invoked to process the "string prevword" Tcl - * command. See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - -static int -StringPrevWordCmd( - TCL_UNUSED(ClientData), - Tcl_Interp *interp, /* Current interpreter. */ - int objc, /* Number of arguments. */ - Tcl_Obj *const objv[]) /* Argument objects. */ -{ - int ch; - const Tcl_UniChar *p, *string; - int cur, index, length; - - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "string index"); - return TCL_ERROR; - } - - string = Tcl_GetUnicodeFromObj(objv[1], &length); - if (TclGetIntForIndexM(interp, objv[2], length-1, &index) != TCL_OK) { - return TCL_ERROR; - } - if (index >= length) { - index = length - 1; - } - cur = 0; - if (index > 0) { - p = &string[index]; - - TclUniCharToUCS4(p, &ch); - for (cur = index; cur >= 0; cur--) { - int delta = 0; - const Tcl_UniChar *next; - - if (!Tcl_UniCharIsWordChar(ch)) { - break; - } - - next = TclUCS4Prev(p, string); - do { - next += delta; - delta = TclUniCharToUCS4(next, &ch); - } while (next + delta < p); - p = next; - } - for (; cur >= 0; cur--) { - int delta = 0; - const Tcl_UniChar *next; - - if (Tcl_UniCharIsWordChar(ch)) { - break; - } - - next = TclUCS4Prev(p, string); - do { - next += delta; - delta = TclUniCharToUCS4(next, &ch); - } while (next + delta < p); - p = next; - } - if (cur != index) { - cur += 1; - } - } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(cur)); - return TCL_OK; -} - + /* *---------------------------------------------------------------------- * @@ -2727,19 +2646,18 @@ StringEndCmd( cur++; } } else { - cur = length; + cur = -1; } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(cur)); return TCL_OK; } - /* *---------------------------------------------------------------------- * - * StringNextCharCmd -- + * StringCharEndCmd -- * - * This procedure is invoked to process the "string nextchar" Tcl command. + * This procedure is invoked to process the "string charend" Tcl command. * See the user documentation for details on what it does. * * Results: @@ -2752,7 +2670,7 @@ StringEndCmd( */ static int -StringNextCharCmd( +StringCharEndCmd( TCL_UNUSED(ClientData), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2777,75 +2695,12 @@ StringNextCharCmd( if (index < length) { index += TclUniCharToUCS4(&string[index], &ch); } else { - index = length; - } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); - return TCL_OK; -} - - -/* - *---------------------------------------------------------------------- - * - * StringNextWordCmd -- - * - * This procedure is invoked to process the "string nextword" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - -static int -StringNextWordCmd( - TCL_UNUSED(ClientData), - Tcl_Interp *interp, /* Current interpreter. */ - int objc, /* Number of arguments. */ - Tcl_Obj *const objv[]) /* Argument objects. */ -{ - int ch; - const Tcl_UniChar *p, *end, *string; - int index, length; - - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "string index"); - return TCL_ERROR; - } - - string = Tcl_GetUnicodeFromObj(objv[1], &length); - if (TclGetIntForIndexM(interp, objv[2], length-1, &index) != TCL_OK) { - return TCL_ERROR; - } - if (index < 0) { - index = 0; - } - if (index < length) { - p = &string[index]; - end = string+length; - while (index++, p < end) { - p += TclUniCharToUCS4(p, &ch); - if (!Tcl_UniCharIsWordChar(ch)) { - break; - } - } - for (; p < end; index++) { - p += TclUniCharToUCS4(p, &ch); - if (Tcl_UniCharIsWordChar(ch)) { - break; - } - } - } else { - index = length; + index = -1; } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -3548,6 +3403,8 @@ TclInitStringCmd( static const EnsembleImplMap stringImplMap[] = { {"bytelength", StringBytesCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0}, {"cat", StringCatCmd, TclCompileStringCatCmd, NULL, NULL, 0}, + {"charend", StringCharEndCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, + {"charstart", StringCharStartCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, {"compare", StringCmpCmd, TclCompileStringCmpCmd, NULL, NULL, 0}, {"equal", StringEqualCmd, TclCompileStringEqualCmd, NULL, NULL, 0}, {"first", StringFirstCmd, TclCompileStringFirstCmd, NULL, NULL, 0}, @@ -3558,10 +3415,6 @@ TclInitStringCmd( {"length", StringLenCmd, TclCompileStringLenCmd, NULL, NULL, 0}, {"map", StringMapCmd, TclCompileStringMapCmd, NULL, NULL, 0}, {"match", StringMatchCmd, TclCompileStringMatchCmd, NULL, NULL, 0}, - {"nextchar", StringNextCharCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, - {"nextword", StringNextWordCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, - {"prevchar", StringPrevCharCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, - {"prevword", StringPrevWordCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, {"range", StringRangeCmd, TclCompileStringRangeCmd, NULL, NULL, 0}, {"repeat", StringReptCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, {"replace", StringRplcCmd, TclCompileStringReplaceCmd, NULL, NULL, 0}, diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 948ec26..8845359 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -893,7 +893,7 @@ declare 227 { # Used to be needed for TclOO-extension; unneeded now that TclOO is in the # core and NRE-enabled # declare 228 { -# int TclObjInterpProcCore(register Tcl_Interp *interp, Tcl_Obj *procNameObj, +# int TclObjInterpProcCore(Tcl_Interp *interp, Tcl_Obj *procNameObj, # int skip, ProcErrorProc *errorProc) # } declare 229 { diff --git a/library/cookiejar/cookiejar.tcl b/library/cookiejar/cookiejar.tcl index c8b495a..6c8e82b 100644 --- a/library/cookiejar/cookiejar.tcl +++ b/library/cookiejar/cookiejar.tcl @@ -98,7 +98,8 @@ namespace eval [info object namespace ::http::cookiejar] { } proc splitPath path { set pieces [split [string trimleft $path "/"] "/"] - for {set j -1} {$j < [llength $pieces]} {incr j} { + set result / + for {set j 0} {$j < [llength $pieces]} {incr j} { lappend result /[join [lrange $pieces 0 $j] "/"] } return $result diff --git a/tests/info.test b/tests/info.test index 18f5c7a..ce51523 100644 --- a/tests/info.test +++ b/tests/info.test @@ -103,8 +103,8 @@ test info-2.5 {info body option, returning bytecompiled bodies} -body { # causing an empty string to be returned [Bug #545644] test info-2.6 {info body option, returning list bodies} { proc foo args [list subst bar] - list [string length [info body foo]] \ - [foo; string length [info body foo]] + list [string bytelength [info body foo]] \ + [foo; string bytelength [info body foo]] } {9 9} proc testinfocmdcount {} { diff --git a/tests/regexp.test b/tests/regexp.test index 03c55b7..bae1217 100644 --- a/tests/regexp.test +++ b/tests/regexp.test @@ -760,8 +760,8 @@ test regexp-20.1 {regsub shared object shimmering} -body { set b $a set c abcdefghijklmnopqurstuvwxyz0123456789 regsub $a $c $b d - list $d [string length $d] -} -result [list abcdefghijklmnopqurstuvwxyz0123456789 37] + list $d [string length $d] [string bytelength $d] +} -result [list abcdefghijklmnopqurstuvwxyz0123456789 37 37] test regexp-20.2 {regsub shared object shimmering with -about} -body { eval regexp -about abc } -result {0 {}} diff --git a/tests/regexpComp.test b/tests/regexpComp.test index 390b003..8819dd2 100644 --- a/tests/regexpComp.test +++ b/tests/regexpComp.test @@ -798,9 +798,9 @@ test regexpComp-20.1 {regsub shared object shimmering} { set b $a set c abcdefghijklmnopqurstuvwxyz0123456789 regsub $a $c $b d - list $d [string length $d] + list $d [string length $d] [string bytelength $d] } -} [list abcdefghijklmnopqurstuvwxyz0123456789 37] +} [list abcdefghijklmnopqurstuvwxyz0123456789 37 37] test regexpComp-20.2 {regsub shared object shimmering with -about} { evalInProc { eval regexp -about abc diff --git a/tests/string.test b/tests/string.test index 17a6d3c..d868610 100644 --- a/tests/string.test +++ b/tests/string.test @@ -75,7 +75,7 @@ if {$noComp} { test string-1.1.$noComp {error conditions} -body { list [catch {run {string gorp a b}} msg] $msg -} -match regexp -result {1 {unknown or ambiguous subcommand "gorp": must be (bytelength, |)cat, compare, equal, first, index, insert, is, last, length, map, match, nextchar, nextword, prevchar, prevword, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} +} -match regexp -result {1 {unknown or ambiguous subcommand "gorp": must be (bytelength, |)cat, charend, charstart, compare, equal, first, index, insert, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-1.2.$noComp {error conditions} { list [catch {run {string}} msg] $msg } {1 {wrong # args: should be "string subcommand ?arg ...?"}} @@ -1802,7 +1802,7 @@ test string-20.1.$noComp {string trimright errors} { } {1 {wrong # args: should be "string trimright string ?chars?"}} test string-20.2.$noComp {string trimright errors} -body { list [catch {run {string trimg a}} msg] $msg -} -match regexp -result {1 {unknown or ambiguous subcommand "trimg": must be (bytelength, |)cat, compare, equal, first, index, insert, is, last, length, map, match, nextchar, nextword, prevchar, prevword, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} +} -match regexp -result {1 {unknown or ambiguous subcommand "trimg": must be (bytelength, |)cat, charend, charstart, compare, equal, first, index, insert, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-20.3.$noComp {string trimright} { run {string trimright " XYZ "} } { XYZ} @@ -1858,7 +1858,7 @@ test string-21.4.$noComp {string wordend} -body { } -result 3 test string-21.5.$noComp {string wordend} -body { run {string wordend abc. 100} -} -result 4 +} -result -1 test string-21.6.$noComp {string wordend} -body { run {string wordend "word_one two three" 2} } -result 8 @@ -1885,17 +1885,17 @@ test string-21.13.$noComp {string wordend, unicode} -body { } -result 3 test string-21.14.$noComp {string wordend, unicode} -body { run {string wordend "\uC700\uC700 abc" 8} -} -result 6 +} -result -1 test string-21.15.$noComp {string wordend, unicode} -body { run {string wordend "\U1D7CA\U1D7CA abc" 0} } -result 2 test string-21.16.$noComp {string wordend, unicode} -constraints utf16 -body { run {string wordend "\U1D7CA\U1D7CA abc" 10} -} -result 8 +} -result -1 test string-22.1.$noComp {string wordstart} -body { list [catch {run {string word a}} msg] $msg -} -match regexp -result {1 {unknown or ambiguous subcommand "word": must be (bytelength, |)cat, compare, equal, first, index, insert, is, last, length, map, match, nextchar, nextword, prevchar, prevword, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} +} -match regexp -result {1 {unknown or ambiguous subcommand "word": must be (bytelength, |)cat, charend, charstart, compare, equal, first, index, insert, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-22.2.$noComp {string wordstart} -body { list [catch {run {string wordstart a}} msg] $msg } -result {1 {wrong # args: should be "string wordstart string index"}} @@ -1913,7 +1913,7 @@ test string-22.6.$noComp {string wordstart} -body { } -result 0 test string-22.7.$noComp {string wordstart} -body { run {string wordstart "one two three_words" -2} -} -result 0 +} -result -1 test string-22.8.$noComp {string wordstart} -body { run {string wordstart "one .*&^ three" 6} } -result 6 @@ -1939,7 +1939,7 @@ test string-22.14.$noComp {string wordstart, invalid UTF-8} -constraints testbyt } -result g test string-22.15.$noComp {string wordstart, unicode} -body { run {string wordstart "\U1D7CA\U1D7CA abc" 0} -} -result 0 +} -result -1 test string-22.16.$noComp {string wordstart, unicode} -constraints utf16 -body { run {string wordstart "\U1D7CA\U1D7CA abc" 10} } -result 5 @@ -2534,205 +2534,105 @@ test string-32.17.$noComp {string is dict, valid dict packed in invalid dict} { string is dict {{a b c d e f g h}} } 0 -test string-33.1.$noComp {string nextchar} -body { - list [catch {run {string nextchar a}} msg] $msg -} -result {1 {wrong # args: should be "string nextchar string index"}} -test string-33.2.$noComp {string nextchar} -body { - list [catch {run {string nextchar a b c}} msg] $msg -} -result {1 {wrong # args: should be "string nextchar string index"}} -test string-33.3.$noComp {string nextchar} -body { - list [catch {run {string nextchar a gorp}} msg] $msg +test string-33.1.$noComp {string charend} -body { + list [catch {run {string charend a}} msg] $msg +} -result {1 {wrong # args: should be "string charend string index"}} +test string-33.2.$noComp {string charend} -body { + list [catch {run {string charend a b c}} msg] $msg +} -result {1 {wrong # args: should be "string charend string index"}} +test string-33.3.$noComp {string charend} -body { + list [catch {run {string charend a gorp}} msg] $msg } -result {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} -test string-33.4.$noComp {string nextchar} -body { - run {string nextchar abc. -1} +test string-33.4.$noComp {string charend} -body { + run {string charend abc. -1} } -result 1 -test string-33.5.$noComp {string nextchar} -body { - run {string nextchar abc. 100} -} -result 4 -test string-33.6.$noComp {string nextchar} -body { - run {string nextchar "word_one two three" 2} +test string-33.5.$noComp {string charend} -body { + run {string charend abc. 100} +} -result -1 +test string-33.6.$noComp {string charend} -body { + run {string charend "word_one two three" 2} } -result 3 -test string-33.7.$noComp {string nextchar} -body { - run {string nextchar "one .&# three" 5} +test string-33.7.$noComp {string charend} -body { + run {string charend "one .&# three" 5} } -result 6 -test string-33.8.$noComp {string nextchar} -body { +test string-33.8.$noComp {string charend} -body { run {string worde "x.y" 0} } -result 1 -test string-33.9.$noComp {string nextchar} -body { +test string-33.9.$noComp {string charend} -body { run {string worde "x.y" end-1} } -result 2 -test string-33.10.$noComp {string nextchar, unicode} -body { - run {string nextchar "xyz\xC7de fg" 0} +test string-33.10.$noComp {string charend, unicode} -body { + run {string charend "xyz\xC7de fg" 0} } -result 1 -test string-33.11.$noComp {string nextchar, unicode} -body { - run {string nextchar "xyz\uC700de fg" 0} +test string-33.11.$noComp {string charend, unicode} -body { + run {string charend "xyz\uC700de fg" 0} } -result 1 -test string-33.12.$noComp {string nextchar, unicode} -body { - run {string nextchar "xyz\u203Fde fg" 0} +test string-33.12.$noComp {string charend, unicode} -body { + run {string charend "xyz\u203Fde fg" 0} } -result 1 -test string-33.13.$noComp {string nextchar, unicode} -body { - run {string nextchar "xyz\u2045de fg" 0} +test string-33.13.$noComp {string charend, unicode} -body { + run {string charend "xyz\u2045de fg" 0} } -result 1 -test string-33.14.$noComp {string nextchar, unicode} -body { - run {string nextchar "\uC700\uC700 abc" 8} -} -result 6 -test string-33.15.$noComp {string nextchar, unicode} -constraints utf16 -body { - run {string nextchar "\U1D7CA\U1D7CA abc" 0} -} -result 2 -test string-33.16.$noComp {string nextchar, unicode} -constraints utf16 -body { - run {string nextchar "\U1D7CA\U1D7CA abc" 10} -} -result 8 - -test string-34.1.$noComp {string nextword} -body { - list [catch {run {string nextword a}} msg] $msg -} -result {1 {wrong # args: should be "string nextword string index"}} -test string-34.2.$noComp {string nextword} -body { - list [catch {run {string nextword a b c}} msg] $msg -} -result {1 {wrong # args: should be "string nextword string index"}} -test string-34.3.$noComp {string nextword} -body { - list [catch {run {string nextword a gorp}} msg] $msg -} -result {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} -test string-34.4.$noComp {string nextword} -body { - run {string nextword abc. -1} -} -result 4 -test string-34.5.$noComp {string nextword} -body { - run {string nextword abc. 100} -} -result 4 -test string-34.6.$noComp {string nextword} -body { - run {string nextword "word_one two three" 2} -} -result 9 -test string-34.7.$noComp {string nextword} -body { - run {string nextword "one .&# three" 5} -} -result 8 -test string-34.8.$noComp {string nextword} -body { - run {string worde "x.y" 0} -} -result 1 -test string-34.9.$noComp {string nextword} -body { - run {string worde "x.y" end-1} +test string-33.14.$noComp {string charend, unicode} -body { + run {string charend "\uC700\uC700 abc" 8} +} -result -1 +test string-33.15.$noComp {string charend, unicode} -constraints utf16 -body { + run {string charend "\U1D7CA\U1D7CA abc" 0} } -result 2 -test string-34.10.$noComp {string nextword, unicode} -body { - run {string nextword "xyz\xC7de fg" 0} -} -result 7 -test string-34.11.$noComp {string nextword, unicode} -body { - run {string nextword "xyz\uC700de fg" 0} -} -result 7 -test string-34.12.$noComp {string nextword, unicode} -body { - run {string nextword "xyz\u203Fde fg" 0} -} -result 7 -test string-34.13.$noComp {string nextword, unicode} -body { - run {string nextword "xyz\u2045\u2045de fg" 0} -} -result 5 -test string-34.14.$noComp {string nextword, unicode} -body { - run {string nextword "\uC700\uC700 abc" 8} -} -result 6 -test string-34.15.$noComp {string nextword, unicode} -body { - run {string nextword "\U1D7CA\U1D7CA abc" 0} -} -result 3 -test string-34.16.$noComp {string nextword, unicode} -constraints utf16 -body { - run {string nextword "\U1D7CA\U1D7CA abc" 10} -} -result 8 +test string-33.16.$noComp {string charend, unicode} -constraints utf16 -body { + run {string charend "\U1D7CA\U1D7CA abc" 10} +} -result -1 -test string-35.1.$noComp {string prevchar} -body { +test string-34.1.$noComp {string charstart} -body { list [catch {run {string word a}} msg] $msg -} -match regexp -result {1 {unknown or ambiguous subcommand "word": must be (bytelength, |)cat, compare, equal, first, index, insert, is, last, length, map, match, nextchar, nextword, prevchar, prevword, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} -test string-35.2.$noComp {string prevchar} -body { - list [catch {run {string prevchar a}} msg] $msg -} -result {1 {wrong # args: should be "string prevchar string index"}} -test string-35.3.$noComp {string prevchar} -body { - list [catch {run {string prevchar a b c}} msg] $msg -} -result {1 {wrong # args: should be "string prevchar string index"}} -test string-35.4.$noComp {string prevchar} -body { - list [catch {run {string prevchar a gorp}} msg] $msg +} -match regexp -result {1 {unknown or ambiguous subcommand "word": must be (bytelength, |)cat, charend, charstart, compare, equal, first, index, insert, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} +test string-34.2.$noComp {string charstart} -body { + list [catch {run {string charstart a}} msg] $msg +} -result {1 {wrong # args: should be "string charstart string index"}} +test string-34.3.$noComp {string charstart} -body { + list [catch {run {string charstart a b c}} msg] $msg +} -result {1 {wrong # args: should be "string charstart string index"}} +test string-34.4.$noComp {string charstart} -body { + list [catch {run {string charstart a gorp}} msg] $msg } -result {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} -test string-35.5.$noComp {string prevchar} -body { - run {string prevchar "one two three_words" 400} +test string-34.5.$noComp {string charstart} -body { + run {string charstart "one two three_words" 400} } -result 18 -test string-35.6.$noComp {string prevchar} -body { - run {string prevchar "one two three_words" 2} +test string-34.6.$noComp {string charstart} -body { + run {string charstart "one two three_words" 2} } -result 1 -test string-35.7.$noComp {string prevchar} -body { - run {string prevchar "one two three_words" -2} +test string-34.7.$noComp {string charstart} -body { + run {string charstart "one two three_words" -2} } -result 0 -test string-35.8.$noComp {string prevchar} -body { - run {string prevchar "one .*&^ three" 6} +test string-34.8.$noComp {string charstart} -body { + run {string charstart "one .*&^ three" 6} } -result 5 -test string-35.9.$noComp {string prevchar} -body { - run {string prevchar "one two three" 4} +test string-34.9.$noComp {string charstart} -body { + run {string charstart "one two three" 4} } -result 3 -test string-35.10.$noComp {string prevchar} -body { - run {string prevchar "one two three" end-5} +test string-34.10.$noComp {string charstart} -body { + run {string charstart "one two three" end-5} } -result 6 -test string-35.11.$noComp {string prevchar, unicode} -body { - run {string prevchar "one tw\xC7o three" 7} +test string-34.11.$noComp {string charstart, unicode} -body { + run {string charstart "one tw\xC7o three" 7} } -result 6 -test string-35.12.$noComp {string prevchar, unicode} -body { - run {string prevchar "ab\uC700\uC700 cdef ghi" 12} +test string-34.12.$noComp {string charstart, unicode} -body { + run {string charstart "ab\uC700\uC700 cdef ghi" 12} } -result 11 -test string-35.13.$noComp {string prevchar, unicode} -body { - run {string prevchar "\uC700\uC700 abc" 8} +test string-34.13.$noComp {string charstart, unicode} -body { + run {string charstart "\uC700\uC700 abc" 8} } -result 5 -test string-35.14.$noComp {string prevchar, invalid UTF-8} -constraints testbytestring -body { +test string-34.14.$noComp {string charstart, invalid UTF-8} -constraints testbytestring -body { # See Bug c61818e4c9 set demo [testbytestring "abc def\xE0\xA9ghi"] - run {string index $demo [string prevchar $demo 10]} + run {string index $demo [string charstart $demo 10]} } -result g -test string-35.15.$noComp {string prevchar, unicode} -body { - run {string prevchar "\U1D7CA\U1D7CA abc" 0} +test string-34.15.$noComp {string charstart, unicode} -body { + run {string charstart "\U1D7CA\U1D7CA abc" 0} } -result 0 -test string-35.16.$noComp {string prevchar, unicode} -constraints utf16 -body { - run {string prevchar "\U1D7CA\U1D7CA abc" 10} -} -result 7 - -test string-36.1.$noComp {string prevword} -body { - list [catch {run {string word a}} msg] $msg -} -match regexp -result {1 {unknown or ambiguous subcommand "word": must be (bytelength, |)cat, compare, equal, first, index, insert, is, last, length, map, match, nextchar, nextword, prevchar, prevword, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} -test string-36.2.$noComp {string prevword} -body { - list [catch {run {string prevword a}} msg] $msg -} -result {1 {wrong # args: should be "string prevword string index"}} -test string-36.3.$noComp {string prevword} -body { - list [catch {run {string prevword a b c}} msg] $msg -} -result {1 {wrong # args: should be "string prevword string index"}} -test string-36.4.$noComp {string prevword} -body { - list [catch {run {string prevword a gorp}} msg] $msg -} -result {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} -test string-36.5.$noComp {string prevword} -body { - run {string prevword "one two three_words" 400} +test string-34.16.$noComp {string charstart, unicode} -constraints utf16 -body { + run {string charstart "\U1D7CA\U1D7CA abc" 10} } -result 7 -test string-36.6.$noComp {string prevword} -body { - run {string prevword "one two three_words" 2} -} -result 0 -test string-36.7.$noComp {string prevword} -body { - run {string prevword "one two three_words" -2} -} -result 0 -test string-36.8.$noComp {string prevword} -body { - run {string prevword "one .*&^ three" 6} -} -result 3 -test string-36.9.$noComp {string prevword} -body { - run {string prevword "one two three" 4} -} -result 3 -test string-36.10.$noComp {string prevword} -body { - run {string prevword "one two three" end-5} -} -result 7 -test string-36.11.$noComp {string prevword, unicode} -body { - run {string prevword "one tw\xC7o three" 7} -} -result 3 -test string-36.12.$noComp {string prevword, unicode} -body { - run {string prevword "ab\uC700\uC700 cdef ghi" 12} -} -result 9 -test string-36.13.$noComp {string prevword, unicode} -body { - run {string prevword "\uC700\uC700 abc" 8} -} -result 2 -test string-36.14.$noComp {string prevword, invalid UTF-8} -constraints testbytestring -body { - # See Bug c61818e4c9 - set demo [testbytestring "abc def\xE0\xA9ghi"] - run {string index $demo [string prevword $demo 10]} -} -result \xA9 -test string-36.15.$noComp {string prevword, unicode} -body { - run {string prevword "\U1D7CA\U1D7CA abc" 0} -} -result 0 -test string-36.16.$noComp {string prevword, unicode} -constraints utf16 -body { - run {string prevword "\U1D7CA\U1D7CA abc" 10} -} -result 4 }; # foreach noComp {0 1} |