From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: arnold@skeeve.com, eggert@cs.ucla.edu
Subject: Re: possible bug in regex and dfa
Date: Sun, 18 Jul 2021 18:09:23 +0200 [thread overview]
Message-ID: <3323531.JAME3IizvO@omega> (raw)
In-Reply-To: <202107181256.16ICuEjF027369@freefriends.org>
Hi Arnold,
> Dot matching newline isn't the issue here.
>
> It's ^ matching in the middle of a string. For my purposes, ^ should
> only match at the beginning of a *string* (as $ should only match at
> the end of a string). I haven't rechecked POSIX, but this is how awk
> has behaved since forever.
Hmm. Regarding POSIX: I've read section 9.3.8 and 9.4.9 of [1],
the description of REG_NOTBOL, REG_NOTEOL in [2], and the description
of REG_NEWLINE in [3]. If I understand it correctly, within POSIX,
".^" should not match a newline because
- if REG_NEWLINE is set, '^' matches after the newline but '.' does not
match the newline,
- if REG_NEWLINE is not set, '.' matches newline but '^' does not match
after the newline.
However, GNU regex.h also has a flag RE_CONTEXT_INDEP_ANCHORS; I don't know
what effect it has.
> (And how I've documented things in the manual, also since forever.)
If you want the behaviour of the GNU regex to be stable over time, you
should contribute unit tests to tests/test-regex.c. So far, I see unit
tests for the flags
REG_EXTENDED
REG_NOSUB
RE_SYNTAX_POSIX_BASIC
RE_SYNTAX_GREP
RE_SYNTAX_EGREP
RE_SYNTAX_POSIX_EGREP
RE_SYNTAX_EMACS
RE_HAT_LISTS_NOT_NEWLINE
RE_ICASE
RE_CONTEXT_INVALID_DUP
RE_NO_EMPTY_RANGES
but no tests at all for
RE_SYNTAX_AWK
RE_SYNTAX_GNU_AWK
RE_SYNTAX_POSIX_AWK
RE_SYNTAX_POSIX_EXTENDED
REG_NEWLINE
REG_NOTBOL
REG_NOTEOL
REG_STARTEND
Usually it takes about as many code lines to reasonably unit test some code
as the code itself has. The regex module is over 300 KB large, and its unit
test less than 20 KB large. Already from these figures you can tell that
the regex module is *NEARLY UNTESTED*.
You may say, well, some other unit tests exist in glibc, in sed, in grep,
in awk, in coreutils, etc. But it doesn't help maintenance if the unit tests
are not part of what gets tested by
./gnulib-tool --test --single-configure regex
Bruno
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/regex.h.html
[3] https://pubs.opengroup.org/onlinepubs/9699919799/functions/regexec.html
next prev parent reply other threads:[~2021-07-18 16:09 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 [this message]
2021-07-18 18:59 ` arnold
2021-07-18 21:45 ` regex unit tests Bruno Haible
2021-07-18 19:30 ` possible bug in regex and dfa arnold
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=3323531.JAME3IizvO@omega \
--to=bruno@clisp.org \
--cc=arnold@skeeve.com \
--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).