From 1ceb4a294741967df7735ebe9e3e2d0606d2af64 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 4 May 2025 03:59:00 +0000 Subject: regex module: scanner function semantics: retern zero upon no-match. --- src/regex/tbnf_regex_scanfns.h | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/regex/tbnf_regex_scanfns.h b/src/regex/tbnf_regex_scanfns.h index c57a606..ee9ee89 100644 --- a/src/regex/tbnf_regex_scanfns.h +++ b/src/regex/tbnf_regex_scanfns.h @@ -15,7 +15,7 @@ static inline int tbnf_regex_scan_brace_rbrace(const struct tbnf_scan_ctx * sctx if (sctx->tok_scan_mark[0] == '}') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_brace_digit(const struct tbnf_scan_ctx * sctx) @@ -24,7 +24,7 @@ static inline int tbnf_regex_scan_brace_digit(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] <= '9') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_brace_comma(const struct tbnf_scan_ctx * sctx) @@ -32,7 +32,7 @@ static inline int tbnf_regex_scan_brace_comma(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == ',') return 1; - return -1; + return 0; } @@ -44,7 +44,7 @@ static inline int tbnf_regex_scan_bracket_escaped_char(const struct tbnf_scan_ct if (sctx->tok_scan_mark[1]) return 2; - return -1; + return 0; } static inline int tbnf_regex_scan_bracket_character_class(const struct tbnf_scan_ctx * sctx) @@ -52,14 +52,14 @@ static inline int tbnf_regex_scan_bracket_character_class(const struct tbnf_scan const char * ch = 0; if (&sctx->tok_scan_mark[4] >= sctx->tok_scan_cap) - return -1; + return 0; if (sctx->tok_scan_mark[0] == '[') if (sctx->tok_scan_mark[1] == ':') ch = &sctx->tok_scan_mark[2]; if (!ch) - return -1; + return 0; for (; (*ch >= 'a') && (*ch <= 'z') && (&ch[2] < sctx->tok_scan_cap); ) ch++; @@ -67,13 +67,13 @@ static inline int tbnf_regex_scan_bracket_character_class(const struct tbnf_scan if ((*ch++ == ':') && (*ch++ == ']')) return (ch - sctx->tok_scan_mark); - return -1; + return 0; } static inline int tbnf_regex_scan_bracket_collation_symbol(const struct tbnf_scan_ctx * sctx) { if (&sctx->tok_scan_mark[4] >= sctx->tok_scan_cap) - return -1; + return 0; if (sctx->tok_scan_mark[0] == '[') if (sctx->tok_scan_mark[1] == '.') @@ -82,7 +82,7 @@ static inline int tbnf_regex_scan_bracket_collation_symbol(const struct tbnf_sca if (sctx->tok_scan_mark[2]) return 5; - return -1; + return 0; } static inline int tbnf_regex_scan_bracket_equivalence_class(const struct tbnf_scan_ctx * sctx) @@ -90,14 +90,14 @@ static inline int tbnf_regex_scan_bracket_equivalence_class(const struct tbnf_sc const char * ch = 0; if (&sctx->tok_scan_mark[4] >= sctx->tok_scan_cap) - return -1; + return 0; if (sctx->tok_scan_mark[0] == '[') if (sctx->tok_scan_mark[1] == '=') ch = &sctx->tok_scan_mark[2]; if (!ch) - return -1; + return 0; for (; (*ch >= 'a') && (*ch <= 'z') && (&ch[2] < sctx->tok_scan_cap); ) ch++; @@ -105,7 +105,7 @@ static inline int tbnf_regex_scan_bracket_equivalence_class(const struct tbnf_sc if ((*ch++ == '=') && (*ch++ == ']')) return (ch - sctx->tok_scan_mark); - return -1; + return 0; } static inline int tbnf_regex_scan_bracket_rbracket(const struct tbnf_scan_ctx * sctx) @@ -113,7 +113,7 @@ static inline int tbnf_regex_scan_bracket_rbracket(const struct tbnf_scan_ctx * if (sctx->tok_scan_mark[0] == ']') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_bracket_hyphen(const struct tbnf_scan_ctx * sctx) @@ -121,7 +121,7 @@ static inline int tbnf_regex_scan_bracket_hyphen(const struct tbnf_scan_ctx * sc if (sctx->tok_scan_mark[0] == '-') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_bracket_error(const struct tbnf_scan_ctx * sctx) @@ -129,7 +129,7 @@ static inline int tbnf_regex_scan_bracket_error(const struct tbnf_scan_ctx * sct if (sctx->tok_scan_mark[0] == '[') return 1; - return -1; + return 0; } @@ -143,7 +143,7 @@ static inline int tbnf_regex_scan_lbracket_circumflex_rbracket(const struct tbnf if (sctx->tok_scan_mark[2] == ']') return 3; - return -1; + return 0; } static inline int tbnf_regex_scan_lbracket_circumflex(const struct tbnf_scan_ctx * sctx) @@ -153,7 +153,7 @@ static inline int tbnf_regex_scan_lbracket_circumflex(const struct tbnf_scan_ctx if (sctx->tok_scan_mark[1] == '^') return 2; - return -1; + return 0; } static inline int tbnf_regex_scan_lbracket_rbracket(const struct tbnf_scan_ctx * sctx) @@ -163,7 +163,7 @@ static inline int tbnf_regex_scan_lbracket_rbracket(const struct tbnf_scan_ctx * if (sctx->tok_scan_mark[1] == ']') return 2; - return -1; + return 0; } static inline int tbnf_regex_scan_lbracket(const struct tbnf_scan_ctx * sctx) @@ -171,7 +171,7 @@ static inline int tbnf_regex_scan_lbracket(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '[') return 1; - return -1; + return 0; } @@ -183,7 +183,7 @@ static inline int tbnf_regex_scan_escaped_char(const struct tbnf_scan_ctx * sctx if (sctx->tok_scan_mark[1]) return 2; - return -1; + return 0; } static inline int tbnf_regex_scan_circumflex_asterisk(const struct tbnf_scan_ctx * sctx) @@ -193,7 +193,7 @@ static inline int tbnf_regex_scan_circumflex_asterisk(const struct tbnf_scan_ctx if (sctx->tok_scan_mark[1] == '*') return 2; - return -1; + return 0; } static inline int tbnf_regex_scan_circumflex(const struct tbnf_scan_ctx * sctx) @@ -201,7 +201,7 @@ static inline int tbnf_regex_scan_circumflex(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '^') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_lbrace(const struct tbnf_scan_ctx * sctx) @@ -209,7 +209,7 @@ static inline int tbnf_regex_scan_lbrace(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '{') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_lparen(const struct tbnf_scan_ctx * sctx) @@ -217,7 +217,7 @@ static inline int tbnf_regex_scan_lparen(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '(') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_rparen(const struct tbnf_scan_ctx * sctx) @@ -225,7 +225,7 @@ static inline int tbnf_regex_scan_rparen(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == ')') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_asterisk(const struct tbnf_scan_ctx * sctx) @@ -233,7 +233,7 @@ static inline int tbnf_regex_scan_asterisk(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '*') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_period(const struct tbnf_scan_ctx * sctx) @@ -241,7 +241,7 @@ static inline int tbnf_regex_scan_period(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '.') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_dollar(const struct tbnf_scan_ctx * sctx) @@ -249,7 +249,7 @@ static inline int tbnf_regex_scan_dollar(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '$') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_vline(const struct tbnf_scan_ctx * sctx) @@ -257,7 +257,7 @@ static inline int tbnf_regex_scan_vline(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '|') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_qmark(const struct tbnf_scan_ctx * sctx) @@ -265,7 +265,7 @@ static inline int tbnf_regex_scan_qmark(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '?') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_plus(const struct tbnf_scan_ctx * sctx) @@ -273,7 +273,7 @@ static inline int tbnf_regex_scan_plus(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0] == '+') return 1; - return -1; + return 0; } static inline int tbnf_regex_scan_char(const struct tbnf_scan_ctx * sctx) @@ -281,7 +281,7 @@ static inline int tbnf_regex_scan_char(const struct tbnf_scan_ctx * sctx) if (sctx->tok_scan_mark[0]) return 1; - return -1; + return 0; } #endif -- cgit v1.2.3