summaryrefslogtreecommitdiff
path: root/sample/listcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'sample/listcap.c')
-rw-r--r--sample/listcap.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sample/listcap.c b/sample/listcap.c
index a73f7d4..c0d3014 100644
--- a/sample/listcap.c
+++ b/sample/listcap.c
@@ -24,7 +24,7 @@ node_callback(int group, int beg, int end, int level, int at, void* arg)
}
extern int ex(unsigned char* str, unsigned char* pattern,
- OnigSyntaxType* syntax)
+ OnigSyntaxType* syntax, OnigOptionType options)
{
int r;
unsigned char *start, *range, *end;
@@ -33,7 +33,7 @@ extern int ex(unsigned char* str, unsigned char* pattern,
OnigRegion *region;
r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
- ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo);
+ options, ONIG_ENCODING_ASCII, syntax, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r, &einfo);
@@ -84,6 +84,7 @@ extern int main(int argc, char* argv[])
{
int r;
OnigSyntaxType syn;
+ OnigEncoding use_encs[1];
static UChar* str1 = (UChar* )"((())())";
static UChar* pattern1
@@ -95,7 +96,11 @@ extern int main(int argc, char* argv[])
static UChar* str3 = (UChar* )"0123";
static UChar* pattern3 = (UChar* )"(?@.)(?@.)(?@.)(?@.)";
- OnigEncoding use_encs[] = { ONIG_ENCODING_ASCII };
+ static UChar* str4 = (UChar* )"(((a))(a)) ((((a))(a)))";
+ static UChar* pattern4
+ = (UChar* )"\\g<p>(?@<p>\\(\\g<s>\\)){0}(?@<s>(?:\\g<p>)*|a){0}";
+
+ use_encs[0] = ONIG_ENCODING_ASCII;
onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
/* enable capture hostory */
@@ -103,9 +108,10 @@ extern int main(int argc, char* argv[])
onig_set_syntax_op2(&syn,
onig_get_syntax_op2(&syn) | ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY);
- r = ex(str1, pattern1, &syn);
- r = ex(str2, pattern2, &syn);
- r = ex(str3, pattern3, &syn);
+ r = ex(str1, pattern1, &syn, ONIG_OPTION_NONE);
+ r = ex(str2, pattern2, &syn, ONIG_OPTION_NONE);
+ r = ex(str3, pattern3, &syn, ONIG_OPTION_NONE);
+ r = ex(str4, pattern4, &syn, ONIG_OPTION_FIND_LONGEST);
onig_end();
return r;