# HG changeset patch # User Matti Hamalainen # Date 1580235016 -7200 # Node ID 7493d4c9ff77f508bf6e1736195123bd26096bc6 # Parent 48e8820bc625e1ebbfb902c062bc548d74be35a4 Add some regex flags, features to be implemented "some day". diff -r 48e8820bc625 -r 7493d4c9ff77 th_regex.c --- a/th_regex.c Mon Jan 27 19:23:06 2020 +0200 +++ b/th_regex.c Tue Jan 28 20:10:16 2020 +0200 @@ -1141,6 +1141,7 @@ if (match == NULL) return THERR_MALLOC; + match->type = TH_RE_MATCH_EXPR; match->start = soffs; match->len = coffs - soffs; diff -r 48e8820bc625 -r 7493d4c9ff77 th_regex.h --- a/th_regex.h Mon Jan 27 19:23:06 2020 +0200 +++ b/th_regex.h Tue Jan 28 20:10:16 2020 +0200 @@ -38,17 +38,32 @@ { th_llist_t node; ///< Internal linked list data + int type; ///< Type of this match, TH_RE_MATCH_* + size_t start; ///< Start offset of the match sequence in @p haystack in @c th_char_t units. size_t len; ///< Length of the match sequence in @p haystack in @c th_char_t units. } th_regex_match_t; -// Flags for th_regex_match() -// (not actually used or supported yet :D) +/** @brief + * Flags @c th_regex_match_t @c type field. + */ enum { - TH_REF_CASEFOLD = 0x0001, - TH_REF_ANCHORED = 0x0002, + TH_RE_MATCH_EXPR, + TH_RE_MATCH_SUBEXPR, +}; + + +/** @brief + * Flags for th_regex_match(). NOTE! Not actually implemented or supported yet! + */ +enum +{ + TH_REF_CASEFOLD = 0x0001, ///< Use case-folding + TH_REF_ANCHORED = 0x0002, ///< Implicitly consider expression "anchored" even without explicit ^$ + TH_REF_NEWLINE = 0x0004, ///< IF SET: Anchors will refer to line start/newline instead of string start/end + TH_REF_SUBMATCH = 0x0008, ///< Include sub-expression matches in results };