summaryrefslogtreecommitdiff
path: root/sample/scan.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2020-11-08 10:58:36 +0100
committerJörg Frings-Fürst <debian@jff.email>2020-11-08 10:58:36 +0100
commitb4158caf13bc715096c1df7c040c9d25995d76f2 (patch)
treea07d7d0764a8488f4b5ebef1561e2f3d8caacc05 /sample/scan.c
parent0f259c3073f341c48468e80e93731daa31698030 (diff)
parentfc9ba4264eafbb5a6ec0f3cc4cd2e1964c9b8fcf (diff)
Update upstream source from tag 'upstream/6.9.6'
Update to upstream version '6.9.6' with Debian dir 111ba939e0875272a460014bdcf030d413ce8f3f
Diffstat (limited to 'sample/scan.c')
-rw-r--r--sample/scan.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/sample/scan.c b/sample/scan.c
index 4039e46..fe1bac1 100644
--- a/sample/scan.c
+++ b/sample/scan.c
@@ -21,14 +21,14 @@ scan_callback(int n, int r, OnigRegion* region, void* arg)
}
static int
-scan(regex_t* reg, unsigned char* str, unsigned char* end)
+scan(regex_t* reg, OnigOptionType options, unsigned char* str, unsigned char* end)
{
int r;
OnigRegion *region;
region = onig_region_new();
- r = onig_scan(reg, str, end, region, ONIG_OPTION_NONE, scan_callback, NULL);
+ r = onig_scan(reg, str, end, region, options, scan_callback, NULL);
if (r >= 0) {
fprintf(stdout, "total: %d match\n", r);
}
@@ -45,7 +45,7 @@ scan(regex_t* reg, unsigned char* str, unsigned char* end)
}
static int
-exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
+exec(OnigEncoding enc, OnigOptionType options, OnigOptionType runtime_options, char* apattern, char* astr)
{
int r;
unsigned char *end;
@@ -69,7 +69,7 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
}
end = str + onigenc_str_bytelen_null(enc, str);
- r = scan(reg, str, end);
+ r = scan(reg, runtime_options, str, end);
onig_free(reg);
onig_end();
@@ -79,11 +79,23 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
extern int main(int argc, char* argv[])
{
- exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE,
+ exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE, ONIG_OPTION_NONE,
"\\Ga+\\s*", "a aa aaa baaa");
+ fprintf(stdout, "\n");
+
+ exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE, ONIG_OPTION_NOT_BEGIN_POSITION,
+ "\\Ga+\\s*", "a aa aaa baaa");
+ fprintf(stdout, "\n");
+ exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE, ONIG_OPTION_NONE,
+ "(?!\\G)a+\\s*", "a aa aaa baaa");
fprintf(stdout, "\n");
- exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE,
+
+ exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE, ONIG_OPTION_NOT_BEGIN_POSITION,
+ "(?!\\G)a+\\s*", "a aa aaa baaa");
+ fprintf(stdout, "\n");
+
+ exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE, ONIG_OPTION_NONE,
"a+\\s*", "a aa aaa baaa");
return 0;