mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Valery Ushakov <uwe@stderr.spb.ru>
Cc: musl@lists.openwall.com, Nigel Kukard <nkukard@LBSD.net>
Subject: Re: [musl] Re: Different results with regex.h between Musl and Libc
Date: Mon, 10 Jun 2024 11:56:14 -0400	[thread overview]
Message-ID: <20240610155613.GL10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <ZmbnuJHi28VxkWHb@snips.stderr.spb.ru>

On Mon, Jun 10, 2024 at 02:47:04PM +0300, Valery Ushakov wrote:
> On Mon, Jun 10, 2024 at 05:38:36 +0000, Nigel Kukard wrote:
> 
> > Musl output (Alpine 3.20), musl-1.2.5-r1...
> > 
> > The input '37' matches the pattern '^([0-9]*)?\.?([0-9]*)?$'
> > Match 0: 37
> > Match 1:
> > Match 2: 37
> > 
> > Glibc output (ArchLinux), glibc 2.39+r52+gf8e4623421-1...
> > 
> > The input '37' matches the pattern '^([0-9]*)?\.?([0-9]*)?$'
> > Match 0: 37
> > Match 1: 37
> > Match 2:
> 
> I'm not sure what POSIX requires here.  The closest I can find after
> skimming through "9. Regular Expressions" is 9.4.6 that ends with:
> 
>   An ERE matching a single character repeated by an '*', '?', or an
>   interval expression shall not match a null expression unless this is
>   the only match for the repetition or it is necessary to satisfy the
>   exact or minimum number of occurrences for the interval expression.
> 
>     https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_06
> 
> I'm not sure what to read into the absense of the usual "or an ERE
> enclosed in parentheses" chorus here.

This looks like a bug. The general requirement (from memory; I don't
have the spec in front of me now) is that each subexpression, in order
from the beginning of the regex, matches the maximal-length input it
can, subject to the overall constraint that the entire regex match the
earliest (first priority) and maximal length (second priority) input
it can.

I guess we need to dig into why this is happening, ensure it's
actually incorrect, and figure out how to fix it...

Rich

  reply	other threads:[~2024-06-10 15:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10  5:38 [musl] " Nigel Kukard
2024-06-10 11:47 ` [musl] " Valery Ushakov
2024-06-10 15:56   ` Rich Felker [this message]
2024-06-10 17:57     ` Valery Ushakov

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240610155613.GL10433@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=nkukard@LBSD.net \
    --cc=uwe@stderr.spb.ru \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).