summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/fnmatch/fnm_test.c
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
committercvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
commiteb8dd9dca1228af0cd132f515509051ecfabf6f6 (patch)
treeedb6da6af7e865d488dc1a29309f1e1ec226e603 /src/regress/lib/libc/fnmatch/fnm_test.c
parent247f0352e0ed72a4f476db9dc91f4d982bc83eb2 (diff)
downloadopenbsd-tb_20250414.tar.gz
openbsd-tb_20250414.tar.bz2
openbsd-tb_20250414.zip
This commit was manufactured by cvs2git to create tag 'tb_20250414'.tb_20250414
Diffstat (limited to 'src/regress/lib/libc/fnmatch/fnm_test.c')
-rw-r--r--src/regress/lib/libc/fnmatch/fnm_test.c62
1 files changed, 0 insertions, 62 deletions
diff --git a/src/regress/lib/libc/fnmatch/fnm_test.c b/src/regress/lib/libc/fnmatch/fnm_test.c
deleted file mode 100644
index ee04f6335e..0000000000
--- a/src/regress/lib/libc/fnmatch/fnm_test.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/* $OpenBSD: fnm_test.c,v 1.3 2019/01/25 00:19:26 millert Exp $ */
2
3/*
4 * Public domain, 2008, Todd C. Miller <millert@openbsd.org>
5 */
6
7#include <err.h>
8#include <fnmatch.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <util.h>
12
13int
14main(int argc, char **argv)
15{
16 FILE *fp = stdin;
17 char pattern[1024], string[1024];
18 char *line;
19 const char delim[3] = {'\0', '\0', '#'};
20 int errors = 0, flags, got, want;
21
22 if (argc > 1) {
23 if ((fp = fopen(argv[1], "r")) == NULL)
24 err(1, "%s", argv[1]);
25 }
26
27 /*
28 * Read in test file, which is formatted thusly:
29 *
30 * pattern string flags expected_result
31 *
32 * lines starting with '#' are comments
33 */
34 for (;;) {
35 line = fparseln(fp, NULL, NULL, delim, 0);
36 if (!line)
37 break;
38 got = sscanf(line, "%s %s 0x%x %d", pattern, string, &flags,
39 &want);
40 if (got == EOF) {
41 free(line);
42 break;
43 }
44 if (pattern[0] == '#') {
45 free(line);
46 continue;
47 }
48 if (got == 4) {
49 got = fnmatch(pattern, string, flags);
50 if (got != want) {
51 warnx("%s %s %d: want %d, got %d", pattern,
52 string, flags, want, got);
53 errors++;
54 }
55 } else {
56 warnx("unrecognized line '%s'\n", line);
57 errors++;
58 }
59 free(line);
60 }
61 exit(errors);
62}