Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-13
12:22 • Closed ticket [1178541fff]: REG_BOSONLY incorrect with | plus 7 other change... artifact: 9b479c9219 user: jan.nijtmans
09:26
Fix [1178541]: with REG_BOSONLY only the first alternative was anchored at the beginning of the stri... check-in: 00f3da1949 user: jan.nijtmans tags: core-8-6-branch
2026-10-12
11:38
Fix [1178541]: with REG_BOSONLY only the first alternative was anchored at the beginning of the stri... check-in: 36b1871836 user: jan.nijtmans tags: core-9-0-branch
2026-10-11
20:53
Fix [1178541]: with REG_BOSONLY only the first alternative was anchored at the beginning of the stri... check-in: a712586c65 user: jan.nijtmans tags: trunk, main
08:46 • Ticket [1178541fff] REG_BOSONLY incorrect with | status still Open with 4 ot... artifact: 70a24ce841 user: serhiy.storchaka
08:45
Fix [1178541]: with REG_BOSONLY only the first alternative was anchored at the beginning of the stri... closed check-in: d1dd282861 user: serhiy.storchaka tags: regexp-bosonly-alternatives
2015-11-06
22:14 • Ticket [1178541fff] REG_BOSONLY incorrect with | status still Open with 7 ot... artifact: cae79199d9 user: tgl
22:10 • Add attachment bosonly.patch to ticket [1178541fff] artifact: ca8a8c6e68 user: tgl
2005-04-07
21:42 • Ticket [1178541fff] REG_BOSONLY incorrect with | status still Open with 4 ot... artifact: 1849538ed5 user: wielemaker
21:42 • Add attachment x to ticket [1178541fff] artifact: 4e1975ff9e user: wielemaker
21:42 • Ticket [1178541fff] REG_BOSONLY incorrect with | status still Open with 4 ot... artifact: 4bd0e230d5 user: wielemaker
13:37 • New ticket [1178541fff]. artifact: 0a30cbe007 user: wielemaker

REG_BOSONLY incorrect with |

Closed / Fixed1178541fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 50 days ago
Descriptionplain2005-04-07 13:37:44
Hi,

I've incorporated the Tcl regex code in my project
(www.swi-prolog.org) and found a bug in the regex
code.  I guess that will also affect Tcl.  I didn't
find a patch yet, I have some trouble sorting out the
internals.

In my app it shows as

?-send(regex('foo|bar'), match, 'xxx bar').

which succeeds!

Match (instead of search) sets REG_BOSONLY, but this causes
the regex to be read as \Afoo|bar rather than \A(foo|bar).

Using foo|\Abar, all works fine as well.

      Cheers --- Jan
wielemakerplain2005-04-07 21:42:00
Logged In: YES 
user_id=1222641

After a bit if hacking I came up with the following patch. 
Its not
tested very much, but it does run the fairly limited test
set I have.
Note that the lines may be shifted a bit as I made some more
modifications to interface the code with the rest of the
environment,

    Cheers --- Jan
wielemakerplain2005-04-07 21:42:01
File Added - 128932: x
tglplain2015-11-06 22:14:19
The complained-of behavior certainly seems to be a bug, but I do not like Jan's proposed fix much --- it's taking an implementation that was a kluge to start with and making it even more messy.  I suggest the attached instead, which works by not generating arcs corresponding to the forbidden cases to begin with.

Another idea worth considering is to remove REG_BOSONLY altogether ... does anyone know if Expect still uses it?
serhiy.storchakawiki2026-10-11 08:46:45

Still the same in 8.6, 9.0 and 9.1.

Proposed fix in branch regexp-bosonly-alternatives: the patch by tgl below. With it, all alternatives are anchored, and the results agree with \A(?:re), also with TCL_REG_NOTBOL. Test reg-30.9.

Expect does not use TCL_REG_BOSONLY any more (it only passes TCL_REG_ADVANCED and TCL_REG_NOCASE); in Tcl itself only testregexp uses it. The flag is kept for other users of tclInt.h.

jan.nijtmanswiki2026-10-13 12:22:17

Merged to [trunk], core-9-0-branch and core-8-6-branch

Log in (anonymous is fine) to add a comment.

Attachments: