diff options
| author | Tyge Løvset <[email protected]> | 2022-02-06 00:07:24 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-02-06 00:07:24 +0100 |
| commit | d68d26d55881cac66be4ab357c08add8c348f083 (patch) | |
| tree | 6792632ded6d4fc73df75f49096fdcac029c49d7 /examples | |
| parent | 29409b257d9144010bd608afc19f66ee2fbaa337 (diff) | |
| download | STC-modified-d68d26d55881cac66be4ab357c08add8c348f083.tar.gz STC-modified-d68d26d55881cac66be4ab357c08add8c348f083.zip | |
Some build warnings/fixes.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/regex2.c | 8 | ||||
| -rw-r--r-- | examples/regex_match.c | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/examples/regex2.c b/examples/regex2.c index 45de9aba..96ac7ed4 100644 --- a/examples/regex2.c +++ b/examples/regex2.c @@ -5,7 +5,7 @@ int main() { const char* inputs[] = {"date: 2024-02-29 leapyear day", "https://en.cppreference.com/w/cpp/regex/regex_search", "!123abcabc!"}; - const char* patterns[] = {"(\\d\\d\\d\\d)-(1[0-2]|0[1-9])-(3[01]|[12][0-9]|0[1-9])", + const char* patterns[] = {"(\\d\\d\\d\\d)[-_](1[0-2]|0[1-9])[-_](3[01]|[12][0-9]|0[1-9])", "(https?://|ftp://|www\\.)([0-9A-Za-z@:%_+~#=-]+\\.)+([a-z][a-z][a-z]?)(/[/0-9A-Za-z\\.@:%_+~#=\\?&-]*)?", "!((abc|123)+)!", }; @@ -13,7 +13,11 @@ int main() { c_auto (cregex, re) { - re = cregex_new(patterns[i], 0); + int res = cregex_compile(&re, patterns[i], 0); + if (res < 0) { + printf("error in regex pattern: %d\n", res); + continue; + } cregmatch m[20]; printf("input: %s\n", inputs[i]); if (cregex_find(&re, inputs[i], 20, m, 0) > 0) diff --git a/examples/regex_match.c b/examples/regex_match.c index be3c0682..c5798b60 100644 --- a/examples/regex_match.c +++ b/examples/regex_match.c @@ -26,7 +26,7 @@ int main() } while (cregex_find(&re, s, 1, m, creg_next) > 0) { - printf("%.*s ; ", m[0].len, m[0].str); + printf("%.*s ; ", (int)m[0].len, m[0].str); } puts(""); } |
