Overview
| Artifact ID: | cd6ab5aa54db581e84895371fc6a66e05048a75dbc1b7b10f25678a0a01b499d |
|---|---|
| Ticket: | 1902890fffffffffffffffffffffffffffffffff
compiled regexp behaves differently |
| User & Date: | serhiy.storchaka on 2026-10-11 07:39:52 |
Changes
- foundin changed to: "8.6.18, 9.0.5, 9.1.0"
- icomment:
Still the same in 8.6, 9.0 and 9.1. <tt>TclCompileRegexpCmd()</tt> can only check a literal RE for a leading "-"; an RE from a variable went straight to <tt>INST_REGEXP</tt>, which does not parse switches. I disagree with changing <tt>regexp</tt> to match the compiled behaviour: compilation is only an optimization, and the compiled code should always behave like the interpreted command. Proposed fix in branch [/timeline?r=regexp-compile-runtime-switch|regexp-compile-runtime-switch]: when the RE is not known at compile time and there is no <tt>--</tt>, the compiled code checks at runtime whether it starts with "-", and if so calls <tt>regexp</tt> itself. So compiled and interpreted <tt>regexp</tt> now behave the same, including <tt>-about</tt>, and ordinary REs still use <tt>INST_REGEXP</tt>. Tests regexpComp-25.1 to 25.7.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"