Date: Mon, 9 Jan 2023 03:09:20 -0500 From: Rich Felker <dalias@...c.org> To: "(GalaxyMaster)" <galaxy@...nwall.com.au> Cc: musl@...ts.openwall.com Subject: Re: is fnmatch() a bit broken? On Mon, Jan 09, 2023 at 07:57:56AM +0000, (GalaxyMaster) wrote: > Rich, > > On Mon, Jan 09, 2023 at 02:32:13AM -0500, Rich Felker wrote: > > > galaxy@...llo:~/musl-fnmatch $ ./musl-fnmatch > > > fnmatch("abc", "abc", 0) = 0 (expected: 0) > > > fnmatch("[1\]] [1\]]", "1 ]", 0) = 1 (expected: 0) > > > > This difference is intentional because glibc's behavior is contrary to > > the spec. > > Thanks for the explanation, today I learnt something :). However, you said: > > > A '\' can escape the '[' and make it non-special (not > > open a bracket) but the '-' inside the bracket is not "special" to > > begin with -- it's just part of the bracket syntax. Likewise with the > > closing ']' case. > > Which brings a question on the "[1\]] [1\]]" use case not matching "1 ]". If I > read your response correctly, it is expected to actually match on musl, did I > get it wrong? It's been a while since I looked at these, but the key thing is that ] is not a special character. Only *, ?, and [ are special. ] is just part of the bracket syntax once the bracket is open, and IIRC \] is identical to ], closing the bracket. The subsequent ] is then outside the bracket and matches itself (mismatch here). Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.