summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-20 06:14:49 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-20 06:14:49 +0100
commit10abcf77cc24dfae451d96310b4391dad35906ed (patch)
treeb9812ad2b1b038fd121f1031e9ff87978af0f5ff /sample
parent98ab313fe496ae7c792db29c80bf6b23347484ff (diff)
New upstream version 6.8.1upstream/6.8.1
Diffstat (limited to 'sample')
-rw-r--r--sample/.gitignore3
-rw-r--r--sample/CMakeLists.txt9
-rw-r--r--sample/Makefile.am12
-rw-r--r--sample/bug_fix.c6
-rw-r--r--sample/callout.c254
-rw-r--r--sample/count.c129
-rw-r--r--sample/echo.c136
-rw-r--r--sample/encode.c6
-rw-r--r--sample/listcap.c4
-rw-r--r--sample/names.c4
-rw-r--r--sample/simple.c4
-rw-r--r--sample/sql.c4
-rw-r--r--sample/syntax.c4
-rw-r--r--sample/user_property.c6
14 files changed, 559 insertions, 22 deletions
diff --git a/sample/.gitignore b/sample/.gitignore
index 79fab44..b6b591b 100644
--- a/sample/.gitignore
+++ b/sample/.gitignore
@@ -7,5 +7,8 @@
/sql
/syntax
/user_property
+/callout
+/echo
+/count
/bug_fix
/log*
diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt
index de25ee7..58d6a99 100644
--- a/sample/CMakeLists.txt
+++ b/sample/CMakeLists.txt
@@ -5,6 +5,15 @@ project(oniguruma_sample C)
add_executable(crnl crnl.c)
target_link_libraries(crnl onig)
+add_executable(callout callout.c)
+target_link_libraries(callout onig)
+
+add_executable(echo echo.c)
+target_link_libraries(echo onig)
+
+add_executable(count count.c)
+target_link_libraries(count onig)
+
add_executable(encode encode.c)
target_link_libraries(encode onig)
diff --git a/sample/Makefile.am b/sample/Makefile.am
index 7403384..fd809fa 100644
--- a/sample/Makefile.am
+++ b/sample/Makefile.am
@@ -6,9 +6,9 @@ LDADD = $(lib_onig)
AM_LDFLAGS = -L$(prefix)/lib
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(includedir)
-TESTS = encode listcap names posix simple sql syntax user_property bug_fix
+TESTS = encode listcap names posix simple sql syntax user_property callout echo count bug_fix
-check_PROGRAMS = encode listcap names posix simple sql syntax user_property bug_fix
+check_PROGRAMS = $(TESTS)
encode_SOURCES = encode.c
listcap_SOURCES = listcap.c
@@ -18,11 +18,14 @@ simple_SOURCES = simple.c
sql_SOURCES = sql.c
syntax_SOURCES = syntax.c
user_property_SOURCES = user_property.c
+callout_SOURCES = callout.c
+echo_SOURCES = echo.c
+count_SOURCES = count.c
bug_fix = bug_fix.c
sampledir = .
-test: encode listcap names posix simple sql syntax user_property bug_fix
+test: $(TESTS)
$(sampledir)/encode
$(sampledir)/listcap
$(sampledir)/names
@@ -31,4 +34,7 @@ test: encode listcap names posix simple sql syntax user_property bug_fix
$(sampledir)/sql
$(sampledir)/syntax
$(sampledir)/user_property
+ $(sampledir)/callout
+ $(sampledir)/echo
+ $(sampledir)/count
$(sampledir)/bug_fix
diff --git a/sample/bug_fix.c b/sample/bug_fix.c
index 9a45a78..44802ef 100644
--- a/sample/bug_fix.c
+++ b/sample/bug_fix.c
@@ -33,7 +33,7 @@ search(regex_t* reg, unsigned char* str, unsigned char* end)
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
fprintf(stderr, " (%s)\n", ONIGENC_NAME(onig_get_encoding(reg)));
return -1;
@@ -69,7 +69,7 @@ exec_deluxe(OnigEncoding pattern_enc, OnigEncoding str_enc,
&ci, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -99,7 +99,7 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
options, enc, ONIG_SYNTAX_DEFAULT, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
diff --git a/sample/callout.c b/sample/callout.c
new file mode 100644
index 0000000..ab89543
--- /dev/null
+++ b/sample/callout.c
@@ -0,0 +1,254 @@
+/*
+ * callout.c
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+static int
+callout_body(OnigCalloutArgs* args, void* user_data)
+{
+ int r;
+ int i;
+ int n;
+ int begin, end;
+ int len;
+ int used_num;
+ int used_bytes;
+ OnigCalloutIn in;
+ int name_id;
+ const UChar* contents;
+ const UChar* start;
+ const UChar* current;
+ regex_t* regex;
+
+ in = onig_get_callout_in_by_callout_args(args);
+ name_id = onig_get_name_id_by_callout_args(args);
+ start = onig_get_start_by_callout_args(args);
+ current = onig_get_current_by_callout_args(args);
+ regex = onig_get_regex_by_callout_args(args);
+
+ contents = onig_get_contents_by_callout_args(args);
+
+ if (name_id != ONIG_NON_NAME_ID) {
+ UChar* name = onig_get_callout_name_by_name_id(name_id);
+ fprintf(stdout, "name: %s\n", name);
+ }
+ fprintf(stdout,
+ "%s %s: contents: \"%s\", start: \"%s\", current: \"%s\"\n",
+ contents != 0 ? "CONTENTS" : "NAME",
+ in == ONIG_CALLOUT_IN_PROGRESS ? "PROGRESS" : "RETRACTION",
+ contents, start, current);
+
+ (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);
+
+ n = onig_number_of_captures(regex);
+ for (i = 1; i <= n; i++) {
+ r = onig_get_capture_range_in_callout(args, i, &begin, &end);
+ if (r != ONIG_NORMAL) return r;
+
+ fprintf(stdout, "capture %d: (%d-%d)\n", i, begin, end);
+ }
+
+ fflush(stdout);
+ return ONIG_CALLOUT_SUCCESS;
+}
+
+static int
+progress_callout_func(OnigCalloutArgs* args, void* user_data)
+{
+ return callout_body(args, user_data);
+}
+
+static int
+retraction_callout_func(OnigCalloutArgs* args, void* user_data)
+{
+ return callout_body(args, user_data);
+}
+
+static int
+foo(OnigCalloutArgs* args, void* user_data)
+{
+ return callout_body(args, user_data);
+}
+
+static int
+bar(OnigCalloutArgs* args, void* user_data)
+{
+ int r;
+ int i;
+ int n;
+ OnigType type;
+ OnigValue val;
+
+ fprintf(stdout, "bar called.\n");
+
+ n = onig_get_args_num_by_callout_args(args);
+ if (n < 0) {
+ fprintf(stderr, "FAIL: onig_get_args_num_by_callout_args(): %d\n", n);
+ return n;
+ }
+
+ for (i = 0; i < n; i++) {
+ r = onig_get_arg_by_callout_args(args, i, &type, &val);
+ if (r != 0) {
+ fprintf(stderr, "FAIL: onig_get_arg_by_callout_args(): %d\n", r);
+ return r;
+ }
+
+ fprintf(stdout, "arg[%d]: ", i);
+ switch (type) {
+ case ONIG_TYPE_LONG:
+ fprintf(stdout, "%ld\n", val.l);
+ break;
+ case ONIG_TYPE_CHAR:
+ fprintf(stdout, "0x%06x\n", val.c);
+ break;
+ case ONIG_TYPE_STRING:
+ fprintf(stdout, "'%s'\n", val.s.start);
+ break;
+ default:
+ /* Never come here. But escape warning. */
+ break;
+ };
+ }
+
+ return ONIG_CALLOUT_SUCCESS;
+}
+
+static int
+test(OnigEncoding enc, char* in_pattern, char* in_str)
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+ UChar* pattern;
+ UChar* str;
+
+ pattern = (UChar* )in_pattern;
+ str = (UChar* )in_str;
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, 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);
+ fprintf(stderr, "COMPILE ERROR: %d: %s\n", r, s);
+ return -1;
+ }
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ int i;
+
+ fprintf(stderr, "match at %d\n", r);
+ for (i = 0; i < region->num_regs; i++) {
+ fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
+ }
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail\n");
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str((UChar* )s, r);
+ fprintf(stderr, "SEARCH ERROR: %d: %s\n", r, s);
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ return r;
+}
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ int id;
+ UChar* name;
+ OnigEncoding use_encs[1];
+ unsigned int arg_types[4];
+ OnigValue opt_defaults[4];
+ OnigEncoding enc;
+
+ enc = ONIG_ENCODING_UTF8;
+ use_encs[0] = enc;
+
+ r = onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
+ if (r != ONIG_NORMAL) return -1;
+
+ /* monitor on */
+ r = onig_setup_builtin_monitors_by_ascii_encoded_name(stdout);
+ if (r != ONIG_NORMAL) return -1;
+
+ name = (UChar* )"foo";
+ id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,
+ name, name + strlen((char* )name),
+ ONIG_CALLOUT_IN_BOTH, foo, 0, 0, 0, 0, 0);
+ if (id < 0) {
+ fprintf(stderr, "ERROR: fail to set callout of name: %s\n", name);
+ //return -1;
+ }
+
+ name = (UChar* )"bar";
+ arg_types[0] = ONIG_TYPE_LONG;
+ arg_types[1] = ONIG_TYPE_STRING;
+ arg_types[2] = ONIG_TYPE_CHAR;
+ opt_defaults[0].s.start = (UChar* )"I am a option argument's default value.";
+ opt_defaults[0].s.end = opt_defaults[0].s.start +
+ strlen((char* )opt_defaults[0].s.start);
+ opt_defaults[1].c = 0x4422;
+
+ id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,
+ name, name + strlen((char* )name),
+ ONIG_CALLOUT_IN_PROGRESS, bar, 0,
+ 3, arg_types, 2, opt_defaults);
+ if (id < 0) {
+ fprintf(stderr, "ERROR: fail to set callout of name: %s\n", name);
+ //return -1;
+ }
+
+ (void)onig_set_progress_callout(progress_callout_func);
+ (void)onig_set_retraction_callout(retraction_callout_func);
+
+ /* 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");
+
+ // 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");
+
+ /* callouts in condition */
+ test(enc, "\\A(?(?{in condition})then|else)\\z", "then");
+ test(enc, "\\A(?(*FAIL)then|else)\\z", "else");
+
+ /* monitor test */
+ test(enc, "(?:(*MON{X})(*FAIL)|.{,3}(*MON[FOO])k)", "abcdefghijk");
+
+ onig_end();
+ return 0;
+}
diff --git a/sample/count.c b/sample/count.c
new file mode 100644
index 0000000..0f0e1f2
--- /dev/null
+++ b/sample/count.c
@@ -0,0 +1,129 @@
+/*
+ * count.c
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+#define ulen(enc, p) onigenc_str_bytelen_null(enc, (UChar* )p)
+
+static int
+test(OnigEncoding enc, OnigMatchParam* mp, char* in_pattern, char* in_str)
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+ UChar* pattern;
+ UChar* str;
+
+ pattern = (UChar* )in_pattern;
+ str = (UChar* )in_str;
+
+ r = onig_new(&reg, pattern, pattern + ulen(enc, pattern),
+ ONIG_OPTION_DEFAULT, 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);
+ fprintf(stderr, "COMPILE ERROR: %d: %s\n", r, s);
+ return -1;
+ }
+
+ region = onig_region_new();
+
+ end = str + ulen(enc, str);
+ start = str;
+ range = end;
+ r = onig_search_with_param(reg, str, end, start, range, region,
+ ONIG_OPTION_NONE, mp);
+ if (r >= 0) {
+ int slot;
+ OnigValue val;
+ char* tag;
+ int tag_len;
+
+ fprintf(stdout, "match at %d\n", r);
+
+ show_count:
+ if (enc == ONIG_ENCODING_UTF16_BE) {
+ tag = "\000x\000\000";
+ }
+ else if (enc == ONIG_ENCODING_UTF16_LE) {
+ tag = "x\000\000\000";
+ }
+ else {
+ tag = "x";
+ }
+ tag_len = ulen(enc, tag);
+
+ slot = 0;
+ r = onig_get_callout_data_by_tag(reg, mp, (UChar* )tag, (UChar* )tag + tag_len,
+ slot, 0, &val);
+ if (r < ONIG_NORMAL) goto err;
+ else if (r > ONIG_NORMAL) {
+ fprintf(stdout, "COUNT[x]: NO DATA\n");
+ }
+ else {
+ fprintf(stdout, "COUNT[x]: %ld\n", val.l);
+ }
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stdout, "search fail\n");
+ goto show_count;
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ err:
+ onig_error_code_to_str((UChar* )s, r);
+ fprintf(stdout, "SEARCH ERROR: %d: %s\n", r, s);
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ return r;
+}
+
+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;
+ encs[2] = ONIG_ENCODING_UTF16_LE;
+
+ r = onig_initialize(encs, sizeof(encs)/sizeof(encs[0]));
+ if (r != ONIG_NORMAL) {
+ fprintf(stderr, "FAIL: onig_initialize(): %d\n", r);
+ return -1;
+ }
+
+ mp = onig_new_match_param();
+
+ test(encs[0], mp, "abc(.(*COUNT[x]))*(*FAIL)", "abcdefg");
+ test(encs[0], mp, "abc(.(*COUNT[_any_]))*(.(*COUNT[x]))*d", "abcdefg");
+ /* fail count */
+ test(encs[0], mp, "abc(.(*COUNT[x]{<}))*f", "abcdefg");
+ /* success count */
+ test(encs[0], mp, "abc(.(*COUNT[x]{X}))*f", "abcdefg");
+ /* passed count */
+ test(encs[0], mp, "abc(.(*COUNT[x]))*f", "abcdefg");
+ test(encs[0], mp, "a(.(*COUNT[x]))*z", "abcd\nabcdz");
+ /* total count */
+ test(encs[0], mp, "a(.(*TOTAL_COUNT[x]))*z", "abcd\nabcdz");
+
+ test(encs[1], mp, "\000a\000b\000c\000(\000.\000(\000*\000C\000O\000U\000N\000T\000[\000x\000]\000)\000)\000*\000(\000*\000F\000A\000I\000L\000)\000\000", "\000a\000b\000c\000d\000e\000f\000g\000\000");
+
+ test(encs[2], mp, "a\000b\000c\000(\000.\000(\000*\000C\000O\000U\000N\000T\000[\000x\000]\000)\000)\000*\000(\000*\000F\000A\000I\000L\000)\000\000\000", "a\000b\000c\000d\000e\000f\000g\000\000\000");
+
+ onig_free_match_param(mp);
+ onig_end();
+ return 0;
+}
diff --git a/sample/echo.c b/sample/echo.c
new file mode 100644
index 0000000..76df207
--- /dev/null
+++ b/sample/echo.c
@@ -0,0 +1,136 @@
+/*
+ * echo.c
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+static int
+echo(OnigCalloutArgs* args, void* user_data)
+{
+ int r;
+ OnigCalloutIn in;
+ OnigType type;
+ OnigValue val;
+ FILE* fp;
+
+ fp = stdout;
+
+ in = onig_get_callout_in_by_callout_args(args);
+
+ r = onig_get_arg_by_callout_args(args, 1, &type, &val);
+ if (r != ONIG_NORMAL) return r;
+
+ if (in == ONIG_CALLOUT_IN_PROGRESS) {
+ if (val.c == '<')
+ return ONIG_CALLOUT_SUCCESS;
+ }
+ else {
+ if (val.c != 'X' && val.c != '<')
+ return ONIG_CALLOUT_SUCCESS;
+ }
+
+ r = onig_get_arg_by_callout_args(args, 0, &type, &val);
+ if (r != ONIG_NORMAL) return r;
+
+
+ fprintf(fp, "%s %s\n",
+ (in == ONIG_CALLOUT_IN_PROGRESS ? "=>" : "<="),
+ val.s.start);
+ fflush(fp);
+
+ return ONIG_CALLOUT_SUCCESS;
+}
+
+
+static int
+test(OnigEncoding enc, char* in_pattern, char* in_str)
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+ UChar* pattern;
+ UChar* str;
+
+ pattern = (UChar* )in_pattern;
+ str = (UChar* )in_str;
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, 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);
+ fprintf(stderr, "COMPILE ERROR: %d: %s\n", r, s);
+ return -1;
+ }
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ int i;
+
+ fprintf(stderr, "match at %d\n", r);
+ for (i = 0; i < region->num_regs; i++) {
+ fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
+ }
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail\n");
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str((UChar* )s, r);
+ fprintf(stderr, "SEARCH ERROR: %d: %s\n", r, s);
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ return r;
+}
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ int id;
+ UChar* name;
+ OnigEncoding use_encs[1];
+ OnigType arg_types[4];
+ OnigValue opt_defaults[4];
+ OnigEncoding enc;
+
+ enc = ONIG_ENCODING_UTF8;
+ use_encs[0] = enc;
+
+ r = onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
+ if (r != ONIG_NORMAL) return -1;
+
+ name = (UChar* )"echo";
+ arg_types[0] = ONIG_TYPE_STRING;
+ arg_types[1] = ONIG_TYPE_CHAR;
+ opt_defaults[0].s.start = (UChar* )"echo";
+ opt_defaults[0].s.end = opt_defaults[0].s.start +
+ strlen((char* )opt_defaults[0].s.start);
+ opt_defaults[1].c = '>';
+
+ id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,
+ name, name + strlen((char* )name),
+ ONIG_CALLOUT_IN_BOTH, echo, 0,
+ 2, arg_types, 2, opt_defaults);
+ if (id < 0) {
+ fprintf(stderr, "ERROR: fail to set callout of name: %s\n", name);
+ return -1;
+ }
+
+ test(enc, "(?:(*echo{abc!!!})a|b)*", "abba");
+ test(enc, "(?:(*echo{xyz,X})a|b)*", "abba");
+
+ onig_end();
+ return 0;
+}
diff --git a/sample/encode.c b/sample/encode.c
index 1daafa9..4eead6e 100644
--- a/sample/encode.c
+++ b/sample/encode.c
@@ -31,7 +31,7 @@ search(regex_t* reg, unsigned char* str, unsigned char* end)
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
fprintf(stderr, " (%s)\n", ONIGENC_NAME(onig_get_encoding(reg)));
return -1;
@@ -59,7 +59,7 @@ exec(OnigEncoding enc, OnigOptionType options,
options, enc, ONIG_SYNTAX_DEFAULT, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -108,7 +108,7 @@ exec_deluxe(OnigEncoding pattern_enc, OnigEncoding str_enc,
&ci, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
diff --git a/sample/listcap.c b/sample/listcap.c
index e283890..6f9880c 100644
--- a/sample/listcap.c
+++ b/sample/listcap.c
@@ -36,7 +36,7 @@ extern int ex(unsigned char* str, unsigned char* pattern,
ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -68,7 +68,7 @@ extern int ex(unsigned char* str, unsigned char* pattern,
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
return -1;
}
diff --git a/sample/names.c b/sample/names.c
index 2cf3a2f..e570402 100644
--- a/sample/names.c
+++ b/sample/names.c
@@ -42,7 +42,7 @@ extern int main(int argc, char* argv[])
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);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -64,7 +64,7 @@ extern int main(int argc, char* argv[])
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
return -1;
}
diff --git a/sample/simple.c b/sample/simple.c
index e570a30..9860dbe 100644
--- a/sample/simple.c
+++ b/sample/simple.c
@@ -23,7 +23,7 @@ extern int main(int argc, char* argv[])
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);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -47,7 +47,7 @@ extern int main(int argc, char* argv[])
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
diff --git a/sample/sql.c b/sample/sql.c
index dfa176c..4f5283a 100644
--- a/sample/sql.c
+++ b/sample/sql.c
@@ -40,7 +40,7 @@ extern int main(int argc, char* argv[])
ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, &SQLSyntax, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -64,7 +64,7 @@ extern int main(int argc, char* argv[])
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
diff --git a/sample/syntax.c b/sample/syntax.c
index 6bf27c5..02af2ea 100644
--- a/sample/syntax.c
+++ b/sample/syntax.c
@@ -20,7 +20,7 @@ extern int exec(OnigSyntaxType* syntax,
ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo);
if (r != ONIG_NORMAL) {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -44,7 +44,7 @@ extern int exec(OnigSyntaxType* syntax,
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
diff --git a/sample/user_property.c b/sample/user_property.c
index fb604f6..99b3f2c 100644
--- a/sample/user_property.c
+++ b/sample/user_property.c
@@ -39,7 +39,7 @@ main(int argc, char* argv[])
}
else {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}
@@ -51,7 +51,7 @@ main(int argc, char* argv[])
}
else {
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r, &einfo);
+ onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "onig_new: ERROR: %s\n", s);
return -1;
}
@@ -75,7 +75,7 @@ main(int argc, char* argv[])
}
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str(s, r);
+ onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
return -1;
}