REG_BOSONLY incorrect with |
Closed / Fixed1178541fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 51 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:
- x [download] added by wielemaker on 2005-04-07 21:42:01. [details]