From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20425 invoked from network); 9 Jan 2023 08:09:36 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 9 Jan 2023 08:09:36 -0000 Received: (qmail 31905 invoked by uid 550); 9 Jan 2023 08:09:33 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 31868 invoked from network); 9 Jan 2023 08:09:33 -0000 Date: Mon, 9 Jan 2023 03:09:20 -0500 From: Rich Felker To: "(GalaxyMaster)" Cc: musl@lists.openwall.com Message-ID: <20230109080920.GC4163@brightrain.aerifal.cx> References: <0100018591a0bfbc-4edc55e0-b5eb-42ef-9d8e-12d9f0d09afd-000000@email.amazonses.com> <20230109073213.GB4163@brightrain.aerifal.cx> <0100018595893ac1-a4a3abcd-d50b-4907-a6bb-6a58d923e6b6-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0100018595893ac1-a4a3abcd-d50b-4907-a6bb-6a58d923e6b6-000000@email.amazonses.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] 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@apollo:~/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