Skip to content

Commit d9a34ad

Browse files
committed
Merge 9.0. Bug [cb03e57a] - raise error on empty regexp for unresolved variable.
2 parents 9d51245 + 0a9db80 commit d9a34ad

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

doc/chan.n

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ Instruct Tcl to always send output to \fBstdout\fR immediately,
809809
whether or not it is to a terminal:
810810
.PP
811811
.CS
812-
\fBfconfigure\fR stdout -buffering none
812+
\fBchan configure\fR stdout -buffering none
813813
.CE
814814
.PP
815815
In the following example a file is opened using the encoding CP1252, which is

generic/tclCompCmdsGR.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,14 +2447,11 @@ TclCompileRegexpCmd(
24472447
return TCL_ERROR;
24482448
}
24492449

2450-
if (len == 0) {
2451-
/*
2452-
* The semantics of regexp are always match on re == "".
2453-
*/
2454-
2455-
PUSH( "1");
2456-
return TCL_OK;
2457-
}
2450+
/*
2451+
* Note: do not optimize for len == 0, as error should be generated
2452+
* at runtime if operand is not a resolvable variable.
2453+
* Bug https://core.tcl-lang.org/tcl/info/cb03e57a7b24d22c
2454+
*/
24582455

24592456
/*
24602457
* Attempt to convert pattern to glob. If successful, push the

tests/binary.test

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,9 +3049,27 @@ test binary-80.4 {Tcl_GetBytesFromObj} -constraints testbytestring -returnCodes
30493049
testbytestring [testbytestring "\xC0\x80\xA0\xA0\xA0\xF0\x9F\x98\x81"]
30503050
} -result "expected byte sequence but character 4 was '\U01F601' (U+01F601)"
30513051
test binary-80.5 {Tcl_GetBytesFromObj} -constraints {
3052-
bigmem testbytestring pointerIs64bit deprecated
3052+
bigmem testbytestring pointerIs64bit deprecated
30533053
} -body {
3054-
testbytestring [string repeat A [expr 2**31]]
3054+
# dynamic constraint - ensure the data segment is large enough on this box for this test:
3055+
if {
3056+
[testConstraint unix] &&
3057+
![catch { exec sh -c {ulimit -d} } dssz] &&
3058+
$dssz ne "unlimited" && $dssz <= 4400000
3059+
} {
3060+
tcltest::Skip "DBIGMEM: too small data seg size limit ($dssz <= 4400000)"
3061+
}
3062+
# dynamic constraint - ensure we're able to allocate such large block:
3063+
if {[catch { string repeat A [expr 2**31] } ret opt]} {
3064+
if {[string match "*unable to alloc*" $ret]} {
3065+
tcltest::Skip "DBIGMEM: $ret"
3066+
}
3067+
return {*}$opt $ret
3068+
}
3069+
# test:
3070+
testbytestring $ret
3071+
} -cleanup {
3072+
unset -nocomplain opt ret dssz
30553073
} -returnCodes 1 -result "byte sequence length exceeds INT_MAX"
30563074

30573075
# ----------------------------------------------------------------------

tests/regexp.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,11 @@ test regexp-27.12 {regsub -command representation smash} {
11991199
set s {list (.+)}
12001200
regsub -command $s {list list} $s
12011201
} {(.+) {list list} list}
1202+
1203+
test regexp-28.1 {bug cb03e57a7b} -returnCodes error -body {
1204+
regexp {} $nosuchvar
1205+
} -result {can't read "nosuchvar": no such variable}
1206+
12021207

12031208
# cleanup
12041209
::tcltest::cleanupTests

0 commit comments

Comments
 (0)