Mercurial > hg > th-libs
changeset 669:7493d4c9ff77
Add some regex flags, features to be implemented "some day".
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 28 Jan 2020 20:10:16 +0200 |
parents | 48e8820bc625 |
children | b383f4e6ab89 |
files | th_regex.c th_regex.h |
diffstat | 2 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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 };