bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behaviour of strverscmp(3)


From: Simon Josefsson
Subject: Re: Behaviour of strverscmp(3)
Date: Mon, 01 Jan 2024 23:43:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Thanks for report, Dmitry.  I am slowly coming back to this.  I have
noticed that Cygwin (via MSYS2) has the same strverscmp as musl:

https://cygwin.com/cgit/newlib-cygwin/tree/newlib/libc/string/strverscmp.c

Compare against musl strverscmp:

https://git.musl-libc.org/cgit/musl/tree/src/string/strverscmp.c

Since gsasl (and many other projects) gets strverscmp() from gnulib, I'm
cc'ing the bug-gnulib list.  I think gnulib should detect and work
around this buggy strverscmp.  The documentation says the function is
missing on all non-glibc platforms, but this is not the case, see:

https://www.gnu.org/software/gnulib/manual/html_node/strverscmp.html

I don't have time to work on a patch for gnulib now, but this e-mail
will serve as a reminder... but happy if someone else has ideas on how
to resolve it in gnulib.  See reproducer below; I recall seeing other
problems too such as strverscmp("1.7", "1.7") behaving different.

Compare to the glibc/gnulib implementation:

https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/strverscmp.c

/Simon

Dmitry Bogatov <oht-tfnfy#tah.bet#i1@kaction.cc> writes:

> 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.
>
>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]