aboutsummaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c38
1 files changed, 0 insertions, 38 deletions
diff --git a/regex.c b/regex.c
deleted file mode 100644
index 8d46a31..0000000
--- a/regex.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "regex.h"
-#include <stdio.h>
-#include <string.h>
-
-char* clstocs(CleanString* cs) {
- char* s = calloc(CleanStringLength(cs) + 1, 1);
- uint8_t i;
- for (i = 0; i < CleanStringLength(cs); i++)
- s[i] = CleanStringCharacters(cs)[i];
- s[i] = 0;
- return s;
-}
-
-pcre2_code* cleanregex_pcre2_compile(CleanString* cs, int64_t flags) {
- uint8_t* s = (uint8_t*) clstocs(cs);
- int error; PCRE2_SIZE offset;
- pcre2_code* code = pcre2_compile(s, PCRE2_ZERO_TERMINATED, flags,
- &error, &offset, NULL);
- if (code)
- return code;
- else
- return NULL;
-}
-
-int64_t cleanregex_match(pcre2_code* re, CleanString* sub) {
- pcre2_match_data *data = pcre2_match_data_create_from_pattern(re, NULL);
- uint8_t* csub = (uint8_t*) clstocs(sub);
- unsigned long len = CleanStringLength(sub);
- int match = pcre2_match(re, csub, len, 0, 0, data, NULL);
- if (match < 0) {
- pcre2_match_data_free(data);
- return match;
- }
- PCRE2_SIZE* ovector = pcre2_get_ovector_pointer(data);
- pcre2_match_data_free(data);
- return ovector[0];
-}
-