mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] fnmatch trailing backslash
@ 2022-02-25 15:44 Tavian Barnes
  0 siblings, 0 replies; only message in thread
From: Tavian Barnes @ 2022-02-25 15:44 UTC (permalink / raw)
  To: musl

I noticed that fnmatch() behaviour with a trailing unescaped backslash
differs between glibc and musl:

$ cat foo.c
#include <assert.h>
#include <fnmatch.h>

int main(void) {
        assert(fnmatch("\\", "\\", 0) != 0);
        return 0;
}
$ gcc foo.c -o foo && ./foo
$ musl-gcc foo.c -o foo && ./foo
Assertion failed: fnmatch("\\", "\\", 0) != 0 (foo.c: main: 5)

In https://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html,
POSIX says:

> If pattern ends with an unescaped <backslash>, fnmatch() shall return a non-zero value (indicating either no match or an error).

And interestingly, it was a defect report from Rich that led to that
wording: https://www.austingroupbugs.net/view.php?id=806

-- 
Tavian Barnes

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-25 15:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 15:44 [musl] fnmatch trailing backslash Tavian Barnes

Code repositories for project(s) associated with this 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).