summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/Makefile.am1
-rw-r--r--sample/encode.c3
-rw-r--r--sample/listcap.c18
-rw-r--r--sample/names.c3
-rw-r--r--sample/regset.c3
-rw-r--r--sample/simple.c3
-rw-r--r--sample/sql.c3
-rw-r--r--sample/syntax.c3
-rw-r--r--sample/user_property.c3
9 files changed, 28 insertions, 12 deletions
diff --git a/sample/Makefile.am b/sample/Makefile.am
index 22a4989..2bf4697 100644
--- a/sample/Makefile.am
+++ b/sample/Makefile.am
@@ -3,6 +3,7 @@
lib_onig = ../src/libonig.la
LDADD = $(lib_onig)
+AM_CFLAGS = -Wall
AM_LDFLAGS = -L$(prefix)/lib
AM_CPPFLAGS = -I$(top_srcdir)/src
diff --git a/sample/encode.c b/sample/encode.c
index c5d4771..9e9a0c7 100644
--- a/sample/encode.c
+++ b/sample/encode.c
@@ -161,6 +161,9 @@ extern int main(int argc, char* argv[])
r = exec(ONIG_ENCODING_GB18030, ONIG_OPTION_IGNORECASE,
"(Aa\\d)+", "BaA5Aa0234");
+ r = exec(ONIG_ENCODING_GB18030, ONIG_OPTION_NONE,
+ "[[^\\w]]+[^\xee\xef]\xee\xef", "[[^\\w]]+[^\xee\xef]\xee\xef");
+
r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
"\000[\000\337\000]\000\000", "\000S\000S\000\000");
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;
diff --git a/sample/names.c b/sample/names.c
index 9b1eb24..bf47f63 100644
--- a/sample/names.c
+++ b/sample/names.c
@@ -31,11 +31,12 @@ extern int main(int argc, char* argv[])
regex_t* reg;
OnigErrorInfo einfo;
OnigRegion *region;
+ OnigEncoding use_encs[1];
static UChar* pattern = (UChar* )"(?<foo>a*)(?<bar>b*)(?<foo>c*)";
static UChar* str = (UChar* )"aaabbbbcc";
- OnigEncoding use_encs[] = { ONIG_ENCODING_ASCII };
+ use_encs[0] = ONIG_ENCODING_ASCII;
onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
diff --git a/sample/regset.c b/sample/regset.c
index ca3a10c..6be511a 100644
--- a/sample/regset.c
+++ b/sample/regset.c
@@ -16,6 +16,7 @@ extern int main(int argc, char* argv[])
regex_t* reg;
OnigErrorInfo einfo;
char ebuf[ONIG_MAX_ERROR_MESSAGE_LEN];
+ OnigEncoding use_encs[1];
static UChar* str = (UChar* )"aaaaaaaaaaaaaaaaaaaaaaca";
@@ -25,7 +26,7 @@ extern int main(int argc, char* argv[])
"a(.....)c"
};
- OnigEncoding use_encs[] = { ONIG_ENCODING_UTF8 };
+ use_encs[0] = ONIG_ENCODING_UTF8;
onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
r = onig_regset_new(&set, 0, NULL);
diff --git a/sample/simple.c b/sample/simple.c
index 5a14042..a08ea86 100644
--- a/sample/simple.c
+++ b/sample/simple.c
@@ -12,11 +12,12 @@ extern int main(int argc, char* argv[])
regex_t* reg;
OnigErrorInfo einfo;
OnigRegion *region;
+ OnigEncoding use_encs[1];
static UChar* pattern = (UChar* )"a(.*)b|[e-f]+";
static UChar* str = (UChar* )"zzzzaffffffffb";
- OnigEncoding use_encs[] = { ONIG_ENCODING_ASCII };
+ use_encs[0] = ONIG_ENCODING_ASCII;
onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
diff --git a/sample/sql.c b/sample/sql.c
index 1602ac9..21147aa 100644
--- a/sample/sql.c
+++ b/sample/sql.c
@@ -14,11 +14,12 @@ extern int main(int argc, char* argv[])
regex_t* reg;
OnigErrorInfo einfo;
OnigRegion *region;
+ OnigEncoding use_encs[1];
static UChar* pattern = (UChar* )"\\_%\\\\__zz";
static UChar* str = (UChar* )"a_abcabcabc\\ppzz";
- OnigEncoding use_encs[] = { ONIG_ENCODING_ASCII };
+ use_encs[0] = ONIG_ENCODING_ASCII;
onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
onig_set_syntax_op (&SQLSyntax, ONIG_SYN_OP_VARIABLE_META_CHARACTERS);
diff --git a/sample/syntax.c b/sample/syntax.c
index e034608..3a5a7cf 100644
--- a/sample/syntax.c
+++ b/sample/syntax.c
@@ -58,8 +58,9 @@ extern int exec(OnigSyntaxType* syntax, char* apattern, char* astr)
extern int main(int argc, char* argv[])
{
int r;
+ OnigEncoding use_encs[1];
- OnigEncoding use_encs[] = { ONIG_ENCODING_ASCII };
+ use_encs[0] = ONIG_ENCODING_ASCII;
onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
r = exec(ONIG_SYNTAX_PERL,
diff --git a/sample/user_property.c b/sample/user_property.c
index d52adc0..ecb842c 100644
--- a/sample/user_property.c
+++ b/sample/user_property.c
@@ -13,6 +13,7 @@ main(int argc, char* argv[])
regex_t* reg;
OnigErrorInfo einfo;
OnigRegion *region;
+ OnigEncoding use_encs[1];
static OnigCodePoint handakuon_hiragana[] = {
5, /* number of ranges */
@@ -29,7 +30,7 @@ main(int argc, char* argv[])
/* "PA PI PU PE PO a" */
static UChar* str = (UChar* )"\343\201\261\343\201\264\343\201\267\343\201\272\343\201\275a";
- OnigEncoding use_encs[] = { ONIG_ENCODING_UTF8 };
+ use_encs[0] = ONIG_ENCODING_UTF8;
onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
r = onig_unicode_define_user_property("HandakuonHiragana", handakuon_hiragana);