diff options
Diffstat (limited to 'sample/scan.c')
-rw-r--r-- | sample/scan.c | 24 |
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; |