|
2026-11-18
| ||
| 18:32 | • Closed ticket [697b1bbfe3]: Incorrect argument handling by regexp plus 4 o... artifact: 5e808a5aa2 user: serhiy.storchaka | |
| 18:27 | • Ticket [1902890fff] compiled regexp behaves differently status still Pending... artifact: b40148c895 user: serhiy.storchaka | |
| 18:27 | • Ticket [697b1bbfe3] Incorrect argument handling by regexp status still Pen... artifact: 3afa410f3b user: serhiy.storchaka | |
| 18:21 | Fix [697b1bbfe3] and [1902890fff]: Incorrect argument handling by [regexp] check-in: b0610ccd6f user: serhiy.storchaka tags: core-8-6-branch | |
| 17:42 | • Pending ticket [697b1bbfe3]: Incorrect argument handling by regexp plus 5 ... artifact: 3e0e8a1136 user: jan.nijtmans | |
| 17:39 | Fix [697b1bbfe3] and [1902890fff]: Incorrect argument handling by [regexp] check-in: 33b0599e53 user: jan.nijtmans tags: core-9-0-branch | |
|
2026-11-08
| ||
| 20:53 | • Ticket [697b1bbfe3] Incorrect argument handling by regexp status still Ope... artifact: 15facf6005 user: dkf | |
|
2026-10-14
| ||
| 09:26 | Fix [697b1bbfe3] and [1902890fff]: Incorrect argument handling by [regexp] check-in: 6e93204003 user: jan.nijtmans tags: trunk, main | |
|
2026-10-11
| ||
| 07:39 | • Ticket [697b1bbfe3] Incorrect argument handling by regexp status still Ope... artifact: c78524a5f0 user: serhiy.storchaka | |
| 07:35 | Fix [1902890]: compiled [regexp] did not treat an RE value starting with "-" as a switch, unlike the... closed check-in: 0b36adaf16 user: serhiy.storchaka tags: regexp-compile-runtime-switch | |
|
2026-10-10
| ||
| 21:12 | • Ticket [697b1bbfe3] Incorrect argument handling by regexp status still Ope... artifact: cc6ba518d4 user: serhiy.storchaka | |
| 21:12 | • Ticket [697b1bbfe3]: 3 changes artifact: ae26d49811 user: serhiy.storchaka | |
| 21:10 | Fix cases #2 and #4 of [697b1bbfe3]: the bytecode compiler for [regexp] checked for a leading "-" on... closed check-in: a64804ce70 user: serhiy.storchaka tags: regexp-compile-dash-pattern | |
|
2022-09-18
| ||
| 11:30 | • New ticket [697b1bbfe3] Incorrect argument handling by regexp. artifact: 834398468f user: erikleunissen | |
Incorrect argument handling by [regexp]
Here are the results of six invocations of the "regexp" command.
They indicate incorrect argument handling.
% set str "a-z"
a-z
% regexp - $str; #1
bad option "-": must be -all, -about, -indices, -inline, -expanded, -line, -linestop, -lineanchor, -nocase, -start, or --
% regexp \- $str; #2
1
% regexp {-} $str; #3
bad option "-": must be -all, -about, -indices, -inline, -expanded, -line, -linestop, -lineanchor, -nocase, -start, or --
% regexp -\\ $str; #4
couldn't compile regular expression pattern: invalid escape \ sequence
% regexp \\- $str; #5
1
% set initstring "-"
-
% regexp $initstring $str; #6
1
%
This discussion thread at c.l.t. provides some clues:
https://groups.google.com/g/comp.lang.tcl/c/pbqqj8tcIUk
b40148c895Ticket [1902890fff] compiled regexp behaves differently status still Pending with 3 other changes ticket2026-11-18 18:27:58b0610ccd6fFix [697b1bbfe3] and [1902890fff]: Incorrect argument handling by [regexp] check-in2026-11-18 18:21:5933b0599e53Fix [697b1bbfe3] and [1902890fff]: Incorrect argument handling by [regexp] check-in2026-11-18 17:39:076e93204003Fix [697b1bbfe3] and [1902890fff]: Incorrect argument handling by [regexp] check-in2026-10-14 09:26:560b36adaf16Fix [1902890]: compiled [regexp] did not treat an RE value starting with "-" as a switch, unlike the command. When the RE is not known at compile time and there is no --, check it at runtime and call [regexp] itself if it starts with "-". Also fixes [7e4d5a0a2b] and case #6 of [697b1bbfe3]. New tests regexpComp-25.1 to 25.7. check-in2026-10-11 07:35:29a64804ce70Fix cases #2 and #4 of [697b1bbfe3]: the bytecode compiler for [regexp] checked for a leading "-" only in simple words, so patterns like \- or -\\ were compiled instead of being reported as bad options. Check the value of any word known at compile time, as for [regsub]. Incompatible for compiled code relying on it; for the next feature release. New tests regexpComp-24.12 to 24.15. check-in2026-10-10 21:10:10
Still the same in 8.6, 9.0 and 9.1. Cases #1, #3 and #5 are correct: an argument starting with "-" is taken as an option unless it follows --. #2 and #4 differ from the command only in compiled code: the bytecode compiler checked for a leading "-" only in words without backslashes, so \- and -\\ were compiled as patterns. #6 (a pattern in a variable) is the same problem as [1902890fff].
Proposed fix for #2 and #4 in branch regexp-compile-dash-pattern: the compiler checks the value of any word known at compile time, as for regsub, so both now give "bad option" as in #1. Tests regexpComp-24.12 to 24.15.
Proposed fix for case #6 in branch regexp-compile-runtime-switch, see [1902890fff].
Backported to core-8-6-branch: [b0610ccd6f]. In 8.6, regexp \- a-z reports "bad option" instead of 9.0's "ambiguous option", compiled and uncompiled alike, so regexpComp-24.12 expects that.