summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/Makefile.am10
-rw-r--r--sample/bug_fix.c56
-rw-r--r--sample/crnl.c2
-rw-r--r--sample/encode.c142
-rw-r--r--sample/listcap.c2
-rw-r--r--sample/names.c3
-rw-r--r--sample/posix.c5
-rw-r--r--sample/regset.c94
-rw-r--r--sample/scan.c2
-rw-r--r--sample/simple.c3
-rw-r--r--sample/sql.c4
-rw-r--r--sample/syntax.c2
-rw-r--r--sample/user_property.c5
13 files changed, 164 insertions, 166 deletions
diff --git a/sample/Makefile.am b/sample/Makefile.am
index 320afcf..22a4989 100644
--- a/sample/Makefile.am
+++ b/sample/Makefile.am
@@ -6,7 +6,11 @@ LDADD = $(lib_onig)
AM_LDFLAGS = -L$(prefix)/lib
AM_CPPFLAGS = -I$(top_srcdir)/src
-TESTS = encode listcap names posix simple sql syntax user_property callout echo count bug_fix
+if ENABLE_POSIX_API
+TESTS = encode listcap names posix simple sql syntax user_property callout echo count bug_fix regset
+else
+TESTS = encode listcap names simple sql syntax user_property callout echo count bug_fix regset
+endif
check_PROGRAMS = $(TESTS)
@@ -22,6 +26,7 @@ callout_SOURCES = callout.c
echo_SOURCES = echo.c
count_SOURCES = count.c
bug_fix = bug_fix.c
+regset_SOURCES = regset.c
sampledir = .
@@ -29,7 +34,9 @@ test: $(TESTS)
$(sampledir)/encode
$(sampledir)/listcap
$(sampledir)/names
+if ENABLE_POSIX_API
$(sampledir)/posix
+endif
$(sampledir)/simple
$(sampledir)/sql
$(sampledir)/syntax
@@ -38,3 +45,4 @@ test: $(TESTS)
$(sampledir)/echo
$(sampledir)/count
$(sampledir)/bug_fix
+ $(sampledir)/regset
diff --git a/sample/bug_fix.c b/sample/bug_fix.c
index 81c2784..f295bfd 100644
--- a/sample/bug_fix.c
+++ b/sample/bug_fix.c
@@ -4,8 +4,6 @@
#include <stdio.h>
#include "oniguruma.h"
-static OnigCaseFoldType CF = ONIGENC_CASE_FOLD_MIN;
-
static int
search(regex_t* reg, unsigned char* str, unsigned char* end)
{
@@ -36,6 +34,7 @@ search(regex_t* reg, unsigned char* str, unsigned char* end)
onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
fprintf(stderr, " (%s)\n", ONIGENC_NAME(onig_get_encoding(reg)));
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
return -1;
}
@@ -44,45 +43,6 @@ search(regex_t* reg, unsigned char* str, unsigned char* end)
}
static int
-exec_deluxe(OnigEncoding pattern_enc, OnigEncoding str_enc,
- OnigOptionType options, char* apattern, char* astr)
-{
- int r;
- unsigned char *end;
- regex_t* reg;
- OnigCompileInfo ci;
- OnigErrorInfo einfo;
- UChar* pattern = (UChar* )apattern;
- UChar* str = (UChar* )astr;
-
- onig_initialize(&str_enc, 1);
-
- ci.num_of_elements = 5;
- ci.pattern_enc = pattern_enc;
- ci.target_enc = str_enc;
- ci.syntax = ONIG_SYNTAX_DEFAULT;
- ci.option = options;
- ci.case_fold_flag = CF;
-
- r = onig_new_deluxe(&reg, pattern,
- pattern + onigenc_str_bytelen_null(pattern_enc, pattern),
- &ci, &einfo);
- if (r != ONIG_NORMAL) {
- char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str((UChar* )s, r, &einfo);
- fprintf(stderr, "ERROR: %s\n", s);
- return -1;
- }
-
- end = str + onigenc_str_bytelen_null(str_enc, str);
- r = search(reg, str, end);
-
- onig_free(reg);
- onig_end();
- return 0;
-}
-
-static int
exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
{
int r;
@@ -92,8 +52,6 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
UChar* pattern = (UChar* )apattern;
UChar* str = (UChar* )astr;
- onig_initialize(&enc, 1);
-
r = onig_new(&reg, pattern,
pattern + onigenc_str_bytelen_null(enc, pattern),
options, enc, ONIG_SYNTAX_DEFAULT, &einfo);
@@ -108,7 +66,6 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
r = search(reg, str, end);
onig_free(reg);
- onig_end();
return 0;
}
@@ -116,16 +73,21 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
extern int main(int argc, char* argv[])
{
+ OnigEncoding use_encs[1];
+
+ use_encs[0] = ONIG_ENCODING_UTF8;
+ onig_initialize(use_encs, 1);
+
/* fix ignore case in look-behind
commit: 3340ec2cc5627172665303fe248c9793354d2251 */
- exec_deluxe(ONIG_ENCODING_UTF8, ONIG_ENCODING_UTF8,
- ONIG_OPTION_IGNORECASE,
- "(?<=\305\211)a", "\312\274na"); /* \u{0149}a \u{02bc}na */
+ exec(ONIG_ENCODING_UTF8, ONIG_OPTION_IGNORECASE,
+ "\305\211a", "\312\274na"); /* \u{0149}a \u{02bc}na */
exec(ONIG_ENCODING_UTF8, ONIG_OPTION_NONE, "(\\2)(\\1)", "aa"); /* fail. */
exec(ONIG_ENCODING_UTF8, ONIG_OPTION_FIND_LONGEST,
"a*", "aa aaa aaaa aaaaa "); /* match 12-17 */
+ onig_end();
return 0;
}
diff --git a/sample/crnl.c b/sample/crnl.c
index 3ad1210..bfa563e 100644
--- a/sample/crnl.c
+++ b/sample/crnl.c
@@ -65,6 +65,8 @@ x(int no, char* pattern_arg, char* str_arg,
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str(s, r);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
return -1;
}
diff --git a/sample/encode.c b/sample/encode.c
index 8a03ab8..c5d4771 100644
--- a/sample/encode.c
+++ b/sample/encode.c
@@ -34,6 +34,7 @@ search(regex_t* reg, unsigned char* str, unsigned char* end)
onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
fprintf(stderr, " (%s)\n", ONIGENC_NAME(onig_get_encoding(reg)));
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
return -1;
}
@@ -72,55 +73,6 @@ exec(OnigEncoding enc, OnigOptionType options,
return 0;
}
-static OnigCaseFoldType CF = ONIGENC_CASE_FOLD_MIN;
-
-#if 0
-static void
-set_case_fold(OnigCaseFoldType cf)
-{
- CF = cf;
-}
-#endif
-
-static int
-exec_deluxe(OnigEncoding pattern_enc, OnigEncoding str_enc,
- OnigOptionType options, char* apattern, char* astr)
-{
- int r;
- unsigned char *end;
- regex_t* reg;
- OnigCompileInfo ci;
- OnigErrorInfo einfo;
- UChar* pattern = (UChar* )apattern;
- UChar* str = (UChar* )astr;
-
- onig_initialize(&str_enc, 1);
-
- ci.num_of_elements = 5;
- ci.pattern_enc = pattern_enc;
- ci.target_enc = str_enc;
- ci.syntax = ONIG_SYNTAX_DEFAULT;
- ci.option = options;
- ci.case_fold_flag = CF;
-
- r = onig_new_deluxe(&reg, pattern,
- pattern + onigenc_str_bytelen_null(pattern_enc, pattern),
- &ci, &einfo);
- if (r != ONIG_NORMAL) {
- char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str((UChar* )s, r, &einfo);
- fprintf(stderr, "ERROR: %s\n", s);
- return -1;
- }
-
- end = str + onigenc_str_bytelen_null(str_enc, str);
- r = search(reg, str, end);
-
- onig_free(reg);
- onig_end();
- return 0;
-}
-
extern int main(int argc, char* argv[])
{
int r;
@@ -196,39 +148,6 @@ extern int main(int argc, char* argv[])
r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
"is", "iss");
- r = exec_deluxe(ONIG_ENCODING_ASCII, ONIG_ENCODING_UTF16_BE,
- ONIG_OPTION_NONE, "a+",
- "\000b\000a\000a\000a\000c\000c\000\000");
-
- r = exec_deluxe(ONIG_ENCODING_ASCII, ONIG_ENCODING_UTF16_LE,
- ONIG_OPTION_NONE, "a+",
- "b\000a\000a\000a\000a\000c\000\000\000");
-
- r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_LE,
- ONIG_OPTION_NONE,
- "\000b\000a\000a\000a\000c\000c\000\000",
- "x\000b\000a\000a\000a\000c\000c\000\000\000");
-
- r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_BE,
- ONIG_OPTION_IGNORECASE,
- "\337", "\000S\000S\000\000");
-
- r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_BE,
- ONIG_OPTION_IGNORECASE,
- "SS", "\000\337\000\000");
-
- r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_LE,
- ONIG_OPTION_IGNORECASE,
- "\337", "S\000S\000\000\000");
-
- r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF32_BE,
- ONIG_OPTION_IGNORECASE,
- "SS", "\000\000\000\337\000\000\000\000");
-
- r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF32_LE,
- ONIG_OPTION_IGNORECASE,
- "\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#\002\120\000a\000Z\012\077\012\076\012\075\000\000");
@@ -242,44 +161,34 @@ extern int main(int argc, char* argv[])
r = exec(ONIG_ENCODING_GB18030, ONIG_OPTION_IGNORECASE,
"(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");
-
- r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
- ONIG_OPTION_IGNORECASE,
- "\000[\000\337\000]\000\000", "\000S\000S\000\000");
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ "\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");
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ "\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");
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ "\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");
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ "\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");
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ "\000S\000T\000S\000S\000\000",
+ "\000S\000t\000s\000S\000\000");
{
UChar pat[] = { 0x1f, 0xfc, 0x00, 0x00 };
UChar str1[] = { 0x21, 0x26, 0x1f, 0xbe, 0x00, 0x00 };
UChar str2[] = { 0x1f, 0xf3, 0x00, 0x00 };
- r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
- ONIG_OPTION_IGNORECASE, (char* )pat, (char* )str1);
+ r = exec(ONIG_ENCODING_UTF16_BE, 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);
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ (char* )pat, (char* )str2);
}
#if 0
@@ -287,17 +196,14 @@ extern int main(int argc, char* argv[])
set_case_fold(ONIGENC_CASE_FOLD_TURKISH_AZERI);
- r = exec_deluxe(ONIG_ENCODING_UTF8, ONIG_ENCODING_UTF8,
- ONIG_OPTION_IGNORECASE,
- "Ii", "\304\261\304\260");
+ r = exec(ONIG_ENCODING_UTF8, ONIG_ENCODING_UTF8, ONIG_OPTION_IGNORECASE,
+ "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");
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ "\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");
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_IGNORECASE,
+ "\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 e0fe23a..a73f7d4 100644
--- a/sample/listcap.c
+++ b/sample/listcap.c
@@ -69,6 +69,8 @@ extern int ex(unsigned char* str, unsigned char* pattern,
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
return -1;
}
diff --git a/sample/names.c b/sample/names.c
index a838056..9b1eb24 100644
--- a/sample/names.c
+++ b/sample/names.c
@@ -65,6 +65,9 @@ extern int main(int argc, char* argv[])
else { /* error */
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
return -1;
}
diff --git a/sample/posix.c b/sample/posix.c
index 35ccb68..c555936 100644
--- a/sample/posix.c
+++ b/sample/posix.c
@@ -49,6 +49,7 @@ extern int main(int argc, char* argv[])
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
regfree(&reg);
+ onig_end();
return -1;
}
x(&reg, pattern, (UChar* )"aaabbbbd");
@@ -60,6 +61,7 @@ extern int main(int argc, char* argv[])
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
regfree(&reg);
+ onig_end();
return -1;
}
x(&reg, pattern, (UChar* )"a+b{2,7}d?|uuu");
@@ -71,6 +73,7 @@ extern int main(int argc, char* argv[])
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
regfree(&reg);
+ onig_end();
return -1;
}
x(&reg, pattern, (UChar* )"aaaabbbbbbd");
@@ -83,6 +86,7 @@ extern int main(int argc, char* argv[])
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
regfree(&reg);
+ onig_end();
return -1;
}
x(&reg, pattern, (UChar* )"aaabbbbd)");
@@ -93,6 +97,7 @@ extern int main(int argc, char* argv[])
regerror(r, &reg, buf, sizeof(buf));
fprintf(stderr, "ERROR: %s\n", buf);
regfree(&reg);
+ onig_end();
return -1;
}
x(&reg, pattern, (UChar* )"a\nb\n");
diff --git a/sample/regset.c b/sample/regset.c
new file mode 100644
index 0000000..ca3a10c
--- /dev/null
+++ b/sample/regset.c
@@ -0,0 +1,94 @@
+/*
+ * regset.c
+ */
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ int i, n;
+ int match_pos;
+ unsigned char *start, *range, *end;
+ OnigRegSet* set;
+ OnigRegSetLead lead;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ char ebuf[ONIG_MAX_ERROR_MESSAGE_LEN];
+
+ static UChar* str = (UChar* )"aaaaaaaaaaaaaaaaaaaaaaca";
+
+ static char* pat[] = {
+ "a(.*)b|a(.)c",
+ "^(abc)",
+ "a(.....)c"
+ };
+
+ OnigEncoding use_encs[] = { ONIG_ENCODING_UTF8 };
+ onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
+
+ r = onig_regset_new(&set, 0, NULL);
+ if (r != ONIG_NORMAL) {
+ onig_error_code_to_str((UChar* )ebuf, r);
+ fprintf(stderr, "ERROR: %s\n", ebuf);
+ onig_end();
+ return -1;
+ }
+
+ n = sizeof(pat) / sizeof(pat[0]);
+
+ for (i = 0; i < n; i++) {
+ r = onig_new(&reg, (UChar* )pat[i], (UChar* )(pat[i] + strlen(pat[i])),
+ ONIG_OPTION_DEFAULT, ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT,
+ &einfo);
+ if (r != ONIG_NORMAL) {
+ onig_error_code_to_str((UChar* )ebuf, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", ebuf);
+ onig_regset_free(set);
+ onig_end();
+ return -1;
+ }
+
+ r = onig_regset_add(set, reg);
+ if (r != ONIG_NORMAL) {
+ onig_free(reg);
+ onig_regset_free(set);
+ onig_end();
+ return -1;
+ }
+ }
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ lead = ONIG_REGSET_POSITION_LEAD;
+ //lead = ONIG_REGSET_PRIORITY_TO_REGEX_ORDER;
+ r = onig_regset_search(set, str, end, start, range, lead, ONIG_OPTION_NONE,
+ &match_pos);
+ if (r >= 0) {
+ OnigRegion *region;
+
+ fprintf(stderr, "match regex index: %d\n", r);
+ fprintf(stderr, "match position: %d\n", match_pos);
+
+ region = onig_regset_get_region(set, 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 */
+ onig_error_code_to_str((UChar* )ebuf, r);
+ fprintf(stderr, "ERROR: %s\n", ebuf);
+ onig_regset_free(set);
+ onig_end();
+ return -1;
+ }
+
+ onig_regset_free(set);
+ onig_end();
+ return 0;
+}
diff --git a/sample/scan.c b/sample/scan.c
index ad5ae74..4039e46 100644
--- a/sample/scan.c
+++ b/sample/scan.c
@@ -36,6 +36,7 @@ scan(regex_t* reg, unsigned char* str, unsigned char* end)
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((OnigUChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
return -1;
}
@@ -63,6 +64,7 @@ exec(OnigEncoding enc, OnigOptionType options, char* apattern, char* astr)
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((OnigUChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_end();
return -1;
}
diff --git a/sample/simple.c b/sample/simple.c
index 95110b8..5a14042 100644
--- a/sample/simple.c
+++ b/sample/simple.c
@@ -49,6 +49,9 @@ extern int main(int argc, char* argv[])
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
return -1;
}
diff --git a/sample/sql.c b/sample/sql.c
index 8e95f70..1602ac9 100644
--- a/sample/sql.c
+++ b/sample/sql.c
@@ -42,6 +42,7 @@ extern int main(int argc, char* argv[])
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_end();
return -1;
}
@@ -66,6 +67,9 @@ extern int main(int argc, char* argv[])
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
return -1;
}
diff --git a/sample/syntax.c b/sample/syntax.c
index e292079..e034608 100644
--- a/sample/syntax.c
+++ b/sample/syntax.c
@@ -45,6 +45,8 @@ extern int exec(OnigSyntaxType* syntax, char* apattern, char* astr)
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
return -1;
}
diff --git a/sample/user_property.c b/sample/user_property.c
index 8b2abd2..d52adc0 100644
--- a/sample/user_property.c
+++ b/sample/user_property.c
@@ -40,6 +40,7 @@ main(int argc, char* argv[])
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_end();
return -1;
}
@@ -52,6 +53,7 @@ main(int argc, char* argv[])
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r, &einfo);
fprintf(stderr, "onig_new: ERROR: %s\n", s);
+ onig_end();
return -1;
}
@@ -76,6 +78,9 @@ main(int argc, char* argv[])
char s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str((UChar* )s, r);
fprintf(stderr, "ERROR: %s\n", s);
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
return -1;
}