Skip to content

Commit

Permalink
filterx: move regexp_subst to separate file
Browse files Browse the repository at this point in the history
refactor to use func-flags to handle flag args

Signed-off-by: shifter <shifter@axoflow.com>
  • Loading branch information
bshifter committed Dec 3, 2024
1 parent 987a68c commit a90b183
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 357 deletions.
2 changes: 2 additions & 0 deletions lib/filterx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(FILTERX_HEADERS
filterx/expr-plus.h
filterx/expr-regexp-common.h
filterx/expr-regexp-search.h
filterx/expr-regexp-subst.h
filterx/expr-regexp.h
filterx/expr-set-subscript.h
filterx/expr-setattr.h
Expand Down Expand Up @@ -83,6 +84,7 @@ set(FILTERX_SOURCES
filterx/expr-plus.c
filterx/expr-regexp-common.c
filterx/expr-regexp-search.c
filterx/expr-regexp-subst.c
filterx/expr-regexp.c
filterx/expr-set-subscript.c
filterx/expr-setattr.c
Expand Down
2 changes: 2 additions & 0 deletions lib/filterx/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ filterxinclude_HEADERS = \
lib/filterx/expr-plus.h \
lib/filterx/expr-regexp-common.h \
lib/filterx/expr-regexp-search.h \
lib/filterx/expr-regexp-subst.h \
lib/filterx/expr-regexp.h \
lib/filterx/expr-set-subscript.h \
lib/filterx/expr-setattr.h \
Expand Down Expand Up @@ -85,6 +86,7 @@ filterx_sources = \
lib/filterx/expr-plus.c \
lib/filterx/expr-regexp-common.c \
lib/filterx/expr-regexp-search.c \
lib/filterx/expr-regexp-subst.c \
lib/filterx/expr-regexp.c \
lib/filterx/expr-set-subscript.c \
lib/filterx/expr-setattr.c \
Expand Down
18 changes: 18 additions & 0 deletions lib/filterx/expr-regexp-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@ gboolean filterx_regexp_extract_optional_arg_flag(FLAGSET *flags, const gchar **
gboolean filterx_regexp_match(FilterXReMatchState *state, pcre2_code_8 *pattern, gint start_offset);
gboolean filterx_regexp_match_eval(FilterXExpr *lhs_expr, pcre2_code_8 *pattern, FilterXReMatchState *state);

static inline gint
match_start_offset(PCRE2_SIZE *ovector)
{
return ovector[0];
}

static inline gint
match_end_offset(PCRE2_SIZE *ovector)
{
return ovector[1];
}

static inline gboolean
is_zero_length_match(PCRE2_SIZE *ovector)
{
return ovector[0] == ovector[1];
}

#endif
Loading

0 comments on commit a90b183

Please sign in to comment.