summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-05-02 17:29:00 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-05-02 17:29:00 +0200
commit7f5dccbe5fee224ecfeceec6e206cca67ad58452 (patch)
tree2891c20f6f89a6a9ca7a967ca2245c0f8370d5b4 /sample
parentfd4ff4e58174679784d7698880717eefc9399ba7 (diff)
parent83ea1be016fd5fc27ee721cf62a18716675815dc (diff)
Update upstream source from tag 'upstream/6.8.2'
Update to upstream version '6.8.2' with Debian dir 36d9b721af0175dd84faa77cc24739097d03e9bb
Diffstat (limited to 'sample')
-rw-r--r--sample/callout.c64
-rw-r--r--sample/count.c4
2 files changed, 39 insertions, 29 deletions
diff --git a/sample/callout.c b/sample/callout.c
index ab89543..b5e3d91 100644
--- a/sample/callout.c
+++ b/sample/callout.c
@@ -13,7 +13,6 @@ callout_body(OnigCalloutArgs* args, void* user_data)
int i;
int n;
int begin, end;
- int len;
int used_num;
int used_bytes;
OnigCalloutIn in;
@@ -41,6 +40,8 @@ callout_body(OnigCalloutArgs* args, void* user_data)
in == ONIG_CALLOUT_IN_PROGRESS ? "PROGRESS" : "RETRACTION",
contents, start, current);
+ fprintf(stdout, "user_data: %s\n", (char* )user_data);
+
(void )onig_get_used_stack_size_in_callout(args, &used_num, &used_bytes);
fprintf(stdout, "stack: used_num: %d, used_bytes: %d\n", used_num, used_bytes);
@@ -119,7 +120,7 @@ bar(OnigCalloutArgs* args, void* user_data)
}
static int
-test(OnigEncoding enc, char* in_pattern, char* in_str)
+test(OnigEncoding enc, OnigMatchParam* mp, char* in_pattern, char* in_str)
{
int r;
unsigned char *start, *range, *end;
@@ -146,7 +147,8 @@ test(OnigEncoding enc, char* in_pattern, char* in_str)
end = str + strlen((char* )str);
start = str;
range = end;
- r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ r = onig_search_with_param(reg, str, end, start, range, region,
+ ONIG_OPTION_NONE, mp);
if (r >= 0) {
int i;
@@ -173,11 +175,13 @@ extern int main(int argc, char* argv[])
{
int r;
int id;
+ void* user_data;
UChar* name;
OnigEncoding use_encs[1];
unsigned int arg_types[4];
OnigValue opt_defaults[4];
OnigEncoding enc;
+ OnigMatchParam* mp;
enc = ONIG_ENCODING_UTF8;
use_encs[0] = enc;
@@ -219,36 +223,46 @@ extern int main(int argc, char* argv[])
(void)onig_set_progress_callout(progress_callout_func);
(void)onig_set_retraction_callout(retraction_callout_func);
+ mp = onig_new_match_param();
+
+ user_data = (void* )"something data";
+ r = onig_set_callout_user_data_of_match_param(mp, user_data);
+ if (r != ONIG_NORMAL) {
+ fprintf(stderr, "ERROR: fail onig_set_callout_user_data_of_match_param(): %d\n", r);
+ }
+
/* callout of contents */
- test(enc, "a+(?{foo bar baz...}X)$", "aaab");
- test(enc, "(?{{!{}#$%&'()=-~^|[_]`@*:+;<>?/.\\,}}[symbols])c", "abc");
- test(enc, "\\A(...)(?{{{booooooooooooo{{ooo}}ooooooooooz}}}<)", "aaab");
- test(enc, "\\A(?!a(?{in prec-read-not}[xxx]X)b)", "ac");
- test(enc, "(?<!a(?{in look-behind-not}X)c)c", "abc");
+ test(enc, mp, "a+(?{foo bar baz...}X)$", "aaab");
+ test(enc, mp, "(?{{!{}#$%&'()=-~^|[_]`@*:+;<>?/.\\,}}[symbols])c", "abc");
+ test(enc, mp, "\\A(...)(?{{{booooooooooooo{{ooo}}ooooooooooz}}}<)", "aaab");
+ test(enc, mp, "\\A(?!a(?{in prec-read-not}[xxx]X)b)", "ac");
+ test(enc, mp, "(?<!a(?{in look-behind-not}X)c)c", "abc");
// callout of name
- test(enc, "\\A(*foo)abc", "abc");
- test(enc, "abc(?:(*FAIL)|$)", "abcabc");
- test(enc, "abc(?:$|(*MISMATCH)|abc$)", "abcabc");
- test(enc, "abc(?:(*ERROR)|$)", "abcabc");
- test(enc, "ab(*foo{})(*FAIL)", "abc");
- test(enc, "abc(d|(*ERROR{-999}))", "abc");
- test(enc, "ab(*bar{372,I am a bar's argument,あ})c(*FAIL)", "abc");
- test(enc, "ab(*bar{1234567890})", "abc");
- test(enc, "(?:a(*MAX{2})|b)*", "abbabbabbabb");
- test(enc, "(?:(*MAX{2})a|b)*", "abbabbabbabb");
- test(enc, "(?:(*MAX{1})a|b)*", "bbbbbabbbbbabbbbb");
- test(enc, "(?:(*MAX{3})a|(*MAX{4})b)*", "bbbaabbab");
- test(enc, "(?:(*MAX[A]{3})a|(*MAX[B]{5})b)*(*CMP{A,<,B})", "abababc");
- test(enc, "(?:(*MAX[A]{7})a|(*MAX[B]{5})b)*(*CMP{A,>=,4})", "abababcabababaa");
+ test(enc, mp, "\\A(*foo)abc", "abc");
+ test(enc, mp, "abc(?:(*FAIL)|$)", "abcabc");
+ test(enc, mp, "abc(?:$|(*MISMATCH)|abc$)", "abcabc");
+ test(enc, mp, "abc(?:(*ERROR)|$)", "abcabc");
+ test(enc, mp, "ab(*foo{})(*FAIL)", "abc");
+ test(enc, mp, "abc(d|(*ERROR{-999}))", "abc");
+ test(enc, mp, "ab(*bar{372,I am a bar's argument,あ})c(*FAIL)", "abc");
+ test(enc, mp, "ab(*bar{1234567890})", "abc");
+ test(enc, mp, "(?:a(*MAX{2})|b)*", "abbabbabbabb");
+ test(enc, mp, "(?:(*MAX{2})a|b)*", "abbabbabbabb");
+ test(enc, mp, "(?:(*MAX{1})a|b)*", "bbbbbabbbbbabbbbb");
+ test(enc, mp, "(?:(*MAX{3})a|(*MAX{4})b)*", "bbbaabbab");
+ test(enc, mp, "(?:(*MAX[A]{3})a|(*MAX[B]{5})b)*(*CMP{A,<,B})", "abababc");
+ test(enc, mp, "(?:(*MAX[A]{7})a|(*MAX[B]{5})b)*(*CMP{A,>=,4})", "abababcabababaa");
+ test(enc, mp, "(?:(*MAX[T]{3})a)*(?:(*MAX{T})c)*", "aaccc");
/* callouts in condition */
- test(enc, "\\A(?(?{in condition})then|else)\\z", "then");
- test(enc, "\\A(?(*FAIL)then|else)\\z", "else");
+ test(enc, mp, "\\A(?(?{in condition})then|else)\\z", "then");
+ test(enc, mp, "\\A(?(*FAIL)then|else)\\z", "else");
/* monitor test */
- test(enc, "(?:(*MON{X})(*FAIL)|.{,3}(*MON[FOO])k)", "abcdefghijk");
+ test(enc, mp, "(?:(*MON{X})(*FAIL)|.{,3}(*MON[FOO])k)", "abcdefghijk");
+ onig_free_match_param(mp);
onig_end();
return 0;
}
diff --git a/sample/count.c b/sample/count.c
index 0f0e1f2..2b67db7 100644
--- a/sample/count.c
+++ b/sample/count.c
@@ -88,12 +88,8 @@ test(OnigEncoding enc, OnigMatchParam* mp, char* in_pattern, char* in_str)
extern int main(int argc, char* argv[])
{
int r;
- int id;
- UChar* name;
OnigMatchParam* mp;
OnigEncoding encs[3];
- OnigType arg_types[4];
- OnigValue opt_defaults[4];
encs[0] = ONIG_ENCODING_UTF8;
encs[1] = ONIG_ENCODING_UTF16_BE;