From: arnold@skeeve.com
To: bug-gnulib@gnu.org, bruno@clisp.org
Cc: eggert@cs.ucla.edu, arnold@skeeve.com
Subject: Re: possible bug in regex and dfa
Date: Sun, 18 Jul 2021 13:30:57 -0600 [thread overview]
Message-ID: <202107181930.16IJUvI3011225@freefriends.org> (raw)
In-Reply-To: <3323531.JAME3IizvO@omega>
Hi.
Bruno Haible <bruno@clisp.org> wrote:
> - if REG_NEWLINE is not set, '.' matches newline but '^' does not match
> after the newline.
This is indeed the desired behavior, but regex isn't following it.
REG_NEWLINE being set gets translated into preg->newline_anchor.
Starting at line 620, regexec.c relates to it:
| /* If initial states with non-begbuf contexts have no elements,
| the regex must be anchored. If preg->newline_anchor is set,
| we'll never use init_state_nl, so do not check it. */
| if (dfa->init_state->nodes.nelem == 0
| && dfa->init_state_word->nodes.nelem == 0
| && (dfa->init_state_nl->nodes.nelem == 0
| || !preg->newline_anchor))
| {
| if (start != 0 && last_start != 0)
| return REG_NOMATCH;
| start = last_start = 0;
| }
(As a side note, I don't think the comment matches the code.)
In my case, preg->newline_anchor is zero (correctly), but
dfa->init_state->nodes.nelem is not, so this body isn't executed.
Making the test for preg->newline_anchor the first thing causes my test
case to work correctly but breaks the gawk test suite.
In other words, I think the bug is somewhere in this area, but I
don't understand the regex internals enough to fix it. dfa will also
need looking at.
Thanks,
Arnold
prev parent reply other threads:[~2021-07-18 19:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-15 18:48 possible bug in regex and dfa Arnold Robbins
2021-07-17 2:58 ` Paul Eggert
2021-07-18 9:01 ` Bruno Haible
2021-07-18 12:56 ` arnold
2021-07-18 16:09 ` Bruno Haible
2021-07-18 18:59 ` arnold
2021-07-18 21:45 ` regex unit tests Bruno Haible
2021-07-18 19:30 ` arnold [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202107181930.16IJUvI3011225@freefriends.org \
--to=arnold@skeeve.com \
--cc=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=eggert@cs.ucla.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).