Tcl Source Code

Check-in [a3fb69be9f]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Don't use [pid] in tests, stick to constant literals.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-429
Files: files | file ages | folders
SHA1: a3fb69be9fb35f5e4122a6a14b218b16344bfb53
User & Date: ferrieux 2014-08-02 15:26:46
Context
2014-08-03
22:43
Tidy up the docs check-in: d560d1022a user: dkf tags: tip-429
2014-08-02
15:26
Don't use [pid] in tests, stick to constant literals. check-in: a3fb69be9f user: ferrieux tags: tip-429
13:04
TIP 429 Implementation: [string cat] check-in: 9ce779b099 user: ferrieux tags: tip-429
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/string.n.

15
16
17
18
19
20
21

22
23
24
25
26
27
28

29
30
31
32
33
34
35
\fBstring \fIoption arg \fR?\fIarg ...?\fR
.BE
.SH DESCRIPTION
.PP
Performs one of several string operations, depending on \fIoption\fR.
The legal \fIoption\fRs (which may be abbreviated) are:
.TP

\fBstring cat\fR ?\fIstring1\fR? ?\fIstring2...\fR?
.
Concatenate the given strings just like direct juxtaposition
would. This primitive is occasionally handier than juxtaposition when
mixed quoting is wanted, or when the aim is to return the result of a
concatenation without resorting to \fB[return -level 0]\fR. If no arg
is present, an empty string is returned.

.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
and \fIstring2\fR.  Returns \-1, 0, or 1, depending on whether
\fIstring1\fR is lexicographically less than, equal to, or greater
than \fIstring2\fR.  If \fB\-length\fR is specified, then only the






>







>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
\fBstring \fIoption arg \fR?\fIarg ...?\fR
.BE
.SH DESCRIPTION
.PP
Performs one of several string operations, depending on \fIoption\fR.
The legal \fIoption\fRs (which may be abbreviated) are:
.TP
.VS 8.6.2
\fBstring cat\fR ?\fIstring1\fR? ?\fIstring2...\fR?
.
Concatenate the given strings just like direct juxtaposition
would. This primitive is occasionally handier than juxtaposition when
mixed quoting is wanted, or when the aim is to return the result of a
concatenation without resorting to \fB[return -level 0]\fR. If no arg
is present, an empty string is returned.
.VE
.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
and \fIstring2\fR.  Returns \-1, 0, or 1, depending on whether
\fIstring1\fR is lexicographically less than, equal to, or greater
than \fIstring2\fR.  If \fB\-length\fR is specified, then only the

Changes to tests/string.test.

1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
    tcl::prefix longest {ax\x90 bep ax\x91} a
} ax

test string-29.1 {string cat, no arg} {
    string cat
} ""
test string-29.2 {string cat, single arg} {
    set x [pid]
    string compare $x [string cat $x]
} 0
test string-29.3 {string cat, two args} {
    set x [pid]
    string compare $x$x [string cat $x $x]
} 0
test string-29.4 {string cat, many args} {
    set x [pid]
    set n 260
    set xx [string repeat $x $n]
    set vv [string repeat {$x} $n]
    set vvs [string repeat {$x } $n]
    set r1 [string compare $xx [subst $vv]]
    set r2 [string compare $xx [eval "string cat $vvs"]]
    list $r1 $r2






|



|



|







1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
    tcl::prefix longest {ax\x90 bep ax\x91} a
} ax

test string-29.1 {string cat, no arg} {
    string cat
} ""
test string-29.2 {string cat, single arg} {
    set x FOO
    string compare $x [string cat $x]
} 0
test string-29.3 {string cat, two args} {
    set x FOO
    string compare $x$x [string cat $x $x]
} 0
test string-29.4 {string cat, many args} {
    set x FOO
    set n 260
    set xx [string repeat $x $n]
    set vv [string repeat {$x} $n]
    set vvs [string repeat {$x } $n]
    set r1 [string compare $xx [subst $vv]]
    set r2 [string compare $xx [eval "string cat $vvs"]]
    list $r1 $r2

Changes to tests/stringComp.test.

739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
## string cat
test stringComp-29.1 {string cat, no arg} {
    proc foo {} {string cat}
    foo
} ""
test stringComp-29.2 {string cat, single arg} {
    proc foo {} {
	set x [pid]
	string compare $x [string cat $x]
    }
    foo
} 0
test stringComp-29.3 {string cat, two args} {
    proc foo {} {
	set x [pid]
	string compare $x$x [string cat $x $x]
    }
    foo
} 0
test stringComp-29.4 {string cat, many args} {
    proc foo {} {
	set x [pid]
	set n 260
	set xx [string repeat $x $n]
	set vv [string repeat {$x} $n]
	set vvs [string repeat {$x } $n]
	set r1 [string compare $xx [subst $vv]]
	set r2 [string compare $xx [eval "string cat $vvs"]]
	list $r1 $r2






|






|






|







739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
## string cat
test stringComp-29.1 {string cat, no arg} {
    proc foo {} {string cat}
    foo
} ""
test stringComp-29.2 {string cat, single arg} {
    proc foo {} {
	set x FOO
	string compare $x [string cat $x]
    }
    foo
} 0
test stringComp-29.3 {string cat, two args} {
    proc foo {} {
	set x FOO
	string compare $x$x [string cat $x $x]
    }
    foo
} 0
test stringComp-29.4 {string cat, many args} {
    proc foo {} {
	set x FOO
	set n 260
	set xx [string repeat $x $n]
	set vv [string repeat {$x} $n]
	set vvs [string repeat {$x } $n]
	set r1 [string compare $xx [subst $vv]]
	set r2 [string compare $xx [eval "string cat $vvs"]]
	list $r1 $r2