Page MenuHomeFreeBSD

fnmatch: Add support for collating symbols, equivalence classes, and character classes
ClosedPublic

Authored by bnovkov on Apr 3 2025, 3:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 2, 10:01 AM
Unknown Object (File)
Wed, Oct 1, 1:06 AM
Unknown Object (File)
Sat, Sep 27, 12:21 AM
Unknown Object (File)
Fri, Sep 26, 11:14 PM
Unknown Object (File)
Fri, Sep 26, 7:31 PM
Unknown Object (File)
Thu, Sep 25, 7:47 PM
Unknown Object (File)
Thu, Sep 18, 8:25 PM
Unknown Object (File)
Aug 31 2025, 3:26 PM
Subscribers

Details

Summary

This change extends fnmatch to support collating symbol expressions,
equivalence class expressions, and character class expressions (as
defined by POSIX.1, section 9.3.5), along with the corresponding
tests.

Sponsored by: Klara, Inc.
Obtained from: https://github.com/apple-oss-distributions/Libc

Test Plan

The new changes pass the existing tests in lib/libc/tests/gen/fnmatch_test.c and contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Presumably this should get a RELNOTES entry?

lib/libc/gen/fnmatch.3
137

Is the first sentence ("The current implementation...") unrelated to the second? Commit 613e383e81062 seems to suggest that they're related.

lib/libc/gen/fnmatch.c
307

&& should be on the previous line.

bnovkov marked an inline comment as done and an inline comment as not done.Apr 7 2025, 4:06 PM

Presumably this should get a RELNOTES entry?

Sure, I'll add it in a separate commit.

lib/libc/gen/fnmatch.3
137

Hm, I initially wanted to avoid making the claim that this change makes us fully POSIX conformant since I wasn't sure if there are other features we're missing.
However, looking at the 1003.2 regex chapter, it appears that we tick all of the boxes listed in section 9.3.5. now.
I'm still on the fence about removing the nonconformance statement, what do you think?

lib/libc/gen/fnmatch.3
137

Sometimes we use "is expected to confirm to".

lib/libc/gen/fnmatch.3
137

Stating that we're non-conformant without explaining how we're non-conformant is somewhat unhelpful. I like the hedge of "is expected to conform to".

Clarify POSIX conformance in manpage.

lib/libc/gen/fnmatch.3
137

Sometimes we use "is expected to confirm to".

Oh, that fits perfectly, thank you!

markj added inline comments.
lib/libc/tests/gen/fnmatch_test.c
199

It'd be nice to have some tests for error cases: invalid classes, malformed ranges, and so on.

This revision is now accepted and ready to land.Apr 8 2025, 2:14 PM
ziaee added a reviewer: manpages.