return ((s - range) + 1);
}
-static bool catch_(const regex_t * const regex,
- int * const state) {
-
- for (size_t i = 0; i < regex->catch_table.element_count; i++){
- const offshoot_t * const offshoot = *(offshoot_t**)vector_get(®ex->catch_table, i);
- if (offshoot->in == *state) {
- *state = offshoot->to;
- return true;
- }
- }
- return false;
-}
-
#define HALT_AND_CATCH_FIRE -1
void HOOK_ALL(int from,
vector_push(&cs->regex->delta_table,
&delta);
}
- if (cs->do_catch || cs->is_negative) {
+ if (*cs->do_catch || *cs->is_negative) {
offshoot_t * offshoot = malloc(sizeof(offshoot_t));
offshoot->in = *cs->state + from;
offshoot->to = hook_to;
assert(!is_quantifier(*pattern) && "Pattern starts with quantifier.");
whitelist[0] = '\00';
do_catch = false;
+ is_negative = false;
width = 1;
switch (*s) {
// -----------------
// ### Searching ###
// -----------------
-static bool regex_assert(const regex_t * const regex,
+static bool catch_(const regex_t * const regex,
+ int * const state) {
+
+ for (size_t i = 0; i < regex->catch_table.element_count; i++){
+ const offshoot_t * const offshoot = *(offshoot_t**)vector_get(®ex->catch_table, i);
+ if (offshoot->in == *state) {
+ *state = offshoot->to;
+ return true;
+ }
+ }
+ return false;
+}
+
+static int regex_assert(const regex_t * const regex,
const char * const string,
- int state) {
+ int state,
+ int * width) {
for (const char * s = string; *s != '\00'; s++) {
// delta
continue;
}
- return false;
+ return (state == regex->accepting_state);
}
- return (state == regex->accepting_state);
+ return false;
}
-bool regex_search( regex_t * regex,
- const char * const string) {
+int regex_match( regex_t * regex,
+ const char * const string) {
if (regex == NULL) {
return false;
return true;
}
- return regex_assert(regex, string, 0);
+ int r = 0;
+ return regex_assert(regex, string, 0, &r);
}
+
+bool regex_search( regex_t * regex,
+ const char * const string) {
+
+ return (bool)regex_match(regex, string, 0);
+}
+