Skip to content

Commit 1b22329

Browse files
epilystgross35
authored andcommitted
Add fnmatch.h
Add fnmatch() function and FNM_* constants. Documentation: Header file: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/fnmatch.h.html fnmatch() function: https://pubs.opengroup.org/onlinepubs/9799919799/functions/fnmatch.html Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is> (backport <#3937>) (cherry picked from commit 70de2da)
1 parent 31f746a commit 1b22329

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

libc-test/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ fn test_apple(target: &str) {
205205
"errno.h",
206206
"execinfo.h",
207207
"fcntl.h",
208+
"fnmatch.h",
208209
"getopt.h",
209210
"glob.h",
210211
"grp.h",
@@ -482,6 +483,7 @@ fn test_openbsd(target: &str) {
482483
"errno.h",
483484
"execinfo.h",
484485
"fcntl.h",
486+
"fnmatch.h",
485487
"getopt.h",
486488
"libgen.h",
487489
"limits.h",
@@ -793,6 +795,7 @@ fn test_redox(target: &str) {
793795
"dlfcn.h",
794796
"errno.h",
795797
"fcntl.h",
798+
"fnmatch.h",
796799
"grp.h",
797800
"limits.h",
798801
"locale.h",
@@ -852,6 +855,7 @@ fn test_solarish(target: &str) {
852855
"errno.h",
853856
"execinfo.h",
854857
"fcntl.h",
858+
"fnmatch.h",
855859
"getopt.h",
856860
"glob.h",
857861
"grp.h",
@@ -1092,6 +1096,7 @@ fn test_netbsd(target: &str) {
10921096
"elf.h",
10931097
"errno.h",
10941098
"fcntl.h",
1099+
"fnmatch.h",
10951100
"getopt.h",
10961101
"libgen.h",
10971102
"limits.h",
@@ -1308,6 +1313,7 @@ fn test_dragonflybsd(target: &str) {
13081313
"errno.h",
13091314
"execinfo.h",
13101315
"fcntl.h",
1316+
"fnmatch.h",
13111317
"getopt.h",
13121318
"glob.h",
13131319
"grp.h",
@@ -1531,6 +1537,7 @@ fn test_wasi(target: &str) {
15311537
"dirent.h",
15321538
"errno.h",
15331539
"fcntl.h",
1540+
"fnmatch.h",
15341541
"langinfo.h",
15351542
"limits.h",
15361543
"locale.h",
@@ -1646,6 +1653,7 @@ fn test_android(target: &str) {
16461653
"elf.h",
16471654
"errno.h",
16481655
"fcntl.h",
1656+
"fnmatch.h",
16491657
"getopt.h",
16501658
"grp.h",
16511659
"ifaddrs.h",
@@ -2145,6 +2153,7 @@ fn test_freebsd(target: &str) {
21452153
"errno.h",
21462154
"execinfo.h",
21472155
"fcntl.h",
2156+
"fnmatch.h",
21482157
"getopt.h",
21492158
"glob.h",
21502159
"grp.h",
@@ -2762,6 +2771,7 @@ fn test_emscripten(target: &str) {
27622771
"dlfcn.h",
27632772
"errno.h",
27642773
"fcntl.h",
2774+
"fnmatch.h",
27652775
"glob.h",
27662776
"grp.h",
27672777
"ifaddrs.h",
@@ -3030,6 +3040,7 @@ fn test_neutrino(target: &str) {
30303040
"dlfcn.h",
30313041
"sys/elf.h",
30323042
"fcntl.h",
3043+
"fnmatch.h",
30333044
"glob.h",
30343045
"grp.h",
30353046
"iconv.h",
@@ -3427,6 +3438,7 @@ fn test_linux(target: &str) {
34273438
"dlfcn.h",
34283439
"elf.h",
34293440
"fcntl.h",
3441+
"fnmatch.h",
34303442
"getopt.h",
34313443
"glob.h",
34323444
[gnu]: "gnu/libc-version.h",

libc-test/semver/unix.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ FD_ZERO
132132
FILE
133133
FIOCLEX
134134
FIONBIO
135+
FNM_CASEFOLD
136+
FNM_NOESCAPE
137+
FNM_NOMATCH
138+
FNM_PATHNAME
139+
FNM_PERIOD
135140
F_DUPFD
136141
F_DUPFD_CLOEXEC
137142
F_GETFD
@@ -525,6 +530,7 @@ fgetpos
525530
fgets
526531
fileno
527532
flock
533+
fnmatch
528534
fopen
529535
fork
530536
fpathconf

src/unix/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,24 @@ pub const ATF_PERM: ::c_int = 0x04;
313313
pub const ATF_PUBL: ::c_int = 0x08;
314314
pub const ATF_USETRAILERS: ::c_int = 0x10;
315315

316+
pub const FNM_PERIOD: c_int = 1 << 2;
317+
pub const FNM_CASEFOLD: c_int = 1 << 4;
318+
pub const FNM_NOMATCH: c_int = 1;
319+
320+
cfg_if! {
321+
if #[cfg(any(
322+
target_os = "macos",
323+
target_os = "freebsd",
324+
target_os = "android",
325+
))] {
326+
pub const FNM_PATHNAME: c_int = 1 << 1;
327+
pub const FNM_NOESCAPE: c_int = 1 << 0;
328+
} else {
329+
pub const FNM_PATHNAME: c_int = 1 << 0;
330+
pub const FNM_NOESCAPE: c_int = 1 << 1;
331+
}
332+
}
333+
316334
extern "C" {
317335
pub static in6addr_loopback: in6_addr;
318336
pub static in6addr_any: in6_addr;
@@ -1580,6 +1598,10 @@ cfg_if! {
15801598
}
15811599
}
15821600

1601+
extern "C" {
1602+
pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int;
1603+
}
1604+
15831605
cfg_if! {
15841606
if #[cfg(target_env = "newlib")] {
15851607
mod newlib;

0 commit comments

Comments
 (0)