summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2021-04-26 17:34:16 +0200
committerJörg Frings-Fürst <debian@jff.email>2021-04-26 17:34:16 +0200
commiteac65ba44805c402f894b700b602c2e891f92a84 (patch)
tree8c74372bd97a480de440013af1dda4958189e24e /sample
parent7ce72ba4d420fde9672c2fb2dd7a6f5a26815e26 (diff)
parentdbedac4783f09292abb187d0c59d4032594038b6 (diff)
Merge branch 'release/debian/6.9.6-1'debian/6.9.6-1
Diffstat (limited to 'sample')
-rw-r--r--sample/Makefile.am6
-rw-r--r--sample/scan.c24
2 files changed, 22 insertions, 8 deletions
diff --git a/sample/Makefile.am b/sample/Makefile.am
index 2bf4697..c2c4596 100644
--- a/sample/Makefile.am
+++ b/sample/Makefile.am
@@ -8,9 +8,9 @@ AM_LDFLAGS = -L$(prefix)/lib
AM_CPPFLAGS = -I$(top_srcdir)/src
if ENABLE_POSIX_API
-TESTS = encode listcap names posix simple sql syntax user_property callout echo count bug_fix regset
+TESTS = encode listcap names posix simple sql syntax user_property callout echo count bug_fix regset scan
else
-TESTS = encode listcap names simple sql syntax user_property callout echo count bug_fix regset
+TESTS = encode listcap names simple sql syntax user_property callout echo count bug_fix regset scan
endif
check_PROGRAMS = $(TESTS)
@@ -28,6 +28,7 @@ echo_SOURCES = echo.c
count_SOURCES = count.c
bug_fix = bug_fix.c
regset_SOURCES = regset.c
+scan_SOURCES = scan.c
sampledir = .
@@ -47,3 +48,4 @@ endif
$(sampledir)/count
$(sampledir)/bug_fix
$(sampledir)/regset
+ $(sampledir)/scan
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;