summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-07-21 16:33:39 +0200
committerTyge Løvset <[email protected]>2022-07-21 16:35:11 +0200
commitf1bc406edb6faef3420de7f77a6f1246065861d9 (patch)
tree2ae4340cbd61bab19044964b66bc4111f4f04edc /include
parent782fa268940611df14bce7823b4aaf6fca671b49 (diff)
downloadSTC-modified-f1bc406edb6faef3420de7f77a6f1246065861d9.tar.gz
STC-modified-f1bc406edb6faef3420de7f77a6f1246065861d9.zip
cregex API change: Added cregex_match_ex() and cregex_match() with string pattern input instead of a cregex*, similar to cregex_replace*().
Diffstat (limited to 'include')
-rw-r--r--include/stc/cregex.h58
1 files changed, 32 insertions, 26 deletions
diff --git a/include/stc/cregex.h b/include/stc/cregex.h
index 2b972fc8..4e82c60a 100644
--- a/include/stc/cregex.h
+++ b/include/stc/cregex.h
@@ -34,33 +34,33 @@ THE SOFTWARE.
#include "forward.h" // csview
typedef enum {
- creg_success = 1,
- creg_nomatch = 0,
- creg_matcherror = -1,
- creg_outofmemory = -2,
- creg_unmatchedleftparenthesis = -3,
- creg_unmatchedrightparenthesis = -4,
- creg_toomanysubexpressions = -5,
- creg_toomanycharacterclasses = -6,
- creg_malformedcharacterclass = -7,
- creg_missingoperand = -8,
- creg_unknownoperator = -9,
- creg_operandstackoverflow = -10,
- creg_operatorstackoverflow = -11,
- creg_operatorstackunderflow = -12,
+ cre_success = 1,
+ cre_nomatch = 0,
+ cre_matcherror = -1,
+ cre_outofmemory = -2,
+ cre_unmatchedleftparenthesis = -3,
+ cre_unmatchedrightparenthesis = -4,
+ cre_toomanysubexpressions = -5,
+ cre_toomanycharacterclasses = -6,
+ cre_malformedcharacterclass = -7,
+ cre_missingoperand = -8,
+ cre_unknownoperator = -9,
+ cre_operandstackoverflow = -10,
+ cre_operatorstackoverflow = -11,
+ cre_operatorstackunderflow = -12,
} cregex_error_t;
enum {
- /* compile flags */
- cregex_DOTALL = 1<<0,
- cregex_CASELESS = 1<<1,
- /* execution flags */
- cregex_FULLMATCH = 1<<2,
- cregex_NEXT = 1<<3,
- cregex_STARTEND = 1<<4,
+ /* compile-flags */
+ cre_DOTALL = 1<<0,
+ cre_CASELESS = 1<<1,
+ /* match-flags */
+ cre_FULLMATCH = 1<<2,
+ cre_NEXT = 1<<3,
+ cre_STARTEND = 1<<4,
/* limits */
- cregex_MAXCLASSES = 16,
- cregex_MAXCAPTURES = 32,
+ cre_MAXCLASSES = 16,
+ cre_MAXCAPTURES = 32,
};
typedef struct {
@@ -80,11 +80,17 @@ int cregex_compile(cregex *self, const char* pattern, int cflags);
int cregex_captures(const cregex* self);
/* return 1 on match, 0 on nomatch, and -1 on failure. */
-int cregex_match(const cregex *self, const char* string,
- unsigned nmatch, csview match[], int mflags);
+int cregex_match_re(const char* input, const cregex* re,
+ unsigned nmatch, csview match[], int mflags);
+
+int cregex_match_ex(const char* input, const char* pattern, int cflags,
+ unsigned nmatch, csview match[], int mflags);
+static inline
+int cregex_match(const char* input, const char* pattern, unsigned nmatch, csview match[])
+ { return cregex_match_ex(input, pattern, 0, nmatch, match, 0); }
/* replace regular expression */
-cstr cregex_replace_re(const char* input, const cregex* re, const char* repl,
+cstr cregex_replace_re(const char* input, const cregex* re, const char* replace,
cstr (*mfun)(int i, csview match), int cflags, unsigned count);
cstr cregex_replace_ex(const char* input, const char* pattern, const char* replace,