Skip to content

Commit 70de2da

Browse files
committed
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 <[email protected]>
1 parent c31dfc1 commit 70de2da

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
@@ -191,6 +191,7 @@ fn test_apple(target: &str) {
191191
"errno.h",
192192
"execinfo.h",
193193
"fcntl.h",
194+
"fnmatch.h",
194195
"getopt.h",
195196
"glob.h",
196197
"grp.h",
@@ -454,6 +455,7 @@ fn test_openbsd(target: &str) {
454455
"errno.h",
455456
"execinfo.h",
456457
"fcntl.h",
458+
"fnmatch.h",
457459
"getopt.h",
458460
"libgen.h",
459461
"limits.h",
@@ -731,6 +733,7 @@ fn test_redox(target: &str) {
731733
"dlfcn.h",
732734
"errno.h",
733735
"fcntl.h",
736+
"fnmatch.h",
734737
"grp.h",
735738
"limits.h",
736739
"locale.h",
@@ -790,6 +793,7 @@ fn test_solarish(target: &str) {
790793
"errno.h",
791794
"execinfo.h",
792795
"fcntl.h",
796+
"fnmatch.h",
793797
"getopt.h",
794798
"glob.h",
795799
"grp.h",
@@ -1030,6 +1034,7 @@ fn test_netbsd(target: &str) {
10301034
"elf.h",
10311035
"errno.h",
10321036
"fcntl.h",
1037+
"fnmatch.h",
10331038
"getopt.h",
10341039
"libgen.h",
10351040
"limits.h",
@@ -1244,6 +1249,7 @@ fn test_dragonflybsd(target: &str) {
12441249
"errno.h",
12451250
"execinfo.h",
12461251
"fcntl.h",
1252+
"fnmatch.h",
12471253
"getopt.h",
12481254
"glob.h",
12491255
"grp.h",
@@ -1464,6 +1470,7 @@ fn test_wasi(target: &str) {
14641470
"dirent.h",
14651471
"errno.h",
14661472
"fcntl.h",
1473+
"fnmatch.h",
14671474
"langinfo.h",
14681475
"limits.h",
14691476
"locale.h",
@@ -1579,6 +1586,7 @@ fn test_android(target: &str) {
15791586
"elf.h",
15801587
"errno.h",
15811588
"fcntl.h",
1589+
"fnmatch.h",
15821590
"getopt.h",
15831591
"grp.h",
15841592
"ifaddrs.h",
@@ -2087,6 +2095,7 @@ fn test_freebsd(target: &str) {
20872095
"errno.h",
20882096
"execinfo.h",
20892097
"fcntl.h",
2098+
"fnmatch.h",
20902099
"getopt.h",
20912100
"glob.h",
20922101
"grp.h",
@@ -2706,6 +2715,7 @@ fn test_emscripten(target: &str) {
27062715
"dlfcn.h",
27072716
"errno.h",
27082717
"fcntl.h",
2718+
"fnmatch.h",
27092719
"glob.h",
27102720
"grp.h",
27112721
"ifaddrs.h",
@@ -2974,6 +2984,7 @@ fn test_neutrino(target: &str) {
29742984
"dlfcn.h",
29752985
"sys/elf.h",
29762986
"fcntl.h",
2987+
"fnmatch.h",
29772988
"glob.h",
29782989
"grp.h",
29792990
"iconv.h",
@@ -3368,6 +3379,7 @@ fn test_linux(target: &str) {
33683379
"dlfcn.h",
33693380
"elf.h",
33703381
"fcntl.h",
3382+
"fnmatch.h",
33713383
"getopt.h",
33723384
"glob.h",
33733385
[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
@@ -526,6 +531,7 @@ fgetpos
526531
fgets
527532
fileno
528533
flock
534+
fnmatch
529535
fopen
530536
fork
531537
fpathconf

src/unix/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,24 @@ pub const ATF_PERM: ::c_int = 0x04;
320320
pub const ATF_PUBL: ::c_int = 0x08;
321321
pub const ATF_USETRAILERS: ::c_int = 0x10;
322322

323+
pub const FNM_PERIOD: c_int = 1 << 2;
324+
pub const FNM_CASEFOLD: c_int = 1 << 4;
325+
pub const FNM_NOMATCH: c_int = 1;
326+
327+
cfg_if! {
328+
if #[cfg(any(
329+
target_os = "macos",
330+
target_os = "freebsd",
331+
target_os = "android",
332+
))] {
333+
pub const FNM_PATHNAME: c_int = 1 << 1;
334+
pub const FNM_NOESCAPE: c_int = 1 << 0;
335+
} else {
336+
pub const FNM_PATHNAME: c_int = 1 << 0;
337+
pub const FNM_NOESCAPE: c_int = 1 << 1;
338+
}
339+
}
340+
323341
extern "C" {
324342
pub static in6addr_loopback: in6_addr;
325343
pub static in6addr_any: in6_addr;
@@ -1573,6 +1591,10 @@ cfg_if! {
15731591
}
15741592
}
15751593

1594+
extern "C" {
1595+
pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int;
1596+
}
1597+
15761598
cfg_if! {
15771599
if #[cfg(target_env = "newlib")] {
15781600
mod newlib;

0 commit comments

Comments
 (0)