aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/posix/regex.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:52 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 18:24:51 -0500
commitf5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch)
tree93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/tests/posix/regex.c
parentbd5969fc876a10b18613302db7087ef3c40f18e1 (diff)
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/tests/posix/regex.c')
-rw-r--r--lib/mlibc/tests/posix/regex.c30
1 files changed, 0 insertions, 30 deletions
diff --git a/lib/mlibc/tests/posix/regex.c b/lib/mlibc/tests/posix/regex.c
deleted file mode 100644
index 6c2ca3f..0000000
--- a/lib/mlibc/tests/posix/regex.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-int main(void) {
- char *testString = "mlibc is the best best best libc";
- char *pattern = "\\(be[a-z]t\\) \\1";
-
- regex_t reg;
- int rc = regcomp(&reg, pattern, 0);
- assert(!rc);
-
- regmatch_t matches[2];
- rc = regexec(&reg, testString, 2, matches, 0);
- assert(!rc);
-
- printf("Whole pattern: \"%.*s\" at %zd-%zd.\n",
- (int)(matches[0].rm_eo - matches[0].rm_so), &testString[matches[0].rm_so],
- (ssize_t)matches[0].rm_so, (ssize_t)(matches[0].rm_eo - 1));
- assert(matches[0].rm_so == 13 && matches[0].rm_eo == 22);
-
- printf("Substring: \"%.*s\" at %zd-%zd.\n",
- (int)(matches[1].rm_eo - matches[1].rm_so), &testString[matches[1].rm_so],
- (ssize_t)matches[1].rm_so, (ssize_t)matches[1].rm_eo - 1);
- assert(matches[1].rm_so == 13 && matches[1].rm_eo == 17);
-
- regfree(&reg);
- return 0;
-}