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)

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

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 public inbox

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