-
Notifications
You must be signed in to change notification settings - Fork 8.3k
libc: fnmatch: Add to A.5 rule and common #98827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +1,12 @@ | ||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
|
||
| /* $NetBSD: fnmatch.h,v 1.12.50.1 2011/02/08 16:18:55 bouyer Exp $ */ | ||
|
|
||
| /*- | ||
| * Copyright (c) 1992, 1993 | ||
| * The Regents of the University of California. All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * 3. Neither the name of the University nor the names of its contributors | ||
| * may be used to endorse or promote products derived from this software | ||
| * without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| * SUCH DAMAGE. | ||
| /* | ||
| * Copyright (c) 2025 The Zephyr Project Contributors | ||
| * | ||
| * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #ifndef _FNMATCH_H_ | ||
| #define _FNMATCH_H_ | ||
|
|
||
| #define FNM_NOMATCH 1 /* Match failed. */ | ||
| #define FNM_NOSYS 2 /* Function not implemented. */ | ||
| #define FNM_NORES 3 /* Out of resources */ | ||
|
|
||
| #define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ | ||
| #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ | ||
| #define FNM_PERIOD 0x04 /* Period must be matched by period. */ | ||
| #define FNM_CASEFOLD 0x08 /* Pattern is matched case-insensitive */ | ||
| #define FNM_LEADING_DIR 0x10 /* Ignore /<tail> after Imatch. */ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| int fnmatch(const char *, const char *, int); | ||
| #ifndef ZEPHYR_INCLUDE_POSIX_FNMATCH_H_ | ||
| #define ZEPHYR_INCLUDE_POSIX_FNMATCH_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #include_next <fnmatch.h> | ||
|
|
||
| #endif /* !_FNMATCH_H_ */ | ||
| #endif /* ZEPHYR_INCLUDE_POSIX_FNMATCH_H_ */ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -90,6 +90,7 @@ config MINIMAL_LIBC | |||||
| imply COMPILER_FREESTANDING | ||||||
| select COMMON_LIBC_ABORT | ||||||
| select COMMON_LIBC_STRNLEN | ||||||
| select COMMON_LIBC_FNMATCH | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| imply COMMON_LIBC_MALLOC | ||||||
| imply COMMON_LIBC_CALLOC | ||||||
| imply COMMON_LIBC_REALLOCARRAY | ||||||
|
|
@@ -119,6 +120,7 @@ config NEWLIB_LIBC | |||||
| depends on NEWLIB_LIBC_SUPPORTED | ||||||
| select NEED_LIBC_MEM_PARTITION | ||||||
| select TC_PROVIDES_POSIX_C_LANG_SUPPORT_R | ||||||
| select COMMON_LIBC_FNMATCH | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newlib should provide this function.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| imply POSIX_DEVICE_IO_ALIAS_CLOSE | ||||||
| imply POSIX_DEVICE_IO_ALIAS_OPEN | ||||||
| imply POSIX_DEVICE_IO_ALIAS_READ | ||||||
|
|
@@ -137,6 +139,7 @@ config ARCMWDT_LIBC | |||||
| depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "arcmwdt" | ||||||
| select STATIC_INIT_GNU | ||||||
| select LIBC_ALLOW_LESS_THAN_64BIT_TIME | ||||||
| select COMMON_LIBC_FNMATCH | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| help | ||||||
| C library provided by ARC MWDT toolchain. | ||||||
|
|
||||||
|
|
@@ -151,6 +154,7 @@ config IAR_LIBC | |||||
| depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "iar" | ||||||
| select COMMON_LIBC_STRNLEN | ||||||
| select COMMON_LIBC_TIME | ||||||
| select COMMON_LIBC_FNMATCH | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| help | ||||||
| Use the full IAR Compiler runtime libraries. | ||||||
| A reduced Zephyr minimal libc will be used for library functionality | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo the changes to this file. |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For C libraries that provide If there are problems doing so, then those issues should be solved in advance. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,6 +104,11 @@ config COMMON_LIBC_STRNLEN | |
| help | ||
| common implementation of strnlen(). | ||
|
|
||
| config COMMON_LIBC_FNMATCH | ||
| bool | ||
| help | ||
| common implementation of fnmatch(). | ||
|
|
||
|
Comment on lines
+107
to
+111
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove |
||
| config COMMON_LIBC_THRD | ||
| bool "C11 <threads.h> API support" | ||
| depends on DYNAMIC_THREAD | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this file back to its original location. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
Check warning on line 1 in lib/libc/common/source/fnmatch/fnmatch.c
|
||
|
|
||
| /* $NetBSD: fnmatch.c,v 1.26 2014/10/12 22:32:33 christos Exp $ */ | ||
|
|
||
|
|
@@ -39,11 +39,13 @@ | |
| * Compares a filename or pathname to a pattern. | ||
| */ | ||
|
|
||
| #define _GNU_SOURCE | ||
|
Check failure on line 42 in lib/libc/common/source/fnmatch/fnmatch.c
|
||
|
|
||
| #include <ctype.h> | ||
| #include <stdbool.h> | ||
| #include <string.h> | ||
|
|
||
| #include <zephyr/posix/fnmatch.h> | ||
| #include <fnmatch.h> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should really only be done after #97855 is merged (although, I guess it is part of that PR already). |
||
| #include <zephyr/toolchain.h> | ||
|
|
||
| #define EOS '\0' | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this header back to its original location. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
Check warning on line 1 in lib/libc/common/source/fnmatch/include/fnmatch.h
|
||
|
|
||
| /* $NetBSD: fnmatch.h,v 1.12.50.1 2011/02/08 16:18:55 bouyer Exp $ */ | ||
|
|
||
| /*- | ||
| * Copyright (c) 1992, 1993 | ||
| * The Regents of the University of California. All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * 3. Neither the name of the University nor the names of its contributors | ||
| * may be used to endorse or promote products derived from this software | ||
| * without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| * SUCH DAMAGE. | ||
| * | ||
| * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 | ||
| */ | ||
|
|
||
| #ifndef _ZEPHYR_LIB_LIBC_COMMON_SOURCE_FNMATCH_INCLUDE_FNMATCH_H_ | ||
| #define _ZEPHYR_LIB_LIBC_COMMON_SOURCE_FNMATCH_INCLUDE_FNMATCH_H_ | ||
|
|
||
| #define FNM_NOMATCH 1 /* Match failed. */ | ||
| #define FNM_NOSYS 2 /* Function not implemented. */ | ||
| #define FNM_NORES 3 /* Out of resources */ | ||
|
|
||
| #define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ | ||
| #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ | ||
| #define FNM_PERIOD 0x04 /* Period must be matched by period. */ | ||
|
|
||
| #if defined(_GNU_SOURCE) | ||
| #define FNM_CASEFOLD 0x08 /* Pattern is matched case-insensitive */ | ||
| #define FNM_LEADING_DIR 0x10 /* Ignore /<tail> after Imatch. */ | ||
| #endif /* _GNU_SOURCE */ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| int fnmatch(const char *, const char *, int); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* !_ZEPHYR_LIB_LIBC_COMMON_SOURCE_FNMATCH_INCLUDE_FNMATCH_H_ */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please undo the changes to this file |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo the changes to this file |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #define _GNU_SOURCE /* for FNM_LEADING_DIR in fnmatch.h */ | ||
|
Check failure on line 8 in subsys/net/lib/http/http_server_core.c
|
||
| #include <fnmatch.h> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should really only be done after #97855 is merged (although, I guess it is part of that PR already). |
||
| #include <errno.h> | ||
| #include <stdbool.h> | ||
| #include <stdio.h> | ||
|
|
@@ -21,7 +23,6 @@ | |
| #include <zephyr/net/socket.h> | ||
| #include <zephyr/net/tls_credentials.h> | ||
| #include <zephyr/posix/sys/eventfd.h> | ||
| #include <zephyr/posix/fnmatch.h> | ||
| #include <zephyr/sys/util_macro.h> | ||
|
|
||
| LOG_MODULE_REGISTER(net_http_server, CONFIG_NET_HTTP_SERVER_LOG_LEVEL); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo the changes to this file |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,8 @@ | |
| */ | ||
|
|
||
| #include <string.h> | ||
| #include <zephyr/posix/fnmatch.h> | ||
| #include <fnmatch.h> | ||
|
|
||
|
Comment on lines
+8
to
+9
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should really only be done after #97855 is merged (although, I guess it is part of that PR already). |
||
| #include "shell_wildcard.h" | ||
| #include "shell_utils.h" | ||
| #include "shell_ops.h" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| #include <stdint.h> | ||
| #include <errno.h> | ||
| #include <string.h> | ||
| #include <zephyr/posix/fnmatch.h> | ||
| #include <fnmatch.h> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should really only be done after #97855 is merged (although, I guess it is part of that PR already). |
||
| #include "coverage.h" | ||
| #include <zephyr/arch/common/semihost.h> | ||
| #include <sys/types.h> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,8 +30,20 @@ | |
| zassert_equal(fnmatch("a*.c", "a/x.c", FNM_PATHNAME), FNM_NOMATCH); | ||
| zassert_ok(fnmatch("*/foo", "/foo", FNM_PATHNAME)); | ||
| zassert_ok(fnmatch("-O[01]", "-O1", 0)); | ||
| zassert_ok(fnmatch("[[?*\\]", "\\", 0)); | ||
| zassert_ok(fnmatch("[]?*\\]", "]", 0)); | ||
| if (!IS_ENABLED(CONFIG_COMMON_LIBC_FNMATCH)) { | ||
| /* \\ escapes ], no bracket expr, no match */ | ||
| zassert_equal(fnmatch("[[?*\\]", "\\", 0), FNM_NOMATCH); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html In the assertion below, zassert_ok(fnmatch("[[?*\\]", "\\", 0));If Picolibc's implementation does not work here, it has at least one bug.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compiler will convert
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't looked at musl's implementation of I think I misinterpreted the pattern, and I can understand why the original author of the test data probably also misinterpreted the pattern due to the wording of the spec. zassert_ok(fnmatch("[[?*\\]", "\\", 0));So I think I can agree with that now, but it required a retake. The alternative below provided in this PR seems to be more correct zassert_ok(fnmatch("[[?*\\\\]", "\\", 0));Ignoring the other options in the bracket expression,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, having both the compiler and the function parsing the same escape sequences is confusing at best. As to changing the test case, they're both "legitimate" test cases; the original one uncovers a bug in the Musl implementation which is not present in the newlib, picolibc or glibc implementations, so we should keep it. Adding your modified version is probably also reasonable (more tests == more better?). |
||
| /* \\ escapes ], no bracket expr, no match */ | ||
| zassert_equal(fnmatch("[]?*\\]", "]", 0), FNM_NOMATCH); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is a little trickier. Just mid-release, so give me some time to revisit.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, these are just more versions of the above test -- because the |
||
| } | ||
| /* \\ unescaped, match */ | ||
| zassert_ok(fnmatch("[[?*\\]", "\\", FNM_NOESCAPE)); | ||
| /* \\ escapes \\, match */ | ||
| zassert_ok(fnmatch("[[?*\\\\]", "\\", 0)); | ||
| /* \\ unescaped, match */ | ||
| zassert_ok(fnmatch("[]?*\\]", "]", FNM_NOESCAPE)); | ||
| /* \\ escapes \\, match */ | ||
| zassert_ok(fnmatch("[]?*\\\\]", "]", 0)); | ||
|
Comment on lines
+39
to
+46
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little hesitant to add these, and it isn't clear to me at the moment if they add to coverage.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They test the four cases where musl and glibc differ because musl doesn't allow for an escaped
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This first one makes sense to me The third one (below) is a bit tricky, because
So while it might be tempting to interpret /* \\ unescaped, match */
zassert_ok(fnmatch("[]?*\\]", "]", FNM_NOESCAPE));The last case is similar at the beginning, and of course allows escapes, so the /* \\ escapes \\, match */
zassert_ok(fnmatch("[]?*\\\\]", "]", 0));So the third and fourth cases make sense to me too. I would probably also say that another pattern to include in addition to the fourth case where there are 0 flags, would be below /* \\ escapes \\, match */
zassert_ok(fnmatch("[\\]?*\\\\]", "]", 0));Which just explicitly escapes the first
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Tricky, but well defined --
Additional annotations for the test cases is probably a good idea. Note that we want to poke the implementation in corner cases, so while I would probably write |
||
| zassert_ok(fnmatch("[!]a-]", "b", 0)); | ||
| zassert_ok(fnmatch("[]-_]", "^", 0)); | ||
| zassert_ok(fnmatch("[!]-_]", "X", 0)); | ||
|
|
@@ -73,9 +85,14 @@ | |
| zassert_equal(fnmatch("*/*", "a/.b", FNM_PATHNAME | FNM_PERIOD), FNM_NOMATCH); | ||
| zassert_ok(fnmatch("*?*/*", "a/.b", FNM_PERIOD)); | ||
| zassert_ok(fnmatch("*[.]/b", "a./b", FNM_PATHNAME | FNM_PERIOD)); | ||
| /* zassert_ok(fnmatch("*[[:alpha:]]/""*[[:alnum:]]", "a/b", FNM_PATHNAME)); */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not remove this line. It's there intentionally. We should wait for #97400 to be merged. I've been working with the first-time contributor for over a month to ensure the PR is ready, and I think it would be great to help them to push it past the finish line.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. This one relies on the library supporting the character class elements of the pattern. Newlib, picolibc 1.8.10 and Zephyr all lack support for these, so we will need to make fixed versions available before this test will pass though. |
||
| zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/b", FNM_PATHNAME), 0); | ||
| zassert_not_equal(fnmatch("*[![:digit:]]*/[[:d-d]", "a/[", FNM_PATHNAME), 0); | ||
|
|
||
| /* Disable tests that fail when using Zephyr's fnmatch implementation */ | ||
| if (!IS_ENABLED(CONFIG_POSIX_C_LIB_EXT)) { | ||
| zassert_ok(fnmatch("*[[:alpha:]]/""*[[:alnum:]]", "a/b", FNM_PATHNAME)); | ||
|
Check warning on line 91 in tests/posix/c_lib_ext/src/fnmatch.c
|
||
| zassert_ok(fnmatch("*[![:digit:]]*/[![:d-d]", "a/b", FNM_PATHNAME)); | ||
| zassert_ok(fnmatch("*[![:digit:]]*/[[:d-d]", "a/[", FNM_PATHNAME)); | ||
| } | ||
|
|
||
|
Comment on lines
+89
to
+95
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These change should be reverted, and the calls should all fail, according to SUSv3. See XCU 2.13.1, XBD 9.3.5 https://git.musl-libc.org/cgit/libc-testsuite/tree/fnmatch.c#n113 I'm just taking the musl libc tester's word for it though.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first test is pretty clearly correct, although it relies upon having character class support. The other two tests check for patterns containing invalid character class expressions. Here, I can understand the difference between musl and glibc. Glibc (and picolibc) interpret an invalid character class expression as the characters themselves, so https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap09.html#tag_09_03_05 seems unclear on this. It does say that |
||
| zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/[", FNM_PATHNAME), 0); | ||
| zassert_ok(fnmatch("a?b", "a.b", FNM_PATHNAME | FNM_PERIOD)); | ||
| zassert_ok(fnmatch("a*b", "a.b", FNM_PATHNAME | FNM_PERIOD)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please undo the changes to this file