diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2019-07-12 09:18:14 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2019-07-12 09:18:14 +0200 |
commit | e25c754918ae26e8b9e68a47bc1af36248e91800 (patch) | |
tree | d21952fcb2767620c25d4d5b412b8c4829ca96bc /sample | |
parent | 70de057dbb5ea79536834e156f534279347f96f3 (diff) |
New upstream version 6.9.2upstream/6.9.2
Diffstat (limited to 'sample')
-rw-r--r-- | sample/Makefile.am | 2 | ||||
-rw-r--r-- | sample/bug_fix.c | 4 | ||||
-rw-r--r-- | sample/crnl.c | 6 | ||||
-rw-r--r-- | sample/encode.c | 82 | ||||
-rw-r--r-- | sample/listcap.c | 2 | ||||
-rw-r--r-- | sample/names.c | 6 | ||||
-rw-r--r-- | sample/posix.c | 8 | ||||
-rw-r--r-- | sample/simple.c | 2 | ||||
-rw-r--r-- | sample/sql.c | 10 | ||||
-rw-r--r-- | sample/syntax.c | 12 | ||||
-rw-r--r-- | sample/user_property.c | 5 |
11 files changed, 70 insertions, 69 deletions
diff --git a/sample/Makefile.am b/sample/Makefile.am index fd809fa..320afcf 100644 --- a/sample/Makefile.am +++ b/sample/Makefile.am @@ -4,7 +4,7 @@ lib_onig = ../src/libonig.la LDADD = $(lib_onig) AM_LDFLAGS = -L$(prefix)/lib -AM_CPPFLAGS = -I$(top_srcdir)/src -I$(includedir) +AM_CPPFLAGS = -I$(top_srcdir)/src TESTS = encode listcap names posix simple sql syntax user_property callout echo count bug_fix diff --git a/sample/bug_fix.c b/sample/bug_fix.c index 44802ef..81c2784 100644 --- a/sample/bug_fix.c +++ b/sample/bug_fix.c @@ -95,8 +95,8 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr) onig_initialize(&enc, 1); r = onig_new(®, pattern, - pattern + onigenc_str_bytelen_null(enc, pattern), - options, enc, ONIG_SYNTAX_DEFAULT, &einfo); + pattern + onigenc_str_bytelen_null(enc, pattern), + options, enc, ONIG_SYNTAX_DEFAULT, &einfo); if (r != ONIG_NORMAL) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r, &einfo); diff --git a/sample/crnl.c b/sample/crnl.c index ee6a516..3ad1210 100644 --- a/sample/crnl.c +++ b/sample/crnl.c @@ -12,7 +12,7 @@ static int nfail = 0; static void result(int no, int from, int to, - int expected_from, int expected_to) + int expected_from, int expected_to) { fprintf(stderr, "%3d: ", no); if (from == expected_from && to == expected_to) { @@ -20,7 +20,7 @@ static void result(int no, int from, int to, } else { fprintf(stderr, "Fail: expected: (%d-%d), result: (%d-%d)\n", - expected_from, expected_to, from, to); + expected_from, expected_to, from, to); nfail++; } @@ -41,7 +41,7 @@ x(int no, char* pattern_arg, char* str_arg, str = (UChar* )str_arg; r = onig_new(®, pattern, pattern + strlen((char* )pattern), - ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); + ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); if (r != ONIG_NORMAL) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str(s, r, &einfo); diff --git a/sample/encode.c b/sample/encode.c index 4eead6e..8a03ab8 100644 --- a/sample/encode.c +++ b/sample/encode.c @@ -129,55 +129,55 @@ extern int main(int argc, char* argv[]) static unsigned char pattern[] = { 0xe7, 0xf6, 0xde, '\\', 'w', '+', 0x00 }; r = exec(ONIG_ENCODING_SJIS, ONIG_OPTION_NONE, - "^a\\p{Hiragana}c$", "a\202\274c"); + "^a\\p{Hiragana}c$", "a\202\274c"); r = exec(ONIG_ENCODING_EUC_JP, ONIG_OPTION_NONE, - "^a\\p{Hiragana}c$", "a\244\276c"); + "^a\\p{Hiragana}c$", "a\244\276c"); r = exec(ONIG_ENCODING_CP1251, ONIG_OPTION_IGNORECASE, - "aBc", " AbC"); + "aBc", " AbC"); r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE, - " [a-c\337z] ", " SS "); + " [a-c\337z] ", " SS "); r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE, - " [\330-\341] ", " SS "); + " [\330-\341] ", " SS "); r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE, - "\337 ", " Ss "); + "\337 ", " Ss "); r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE, - "SS ", " \337 "); + "SS ", " \337 "); r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE, - "\\A\\S\\z", "ss"); + "\\A\\S\\z", "ss"); r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_3, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_4, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_5, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_6, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_7, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_8, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_9, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_10, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_11, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_13, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_14, ONIG_OPTION_IGNORECASE, - "[ac]+", "bbbaAaCCC"); + "[ac]+", "bbbaAaCCC"); r = exec(ONIG_ENCODING_ISO_8859_15, ONIG_OPTION_IGNORECASE, - (char* )pattern, (char* )str); + (char* )pattern, (char* )str); r = exec(ONIG_ENCODING_ISO_8859_16, ONIG_OPTION_IGNORECASE, - (char* )pattern, (char* )str); + (char* )pattern, (char* )str); r = exec(ONIG_ENCODING_KOI8_R, ONIG_OPTION_NONE, "a+", "bbbaaaccc"); r = exec(ONIG_ENCODING_EUC_TW, ONIG_OPTION_NONE, "b*a+?c+", "bbbaaaccc"); @@ -230,45 +230,45 @@ extern int main(int argc, char* argv[]) "\337", "S\000\000\000S\000\000\000\000\000\000\000"); r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_NONE, - "\000[\000[\000:\000a\000l\000n\000u\000m\000:\000]\000]\000+\000\000", + "\000[\000[\000:\000a\000l\000n\000u\000m\000:\000]\000]\000+\000\000", "\000#\002\120\000a\000Z\012\077\012\076\012\075\000\000"); /* 0x0a3d == \012\075 : is not alnum */ /* 0x0a3e == \012\076 : is alnum */ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_NONE, - "\000\\\000d\000+\000\000", + "\000\\\000d\000+\000\000", "\0003\0001\377\020\377\031\377\032\000\000"); r = exec(ONIG_ENCODING_GB18030, ONIG_OPTION_IGNORECASE, - "(Aa\\d)+", "BaA5Aa0234"); + "(Aa\\d)+", "BaA5Aa0234"); r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_NONE, - "^\\P{Hiragana}\\p{^Hiragana}(\\p{Hiragana}+)$", - "\060\100\060\240\060\101\060\102\060\226\060\237\000\000"); + "^\\P{Hiragana}\\p{^Hiragana}(\\p{Hiragana}+)$", + "\060\100\060\240\060\101\060\102\060\226\060\237\000\000"); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE, - "\000[\000\337\000]\000\000", "\000S\000S\000\000"); + "\000[\000\337\000]\000\000", "\000S\000S\000\000"); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE, - "\000[\000\337\000]\000\000", "\000s\000S\000\000"); + "\000[\000\337\000]\000\000", "\000s\000S\000\000"); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE, - "\000^\000[\000\001\000-\377\375\000]\000$\000\000", - "\000s\000S\000\000"); + "\000^\000[\000\001\000-\377\375\000]\000$\000\000", + "\000s\000S\000\000"); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE, - "\000S\000S\000\000", - "\000S\000T\000\337\000\000"); + "\000S\000S\000\000", + "\000S\000T\000\337\000\000"); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE, - "\000S\000T\000S\000S\000\000", - "\000S\000t\000s\000S\000\000"); + "\000S\000T\000S\000S\000\000", + "\000S\000t\000s\000S\000\000"); { UChar pat[] = { 0x1f, 0xfc, 0x00, 0x00 }; @@ -276,12 +276,10 @@ extern int main(int argc, char* argv[]) UChar str2[] = { 0x1f, 0xf3, 0x00, 0x00 }; r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, - ONIG_OPTION_IGNORECASE, - (char* )pat, (char* )str1); + ONIG_OPTION_IGNORECASE, (char* )pat, (char* )str1); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, - ONIG_OPTION_IGNORECASE, - (char* )pat, (char* )str2); + ONIG_OPTION_IGNORECASE, (char* )pat, (char* )str2); } #if 0 @@ -291,15 +289,15 @@ extern int main(int argc, char* argv[]) r = exec_deluxe(ONIG_ENCODING_UTF8, ONIG_ENCODING_UTF8, ONIG_OPTION_IGNORECASE, - "Ii", "\304\261\304\260"); + "Ii", "\304\261\304\260"); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE, - "\000I\000i\000\000", "\001\061\001\060\000\000"); + "\000I\000i\000\000", "\001\061\001\060\000\000"); r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE, - "\001\061\001\060\000\000", "\000I\000i\000\000"); + "\001\061\001\060\000\000", "\000I\000i\000\000"); set_case_fold(ONIGENC_CASE_FOLD_MIN); #endif diff --git a/sample/listcap.c b/sample/listcap.c index 8598d6a..e0fe23a 100644 --- a/sample/listcap.c +++ b/sample/listcap.c @@ -33,7 +33,7 @@ extern int ex(unsigned char* str, unsigned char* pattern, OnigRegion *region; r = onig_new(®, pattern, pattern + strlen((char* )pattern), - ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo); + ONIG_OPTION_DEFAULT, 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); diff --git a/sample/names.c b/sample/names.c index e570402..a838056 100644 --- a/sample/names.c +++ b/sample/names.c @@ -7,8 +7,8 @@ static int name_callback(const UChar* name, const UChar* name_end, - int ngroup_num, int* group_nums, - regex_t* reg, void* arg) + int ngroup_num, int* group_nums, + regex_t* reg, void* arg) { int i, gn, ref; char* s; @@ -39,7 +39,7 @@ extern int main(int argc, char* argv[]) onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0])); r = onig_new(®, pattern, pattern + strlen((char* )pattern), - ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); + ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); if (r != ONIG_NORMAL) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r, &einfo); diff --git a/sample/posix.c b/sample/posix.c index 65bcf51..35ccb68 100644 --- a/sample/posix.c +++ b/sample/posix.c @@ -16,6 +16,7 @@ static int x(regex_t* reg, unsigned char* pattern, unsigned char* str) if (r != 0 && r != REG_NOMATCH) { regerror(r, reg, buf, sizeof(buf)); fprintf(stderr, "ERROR: %s\n", buf); + regfree(reg); return -1; } @@ -28,6 +29,7 @@ static int x(regex_t* reg, unsigned char* pattern, unsigned char* str) fprintf(stderr, "%d: %d-%d\n", i, pmatch[i].rm_so, pmatch[i].rm_eo); } } + regfree(reg); return 0; } @@ -46,6 +48,7 @@ extern int main(int argc, char* argv[]) if (r) { regerror(r, ®, buf, sizeof(buf)); fprintf(stderr, "ERROR: %s\n", buf); + regfree(®); return -1; } x(®, pattern, (UChar* )"aaabbbbd"); @@ -56,6 +59,7 @@ extern int main(int argc, char* argv[]) if (r) { regerror(r, ®, buf, sizeof(buf)); fprintf(stderr, "ERROR: %s\n", buf); + regfree(®); return -1; } x(®, pattern, (UChar* )"a+b{2,7}d?|uuu"); @@ -66,6 +70,7 @@ extern int main(int argc, char* argv[]) if (r) { regerror(r, ®, buf, sizeof(buf)); fprintf(stderr, "ERROR: %s\n", buf); + regfree(®); return -1; } x(®, pattern, (UChar* )"aaaabbbbbbd"); @@ -77,6 +82,7 @@ extern int main(int argc, char* argv[]) if (r) { regerror(r, ®, buf, sizeof(buf)); fprintf(stderr, "ERROR: %s\n", buf); + regfree(®); return -1; } x(®, pattern, (UChar* )"aaabbbbd)"); @@ -86,11 +92,11 @@ extern int main(int argc, char* argv[]) if (r) { regerror(r, ®, buf, sizeof(buf)); fprintf(stderr, "ERROR: %s\n", buf); + regfree(®); return -1; } x(®, pattern, (UChar* )"a\nb\n"); - regfree(®); onig_end(); return 0; } diff --git a/sample/simple.c b/sample/simple.c index 9860dbe..95110b8 100644 --- a/sample/simple.c +++ b/sample/simple.c @@ -20,7 +20,7 @@ extern int main(int argc, char* argv[]) onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0])); r = onig_new(®, pattern, pattern + strlen((char* )pattern), - ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); + ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); if (r != ONIG_NORMAL) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r, &einfo); diff --git a/sample/sql.c b/sample/sql.c index 4f5283a..8e95f70 100644 --- a/sample/sql.c +++ b/sample/sql.c @@ -28,16 +28,16 @@ extern int main(int argc, char* argv[]) onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ESCAPE, (OnigCodePoint )'\\'); onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR, (OnigCodePoint )'_'); onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYTIME, - ONIG_INEFFECTIVE_META_CHAR); + ONIG_INEFFECTIVE_META_CHAR); onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ZERO_OR_ONE_TIME, - ONIG_INEFFECTIVE_META_CHAR); + ONIG_INEFFECTIVE_META_CHAR); onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ONE_OR_MORE_TIME, - ONIG_INEFFECTIVE_META_CHAR); + ONIG_INEFFECTIVE_META_CHAR); onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR_ANYTIME, - (OnigCodePoint )'%'); + (OnigCodePoint )'%'); r = onig_new(®, pattern, pattern + strlen((char* )pattern), - ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, &SQLSyntax, &einfo); + ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, &SQLSyntax, &einfo); if (r != ONIG_NORMAL) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r, &einfo); diff --git a/sample/syntax.c b/sample/syntax.c index 02af2ea..e292079 100644 --- a/sample/syntax.c +++ b/sample/syntax.c @@ -5,8 +5,7 @@ #include <string.h> #include "oniguruma.h" -extern int exec(OnigSyntaxType* syntax, - char* apattern, char* astr) +extern int exec(OnigSyntaxType* syntax, char* apattern, char* astr) { int r; unsigned char *start, *range, *end; @@ -17,7 +16,7 @@ extern int exec(OnigSyntaxType* syntax, UChar* str = (UChar* )astr; r = onig_new(®, pattern, pattern + strlen((char* )pattern), - ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo); + ONIG_OPTION_DEFAULT, 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); @@ -62,11 +61,10 @@ extern int main(int argc, char* argv[]) onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0])); r = exec(ONIG_SYNTAX_PERL, - "\\p{XDigit}\\P{XDigit}\\p{^XDigit}\\P{^XDigit}\\p{XDigit}", - "bgh3a"); + "\\p{XDigit}\\P{XDigit}\\p{^XDigit}\\P{^XDigit}\\p{XDigit}", + "bgh3a"); - r = exec(ONIG_SYNTAX_JAVA, - "\\p{XDigit}\\P{XDigit}[a-c&&b-g]", "bgc"); + r = exec(ONIG_SYNTAX_JAVA, "\\p{XDigit}\\P{XDigit}[a-c&&b-g]", "bgc"); r = exec(ONIG_SYNTAX_ASIS, "abc def* e+ g?ddd[a-rvvv] (vv){3,7}hv\\dvv(?:aczui ss)\\W\\w$", diff --git a/sample/user_property.c b/sample/user_property.c index 99b3f2c..8b2abd2 100644 --- a/sample/user_property.c +++ b/sample/user_property.c @@ -32,8 +32,7 @@ main(int argc, char* argv[]) OnigEncoding use_encs[] = { ONIG_ENCODING_UTF8 }; onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0])); - r = onig_unicode_define_user_property("HandakuonHiragana", - handakuon_hiragana); + r = onig_unicode_define_user_property("HandakuonHiragana", handakuon_hiragana); if (r == ONIG_NORMAL) { fprintf(stdout, "define HandakuonHiragana\n"); } @@ -45,7 +44,7 @@ main(int argc, char* argv[]) } r = onig_new(®, pattern, pattern + strlen((char* )pattern), - ONIG_OPTION_DEFAULT, ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo); + ONIG_OPTION_DEFAULT, ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo); if (r == ONIG_NORMAL) { fprintf(stdout, "onig_new: success.\n"); } |