const char * const to,
const int string_offset,
int * match_offset) {
+ UNUSED(match_offset);
//return regex_match(pattern, to, string_offset, match_offset);
- return regex_search(token->syntax, to + string_offset);
+ return regex_match(token->syntax, to + string_offset);
}
void render_string(const char * const string,
static int regex_assert(const regex_t * const regex,
const char * const string,
int state,
- int * width) {
+ int width) {
for (const char * s = string; *s != '\00'; s++) {
// delta
const delta_t * const delta = *(delta_t**)vector_get(®ex->delta_table, i);
if ((delta->in == state)
&& (delta->input == *s)) {
- if(regex_assert(regex, s + delta->width, delta->to)){
- return true;
+ int r = regex_assert(regex, s + delta->width, delta->to, width + 1);
+ if(r){
+ return r;
}
}
}
continue;
}
- return (state == regex->accepting_state);
+ return (state == regex->accepting_state) ? width : false;
}
return false;
return true;
}
- int r = 0;
- return regex_assert(regex, string, 0, &r);
+ return regex_assert(regex, string, 0, 0);
}
bool regex_search( regex_t * regex,
const char * const string) {
- return (bool)regex_match(regex, string, 0);
+ return (bool)regex_match(regex, string);
}
} regex_t;
extern regex_t * regex_compile(const char * const pattern);
-extern bool regex_search(regex_t * regex, const char * const string);
extern int regex_free(regex_t * const regex);
+extern bool regex_search(regex_t * regex, const char * const string);
+extern int regex_match(regex_t * regex, const char * const string);
extern bool is_magic(const char c);