summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2019-08-07 09:32:54 +0200
committerJörg Frings-Fürst <debian@jff.email>2019-08-07 09:32:54 +0200
commit1fb4b2b100d76cfa362cd021760b7cc0038cf55d (patch)
tree2443bfdda69965757d8ce335cda1a28bb7327834 /sample
parentb134093d75235a90f09ff591137aed9dbdad6e89 (diff)
parent40f3d0030e6e98bcb02d6523e5ee48497dec49a6 (diff)
Update upstream source from tag 'upstream/6.9.3'
Update to upstream version '6.9.3' with Debian dir 0b54db06b48ebf22a6090f21e4dcc045a1085e11
Diffstat (limited to 'sample')
-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/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
11 files changed, 61 insertions, 165 deletions
diff --git a/sample/bug_fix.c b/sample/bug_fix.c
index 81c2784..3f60c5b 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\211)a", "\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/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;
}