summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-14 10:35:13 +0100
committerTyge Løvset <[email protected]>2022-12-14 10:35:13 +0100
commit992812341a98c889297db8df0f8a34f1c59d07bb (patch)
treeadf301c5b1e43fda286b990b3a451cc5cecf5ac1 /examples
parent0db528ed0062920e9bd5b2c7fcdc7506bd41abad (diff)
downloadSTC-modified-992812341a98c889297db8df0f8a34f1c59d07bb.tar.gz
STC-modified-992812341a98c889297db8df0f8a34f1c59d07bb.zip
cregex: renamed enums to all uppercase and prefixed CREG_
Diffstat (limited to 'examples')
-rw-r--r--examples/regex1.c2
-rw-r--r--examples/regex2.c2
-rw-r--r--examples/regex_match.c4
-rw-r--r--examples/regex_replace.c8
-rw-r--r--examples/splitstr.c2
5 files changed, 9 insertions, 9 deletions
diff --git a/examples/regex1.c b/examples/regex1.c
index 47cce4cf..7a22220d 100644
--- a/examples/regex1.c
+++ b/examples/regex1.c
@@ -10,7 +10,7 @@ int main(int argc, char* argv[])
c_auto (cstr, input)
c_auto (cregex, float_expr)
{
- int res = cregex_compile(&float_expr, "^[+-]?[0-9]+((\\.[0-9]*)?|\\.[0-9]+)$", cre_default);
+ int res = cregex_compile(&float_expr, "^[+-]?[0-9]+((\\.[0-9]*)?|\\.[0-9]+)$", CREG_DEFAULT);
// Until "q" is given, ask for another number
if (res > 0) while (true)
{
diff --git a/examples/regex2.c b/examples/regex2.c
index 8c4df420..4f60cfc4 100644
--- a/examples/regex2.c
+++ b/examples/regex2.c
@@ -16,7 +16,7 @@ int main()
c_auto (cregex, re)
c_forrange (i, c_arraylen(s))
{
- int res = cregex_compile(&re, s[i].pattern, cre_default);
+ int res = cregex_compile(&re, s[i].pattern, CREG_DEFAULT);
if (res < 0) {
printf("error in regex pattern: %d\n", res);
continue;
diff --git a/examples/regex_match.c b/examples/regex_match.c
index fd4315ad..376b002e 100644
--- a/examples/regex_match.c
+++ b/examples/regex_match.c
@@ -17,7 +17,7 @@ int main()
c_auto (cstr, nums)
{
const char* pattern = "[+-]?([0-9]*\\.)?\\d+([Ee][+-]?\\d+)?";
- int res = cregex_compile(&re, pattern, cre_default);
+ int res = cregex_compile(&re, pattern, CREG_DEFAULT);
printf("%d: %s\n", res, pattern);
// extract and convert all numbers in str to floats
@@ -28,7 +28,7 @@ int main()
printf(" %g\n", *i.ref);
// extracts the numbers only to a comma separated string.
- nums = cregex_replace_sv(&re, csview_from(str), " $0,", 0, NULL, cre_r_strip);
+ nums = cregex_replace_sv(&re, csview_from(str), " $0,", 0, NULL, CREG_R_STRIP);
printf("\n%s\n", cstr_str(&nums));
}
}
diff --git a/examples/regex_replace.c b/examples/regex_replace.c
index 808ac086..e296dfd8 100644
--- a/examples/regex_replace.c
+++ b/examples/regex_replace.c
@@ -26,15 +26,15 @@ int main()
printf("fixed: %s\n", cstr_str(&str));
/* US date format, and add 10 years to dates: */
- cstr_take(&str, cregex_replace_pattern_n(pattern, input, "$1/$3/$2", 0, add_10_years, cre_default));
+ cstr_take(&str, cregex_replace_pattern_n(pattern, input, "$1/$3/$2", 0, add_10_years, CREG_DEFAULT));
printf("us+10: %s\n", cstr_str(&str));
/* Wrap first date inside []: */
- cstr_take(&str, cregex_replace_pattern_n(pattern, input, "[$0]", 1, NULL, cre_default));
+ cstr_take(&str, cregex_replace_pattern_n(pattern, input, "[$0]", 1, NULL, CREG_DEFAULT));
printf("brack: %s\n", cstr_str(&str));
/* Shows how to compile RE separately */
- c_with (cregex re = cregex_from(pattern, cre_default), cregex_drop(&re)) {
+ c_with (cregex re = cregex_from(pattern, CREG_DEFAULT), cregex_drop(&re)) {
if (cregex_captures(&re) == 0)
continue; /* break c_with */
/* European date format. */
@@ -42,7 +42,7 @@ int main()
printf("euros: %s\n", cstr_str(&str));
/* Strip out everything but the matches */
- cstr_take(&str, cregex_replace_sv(&re, csview_from(input), "$3.$2.$1;", 0, NULL, cre_r_strip));
+ cstr_take(&str, cregex_replace_sv(&re, csview_from(input), "$3.$2.$1;", 0, NULL, CREG_R_STRIP));
printf("strip: %s\n", cstr_str(&str));
}
diff --git a/examples/splitstr.c b/examples/splitstr.c
index a7b386f3..39db1a54 100644
--- a/examples/splitstr.c
+++ b/examples/splitstr.c
@@ -13,7 +13,7 @@ int main()
puts("\nSplit with c_formatch (regex):");
- c_with (cregex re = cregex_from("[^ ]+", cre_default), cregex_drop(&re))
+ c_with (cregex re = cregex_from("[^ ]+", CREG_DEFAULT), cregex_drop(&re))
c_formatch (i, &re, " Hello World C99! ")
printf("'%.*s'\n", c_ARGsv(i.match[0]));
}