[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [musl] Behaviour of strverscmp(3)
From: |
Rich Felker |
Subject: |
Re: [musl] Behaviour of strverscmp(3) |
Date: |
Mon, 7 Nov 2022 22:08:25 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Sun, Nov 06, 2022 at 06:39:04PM -0500, Rich Felker wrote:
> On Sun, Nov 06, 2022 at 06:18:22PM -0500, Dmitry Bogatov wrote:
> > Hello.
> >
> > While trying to building gsasl statically with musl library as part of
> > Nixpkgs distribution, I noticed that test built from tests/version.c
> > fails when built with musl library. After a bit of troubleshooting, I
> > can pinpoint the reason -- different behaviour of "strverscmp" from
> > glibc and musl.
> >
> > Example code:
> >
> > #include <string.h>
> > #include <stdio.h>
> >
> > int main()
> > {
> > int value = strverscmp("UNKNOWN", "2.2.0");
> > printf("%d\n", value);
> > return 0;
> > }
> >
> > Under glibc value "35" is printed (positive), under musl value "-1" is
> > printed (negative). Not sure what is the correct solution for the
> > issue, so I cross-post into two lists.
> >
> > For now I plan to patch-out this particular test. Thank you.
>
> It looks like we're neglecting to honor the exception case to "longer
> digit sequence is greater" when one of the sequences is degenerate (no
> digits).
I think the attached patch fixes it in the most non-invasive way
that's most clear in avoiding other unwanted side effects. It
basically says "only apply the longest-digit-sequence" rule if there
is a common nonzero length [[:digit:]]+ match (dp is the position
where digit sequence starts, j is the test position).
I think this code should be reviewed for additional bugs though.
Rich
strverscmp.diff
Description: Text document