summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2021-04-26 17:40:21 +0200
committerJörg Frings-Fürst <debian@jff.email>2021-04-26 17:40:21 +0200
commitd3a83c35311ec631a46b59b66c38ef8d3a2a629a (patch)
tree28fc4dd524fa29f712020b61e565ab47b1fefd8e /test
parent77a04959299aa252579a98655e626d1b8f5f9f34 (diff)
parent98f7065a3f7b386564840bb5b24b94f9335b2e97 (diff)
Update upstream source from tag 'upstream/6.9.7.1'
Update to upstream version '6.9.7.1' with Debian dir c2c92e088b7e91033d7f5bee51ac7827148eaf4b
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am12
-rw-r--r--test/test_back.c9
-rw-r--r--test/test_options.c224
-rw-r--r--test/test_syntax.c77
-rw-r--r--test/test_utf8.c168
-rw-r--r--test/testc.c3
-rw-r--r--test/testp.c3
7 files changed, 454 insertions, 42 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index f12eebe..36f8dbe 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,14 +1,14 @@
## Makefile.am for Oniguruma
lib_onig = ../src/libonig.la
-AM_LDFLAGS = -L$(prefix)/lib
+AM_LDFLAGS = -L$(libdir)
AM_CFLAGS = -Wall -Wno-invalid-source-encoding
AM_CPPFLAGS = -I$(top_srcdir)/src
if ENABLE_POSIX_API
-TESTS = test_utf8 test_syntax testc testp testcu test_regset test_back
+TESTS = test_utf8 test_syntax test_options testc testp testcu test_regset test_back
else
-TESTS = test_utf8 test_syntax testc testcu test_regset test_back
+TESTS = test_utf8 test_syntax test_options testc testcu test_regset test_back
endif
check_PROGRAMS = $(TESTS)
@@ -18,6 +18,8 @@ test: test_uchar $(TESTS)
@./test_utf8 | grep RESULT
@echo "[Oniguruma API, SYNTAX check]"
@./test_syntax | grep RESULT
+ @echo "[Oniguruma API, Options check]"
+ @./test_options | grep RESULT
@echo "[Oniguruma API, EUC-JP check]"
@./testc | grep RESULT
if ENABLE_POSIX_API
@@ -43,6 +45,9 @@ test_utf8_LDADD = $(lib_onig)
test_syntax_SOURCES = test_syntax.c
test_syntax_LDADD = $(lib_onig)
+test_options_SOURCES = test_options.c
+test_options_LDADD = $(lib_onig)
+
testc_SOURCES = testc.c
testc_LDADD = $(lib_onig)
@@ -62,6 +67,7 @@ test_back_LDADD = $(lib_onig)
gcov:
make CFLAGS="--coverage" test_utf8
make CFLAGS="--coverage" test_syntax
+ make CFLAGS="--coverage" test_options
make CFLAGS="--coverage" testc
if ENABLE_POSIX_API
make CFLAGS="--coverage" testp
diff --git a/test/test_back.c b/test/test_back.c
index 6bf5159..9a6e4a8 100644
--- a/test/test_back.c
+++ b/test/test_back.c
@@ -1,8 +1,7 @@
/*
* test_back.c
- * Copyright (c) 2020 K.Kosako
+ * Copyright (c) 2020-2021 K.Kosako
*/
-#include "config.h"
#ifdef ONIG_ESCAPE_UCHAR_COLLISION
#undef ONIG_ESCAPE_UCHAR_COLLISION
#endif
@@ -141,7 +140,7 @@ static void xe(char* pattern, char* str, int error_no, int line_no)
#define x2(p,s,f,t) xx2(p,s,f,t, __LINE__)
#define x3(p,s,f,t,m) xx3(p,s,f,t,m, __LINE__)
#define n(p,s) xn(p,s, __LINE__)
-#define e(p,s,e) xe(p,s,e, __LINE__)
+#define e(p,s,en) xe(p,s,en, __LINE__)
extern int main(int argc, char* argv[])
{
@@ -1331,10 +1330,10 @@ extern int main(int argc, char* argv[])
x2("(?<!v|^t|^a+.*[efg])z", "uabcdfz", 6, 7);
x2("((?(a)\\g<1>|b))", "aab", 2, 3);
- x2("((?(a)\\g<1>))", "aab", 1, 2);
+ x2("((?(a)\\g<1>))", "aab", 3, 3);
x2("(b(?(a)|\\g<1>))", "bba", 1, 3);
e("(()(?(2)\\g<1>))", "", ONIGERR_NEVER_ENDING_RECURSION);
- x2("(?(a)(?:b|c))", "ac", 0, 2);
+ x2("(?(a)(?:b|c))", "ac", 2, 2);
n("^(?(a)b|c)", "ac");
x2("(?i)a|b", "B", 0, 1);
n("((?i)a|b.)|c", "C");
diff --git a/test/test_options.c b/test/test_options.c
new file mode 100644
index 0000000..7010f0f
--- /dev/null
+++ b/test/test_options.c
@@ -0,0 +1,224 @@
+/*
+ * test_options.c
+ * Copyright (c) 2020-2021 K.Kosako
+ */
+#ifdef ONIG_ESCAPE_UCHAR_COLLISION
+#undef ONIG_ESCAPE_UCHAR_COLLISION
+#endif
+#include <stdio.h>
+
+#include "oniguruma.h"
+
+#include <string.h>
+
+#define SLEN(s) strlen(s)
+
+static int nsucc = 0;
+static int nfail = 0;
+static int nerror = 0;
+
+#ifdef __TRUSTINSOFT_ANALYZER__
+static int nall = 0;
+#endif
+
+static FILE* err_file;
+
+static OnigRegion* region;
+
+static void xx(OnigOptionType options, char* pattern, char* str,
+ int from, int to, int mem, int not, int error_no, int line_no)
+{
+#ifdef __TRUSTINSOFT_ANALYZER__
+ if (nall++ % TIS_TEST_CHOOSE_MAX != TIS_TEST_CHOOSE_CURRENT) return;
+#endif
+
+ int r;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+
+ r = onig_new(&reg, (UChar* )pattern, (UChar* )(pattern + SLEN(pattern)),
+ options, ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo);
+ if (r) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+
+ if (error_no == 0) {
+ onig_error_code_to_str((UChar* )s, r, &einfo);
+ fprintf(err_file, "ERROR: %s /%s/ #%d\n", s, pattern, line_no);
+ nerror++;
+ }
+ else {
+ if (r == error_no) {
+ fprintf(stdout, "OK(ERROR): /%s/ %d #%d\n", pattern, r, line_no);
+ nsucc++;
+ }
+ else {
+ fprintf(stdout, "FAIL(ERROR): /%s/ '%s', %d, %d #%d\n", pattern, str,
+ error_no, r, line_no);
+ nfail++;
+ }
+ }
+
+ return ;
+ }
+
+ r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)),
+ (UChar* )str, (UChar* )(str + SLEN(str)),
+ region, options);
+ if (r < ONIG_MISMATCH) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+
+ if (error_no == 0) {
+ onig_error_code_to_str((UChar* )s, r);
+ fprintf(err_file, "ERROR: %s /%s/ #%d\n", s, pattern, line_no);
+ nerror++;
+ }
+ else {
+ if (r == error_no) {
+ fprintf(stdout, "OK(ERROR): /%s/ '%s', %d #%d\n",
+ pattern, str, r, line_no);
+ nsucc++;
+ }
+ else {
+ fprintf(stdout, "FAIL ERROR NO: /%s/ '%s', %d, %d #%d\n",
+ pattern, str, error_no, r, line_no);
+ nfail++;
+ }
+ }
+
+ return ;
+ }
+
+ if (r == ONIG_MISMATCH) {
+ if (not) {
+ fprintf(stdout, "OK(N): /%s/ '%s' #%d\n", pattern, str, line_no);
+ nsucc++;
+ }
+ else {
+ fprintf(stdout, "FAIL: /%s/ '%s' #%d\n", pattern, str, line_no);
+ nfail++;
+ }
+ }
+ else {
+ if (not) {
+ fprintf(stdout, "FAIL(N): /%s/ '%s' #%d\n", pattern, str, line_no);
+ nfail++;
+ }
+ else {
+ if (region->beg[mem] == from && region->end[mem] == to) {
+ fprintf(stdout, "OK: /%s/ '%s' #%d\n", pattern, str, line_no);
+ nsucc++;
+ }
+ else {
+ fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d #%d\n", pattern, str,
+ from, to, region->beg[mem], region->end[mem], line_no);
+ nfail++;
+ }
+ }
+ }
+ onig_free(reg);
+}
+
+static void xx2(OnigOptionType options, char* pattern, char* str,
+ int from, int to, int line_no)
+{
+ xx(options, pattern, str, from, to, 0, 0, 0, line_no);
+}
+
+static void xx3(OnigOptionType options, char* pattern, char* str,
+ int from, int to, int mem, int line_no)
+{
+ xx(options, pattern, str, from, to, mem, 0, 0, line_no);
+}
+
+static void xn(OnigOptionType options, char* pattern, char* str, int line_no)
+{
+ xx(options, pattern, str, 0, 0, 0, 1, 0, line_no);
+}
+
+#if 0
+static void xe(OnigOptionType options, char* pattern, char* str,
+ int error_no, int line_no)
+{
+ xx(options, pattern, str, 0, 0, 0, 0, error_no, line_no);
+}
+#endif
+
+#define x2(o,p,s,f,t) xx2(o,p,s,f,t, __LINE__)
+#define x3(o,p,s,f,t,m) xx3(o,p,s,f,t,m, __LINE__)
+#define n(o,p,s) xn(o,p,s, __LINE__)
+#define e(o,p,s,en) xe(o,p,s,en, __LINE__)
+
+#define OIA (ONIG_OPTION_IGNORECASE | ONIG_OPTION_IGNORECASE_IS_ASCII)
+
+extern int main(int argc, char* argv[])
+{
+ OnigEncoding use_encs[1];
+
+ use_encs[0] = ONIG_ENCODING_UTF8;
+ onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0]));
+
+ err_file = stdout;
+
+ region = onig_region_new();
+
+ x2(ONIG_OPTION_IGNORECASE, "a", "A", 0, 1);
+ n(ONIG_OPTION_IGNORECASE_IS_ASCII, "a", "A");
+ /* KELVIN SIGN */
+ x2(ONIG_OPTION_IGNORECASE, "\xe2\x84\xaa", "k", 0, 1);
+ x2(ONIG_OPTION_IGNORECASE, "k", "\xe2\x84\xaa", 0, 3);
+ n(OIA, "\xe2\x84\xaa", "k");
+ n(OIA, "k", "\xe2\x84\xaa");
+ x2(OIA, "a", "a", 0, 1);
+ x2(OIA, "A", "A", 0, 1);
+ x2(OIA, "a", "A", 0, 1);
+ x2(OIA, "A", "a", 0, 1);
+ x2(OIA, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", 0, 26);
+ x2(OIA, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 26);
+ x2(OIA, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCabcdefghijklmnopqrstuvwxyz", 3, 29);
+ x2(OIA, "abcdefghijklmnopqrstuvwxyz", "abcABCDEFGHIJKLMNOPQRSTUVWXYZ", 3, 29);
+ x3(OIA, "#%(a!;)(b&)", "#%A!;B&", 5, 7, 2);
+
+ x2(ONIG_OPTION_IGNORECASE, "ss", "\xc3\x9f", 0, 2);
+ x2(ONIG_OPTION_IGNORECASE, "\xc3\x9f", "SS", 0, 2);
+ n(OIA, "ss", "\xc3\x9f");
+ n(OIA, "\xc3\x9f", "ss");
+ x2(OIA, "ss", "SS", 0, 2);
+ x2(OIA, "Ss", "sS", 0, 2);
+
+ n(ONIG_OPTION_NOTBOL, "^ab", "ab");
+ n(ONIG_OPTION_NOTBOL, "\\Aab", "ab");
+ n(ONIG_OPTION_NOTEOL, "ab$", "ab");
+ n(ONIG_OPTION_NOTEOL, "ab\\z", "ab");
+ n(ONIG_OPTION_NOTEOL, "ab\\Z", "ab");
+ n(ONIG_OPTION_NOTEOL, "ab\\Z", "ab\n");
+
+ n(ONIG_OPTION_NOT_BEGIN_STRING, "\\Aab", "ab");
+ n(ONIG_OPTION_NOT_END_STRING, "ab\\z", "ab");
+ n(ONIG_OPTION_NOT_END_STRING, "ab\\Z", "ab");
+ n(ONIG_OPTION_NOT_END_STRING, "ab\\Z", "ab\n");
+
+ x2(ONIG_OPTION_WORD_IS_ASCII, "\\w", "@g", 1, 2);
+ n(ONIG_OPTION_WORD_IS_ASCII, "\\w", "あ");
+ x2(ONIG_OPTION_NONE, "\\d", "1", 0, 3);
+ n(ONIG_OPTION_DIGIT_IS_ASCII, "\\d", "1");
+ x2(ONIG_OPTION_SPACE_IS_ASCII, "\\s", " ", 0, 1);
+ x2(ONIG_OPTION_NONE, "\\s", " ", 0, 3);
+ n(ONIG_OPTION_SPACE_IS_ASCII, "\\s", " ");
+
+ x2(ONIG_OPTION_POSIX_IS_ASCII, "\\w\\d\\s", "c3 ", 0, 3);
+ n(ONIG_OPTION_POSIX_IS_ASCII, "\\w|\\d|\\s", "あ4 ");
+
+ x2(ONIG_OPTION_EXTEND, " abc \n def", "abcdef", 0, 6);
+ x2(ONIG_OPTION_FIND_LONGEST, "\\w+", "abc defg hij", 4, 8);
+ x2(ONIG_OPTION_FIND_NOT_EMPTY, "\\w*", "@@@ abc defg hij", 4, 7);
+
+
+ fprintf(stdout,
+ "\nRESULT SUCC: %4d, FAIL: %d, ERROR: %d (by Oniguruma %s)\n",
+ nsucc, nfail, nerror, onig_version());
+
+ onig_region_free(region, 1);
+ onig_end();
+
+ return ((nfail == 0 && nerror == 0) ? 0 : -1);
+}
diff --git a/test/test_syntax.c b/test/test_syntax.c
index 06fef45..b501ccd 100644
--- a/test/test_syntax.c
+++ b/test/test_syntax.c
@@ -1,8 +1,7 @@
/*
* test_syntax.c
- * Copyright (c) 2019-2020 K.Kosako
+ * Copyright (c) 2019-2021 K.Kosako
*/
-#include "config.h"
#ifdef ONIG_ESCAPE_UCHAR_COLLISION
#undef ONIG_ESCAPE_UCHAR_COLLISION
#endif
@@ -139,7 +138,7 @@ static void e(char* pattern, char* str, int error_no)
xx(pattern, str, 0, 0, 0, 0, error_no);
}
-static int test_fixed_interval()
+static int test_reluctant_interval()
{
x2("a{1,3}?", "aaa", 0, 1);
x2("a{3}", "aaa", 0, 3);
@@ -148,6 +147,11 @@ static int test_fixed_interval()
x2("a{3,3}?", "aaa", 0, 3);
n("a{3,3}?", "aa");
+ return 0;
+}
+
+static int test_possessive_interval()
+{
x2("a{1,3}+", "aaaaaa", 0, 3);
x2("a{3}+", "aaaaaa", 0, 3);
x2("a{3,3}+", "aaaaaa", 0, 3);
@@ -209,6 +213,52 @@ static int test_look_behind()
return 0;
}
+static int test_python_option_ascii()
+{
+ x2("(?a)\\w", "a", 0, 1);
+ x2("\\w", "あ", 0, 3);
+ n("(?a)\\w", "あ");
+ x2("\\s", " ", 0, 3);
+ n("(?a)\\s", " ");
+ x2("\\d", "5", 0, 3);
+ n("(?a)\\d", "5");
+ x2("あ\\b ", "あ ", 0, 4);
+ n("(?a)あ\\b ", "あ ");
+ n("あ\\B ", "あ ");
+ x2("(?a)あ\\B ", "あ ", 0, 4);
+ x2("(?a)\\W", "あ", 0, 3);
+ n("\\W", "あ");
+ x2("(?a)\\S", " ", 0, 3);
+ n("\\S", " ");
+ x2("(?a)\\D", "5", 0, 3);
+ n("\\D", "5");
+
+ return 0;
+}
+
+static int test_python_z()
+{
+ x2("a\\Z", "a", 0, 1);
+ n("a\\Z", "a\n");
+ e("\\z", "a", ONIGERR_UNDEFINED_OPERATOR);
+
+ return 0;
+}
+
+static int test_python_single_multi()
+{
+ n(".", "\n");
+ x2("(?s).", "\n", 0, 1);
+
+ n("^abc", "\nabc");
+ x2("(?m)^abc", "\nabc", 1, 4);
+ n("abc$", "abc\ndef");
+ x2("abc$", "abc\n", 0, 3);
+ x2("(?m)abc$", "abc\ndef", 0, 3);
+
+ return 0;
+}
+
extern int main(int argc, char* argv[])
{
OnigEncoding use_encs[1];
@@ -222,7 +272,8 @@ extern int main(int argc, char* argv[])
Syntax = ONIG_SYNTAX_PERL;
- test_fixed_interval();
+ test_reluctant_interval();
+ test_possessive_interval();
test_isolated_option();
test_prec_read();
test_look_behind();
@@ -235,7 +286,8 @@ extern int main(int argc, char* argv[])
Syntax = ONIG_SYNTAX_JAVA;
- test_fixed_interval();
+ test_reluctant_interval();
+ test_possessive_interval();
test_isolated_option();
test_prec_read();
test_look_behind();
@@ -243,6 +295,21 @@ extern int main(int argc, char* argv[])
n("(?<!ab|b)c", "bbc");
n("(?<!b|ab)c", "bbc");
+ Syntax = ONIG_SYNTAX_PYTHON;
+
+ test_reluctant_interval();
+ test_python_option_ascii();
+ test_python_z();
+ test_python_single_multi();
+ x2("(?P<name>abc)", "abc", 0, 3);
+ x2("(?P<name>abc)(?P=name)", "abcabc", 0, 6);
+ x2("(?P<name>abc){0}(?P>name)", "abc", 0, 3);
+ x2("(?P<expr>[^()]+|\\((?P>expr)\\)){0}(?P>expr)", "((((xyz))))", 0, 11);
+ x2("\\u0041", "A", 0, 1);
+ x2("\\U00000041", "A", 0, 1);
+ e("\\U0041", "A", ONIGERR_INVALID_CODE_POINT_VALUE);
+
+
fprintf(stdout,
"\nRESULT SUCC: %4d, FAIL: %d, ERROR: %d (by Oniguruma %s)\n",
nsucc, nfail, nerror, onig_version());
diff --git a/test/test_utf8.c b/test/test_utf8.c
index 7a4322d..9822308 100644
--- a/test/test_utf8.c
+++ b/test/test_utf8.c
@@ -1,8 +1,7 @@
/*
* test_utf8.c
- * Copyright (c) 2019-2020 K.Kosako
+ * Copyright (c) 2019-2021 K.Kosako
*/
-#include "config.h"
#ifdef ONIG_ESCAPE_UCHAR_COLLISION
#undef ONIG_ESCAPE_UCHAR_COLLISION
#endif
@@ -27,7 +26,7 @@ static FILE* err_file;
static OnigRegion* region;
static void xx(char* pattern, char* str, int from, int to, int mem, int not,
- int error_no)
+ int error_no, int line_no)
{
#ifdef __TRUSTINSOFT_ANALYZER__
if (nall++ % TIS_TEST_CHOOSE_MAX != TIS_TEST_CHOOSE_CURRENT) return;
@@ -44,17 +43,17 @@ static void xx(char* pattern, char* str, int from, int to, int mem, int not,
if (error_no == 0) {
onig_error_code_to_str((UChar* )s, r, &einfo);
- fprintf(err_file, "ERROR: %s /%s/\n", s, pattern);
+ fprintf(err_file, "ERROR: %s /%s/ #%d\n", s, pattern, line_no);
nerror++;
}
else {
if (r == error_no) {
- fprintf(stdout, "OK(ERROR): /%s/ %d\n", pattern, r);
+ fprintf(stdout, "OK(ERROR): /%s/ %d #%d\n", pattern, r, line_no);
nsucc++;
}
else {
- fprintf(stdout, "FAIL(ERROR): /%s/ '%s', %d, %d\n", pattern, str,
- error_no, r);
+ fprintf(stdout, "FAIL(ERROR): /%s/ '%s', %d, %d #%d\n", pattern, str,
+ error_no, r, line_no);
nfail++;
}
}
@@ -70,17 +69,18 @@ static void xx(char* pattern, char* str, int from, int to, int mem, int not,
if (error_no == 0) {
onig_error_code_to_str((UChar* )s, r);
- fprintf(err_file, "ERROR: %s /%s/\n", s, pattern);
+ fprintf(err_file, "ERROR: %s /%s/ #%d\n", s, pattern, line_no);
nerror++;
}
else {
if (r == error_no) {
- fprintf(stdout, "OK(ERROR): /%s/ '%s', %d\n", pattern, str, r);
+ fprintf(stdout, "OK(ERROR): /%s/ '%s', %d #%d\n",
+ pattern, str, r, line_no);
nsucc++;
}
else {
- fprintf(stdout, "FAIL ERROR NO: /%s/ '%s', %d, %d\n", pattern, str,
- error_no, r);
+ fprintf(stdout, "FAIL ERROR NO: /%s/ '%s', %d, %d #%d\n",
+ pattern, str, error_no, r, line_no);
nfail++;
}
}
@@ -90,27 +90,27 @@ static void xx(char* pattern, char* str, int from, int to, int mem, int not,
if (r == ONIG_MISMATCH) {
if (not) {
- fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str);
+ fprintf(stdout, "OK(N): /%s/ '%s' #%d\n", pattern, str, line_no);
nsucc++;
}
else {
- fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str);
+ fprintf(stdout, "FAIL: /%s/ '%s' #%d\n", pattern, str, line_no);
nfail++;
}
}
else {
if (not) {
- fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str);
+ fprintf(stdout, "FAIL(N): /%s/ '%s' #%d\n", pattern, str, line_no);
nfail++;
}
else {
if (region->beg[mem] == from && region->end[mem] == to) {
- fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str);
+ fprintf(stdout, "OK: /%s/ '%s' #%d\n", pattern, str, line_no);
nsucc++;
}
else {
- fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str,
- from, to, region->beg[mem], region->end[mem]);
+ fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d #%d\n", pattern, str,
+ from, to, region->beg[mem], region->end[mem], line_no);
nfail++;
}
}
@@ -118,26 +118,31 @@ static void xx(char* pattern, char* str, int from, int to, int mem, int not,
onig_free(reg);
}
-static void x2(char* pattern, char* str, int from, int to)
+static void xx2(char* pattern, char* str, int from, int to, int line_no)
{
- xx(pattern, str, from, to, 0, 0, 0);
+ xx(pattern, str, from, to, 0, 0, 0, line_no);
}
-static void x3(char* pattern, char* str, int from, int to, int mem)
+static void xx3(char* pattern, char* str, int from, int to, int mem, int line_no)
{
- xx(pattern, str, from, to, mem, 0, 0);
+ xx(pattern, str, from, to, mem, 0, 0, line_no);
}
-static void n(char* pattern, char* str)
+static void xn(char* pattern, char* str, int line_no)
{
- xx(pattern, str, 0, 0, 0, 1, 0);
+ xx(pattern, str, 0, 0, 0, 1, 0, line_no);
}
-static void e(char* pattern, char* str, int error_no)
+static void xe(char* pattern, char* str, int error_no, int line_no)
{
- xx(pattern, str, 0, 0, 0, 0, error_no);
+ xx(pattern, str, 0, 0, 0, 0, error_no, line_no);
}
+#define x2(p,s,f,t) xx2(p,s,f,t, __LINE__)
+#define x3(p,s,f,t,m) xx3(p,s,f,t,m, __LINE__)
+#define n(p,s) xn(p,s, __LINE__)
+#define e(p,s,en) xe(p,s,en, __LINE__)
+
extern int main(int argc, char* argv[])
{
OnigEncoding use_encs[1];
@@ -359,6 +364,114 @@ extern int main(int argc, char* argv[])
x2("(.*)a\\1f", "bacbabf", 3, 7);
x2("((.*)a\\2f)", "bacbabf", 3, 7);
x2("(.*)a\\1f", "baczzzzzz\nbazz\nzzzzbabf", 19, 23);
+ x2("(?:x?)?", "", 0, 0);
+ x2("(?:x?)?", "x", 0, 1);
+ x2("(?:x?)?", "xx", 0, 1);
+ x2("(?:x?)*", "", 0, 0);
+ x2("(?:x?)*", "x", 0, 1);
+ x2("(?:x?)*", "xx", 0, 2);
+ x2("(?:x?)+", "", 0, 0);
+ x2("(?:x?)+", "x", 0, 1);
+ x2("(?:x?)+", "xx", 0, 2);
+ x2("(?:x?)\?\?", "", 0, 0);
+ x2("(?:x?)\?\?", "x", 0, 0);
+ x2("(?:x?)\?\?", "xx", 0, 0);
+ x2("(?:x?)*?", "", 0, 0);
+ x2("(?:x?)*?", "x", 0, 0);
+ x2("(?:x?)*?", "xx", 0, 0);
+ x2("(?:x?)+?", "", 0, 0);
+ x2("(?:x?)+?", "x", 0, 1);
+ x2("(?:x?)+?", "xx", 0, 1);
+ x2("(?:x*)?", "", 0, 0);
+ x2("(?:x*)?", "x", 0, 1);
+ x2("(?:x*)?", "xx", 0, 2);
+ x2("(?:x*)*", "", 0, 0);
+ x2("(?:x*)*", "x", 0, 1);
+ x2("(?:x*)*", "xx", 0, 2);
+ x2("(?:x*)+", "", 0, 0);
+ x2("(?:x*)+", "x", 0, 1);
+ x2("(?:x*)+", "xx", 0, 2);
+ x2("(?:x*)\?\?", "", 0, 0);
+ x2("(?:x*)\?\?", "x", 0, 0);
+ x2("(?:x*)\?\?", "xx", 0, 0);
+ x2("(?:x*)*?", "", 0, 0);
+ x2("(?:x*)*?", "x", 0, 0);
+ x2("(?:x*)*?", "xx", 0, 0);
+ x2("(?:x*)+?", "", 0, 0);
+ x2("(?:x*)+?", "x", 0, 1);
+ x2("(?:x*)+?", "xx", 0, 2);
+ x2("(?:x+)?", "", 0, 0);
+ x2("(?:x+)?", "x", 0, 1);
+ x2("(?:x+)?", "xx", 0, 2);
+ x2("(?:x+)*", "", 0, 0);
+ x2("(?:x+)*", "x", 0, 1);
+ x2("(?:x+)*", "xx", 0, 2);
+ n("(?:x+)+", "");
+ x2("(?:x+)+", "x", 0, 1);
+ x2("(?:x+)+", "xx", 0, 2);
+ x2("(?:x+)\?\?", "", 0, 0);
+ x2("(?:x+)\?\?", "x", 0, 0);
+ x2("(?:x+)\?\?", "xx", 0, 0);
+ x2("(?:x+)*?", "", 0, 0);
+ x2("(?:x+)*?", "x", 0, 0);
+ x2("(?:x+)*?", "xx", 0, 0);
+ n("(?:x+)+?", "");
+ x2("(?:x+)+?", "x", 0, 1);
+ x2("(?:x+)+?", "xx", 0, 2);
+ x2("(?:x\?\?)?", "", 0, 0);
+ x2("(?:x\?\?)?", "x", 0, 0);
+ x2("(?:x\?\?)?", "xx", 0, 0);
+ x2("(?:x\?\?)*", "", 0, 0);
+ x2("(?:x\?\?)*", "x", 0, 0);
+ x2("(?:x\?\?)*", "xx", 0, 0);
+ x2("(?:x\?\?)+", "", 0, 0);
+ x2("(?:x\?\?)+", "x", 0, 0);
+ x2("(?:x\?\?)+", "xx", 0, 0);
+ x2("(?:x\?\?)\?\?", "", 0, 0);
+ x2("(?:x\?\?)\?\?", "x", 0, 0);
+ x2("(?:x\?\?)\?\?", "xx", 0, 0);
+ x2("(?:x\?\?)*?", "", 0, 0);
+ x2("(?:x\?\?)*?", "x", 0, 0);
+ x2("(?:x\?\?)*?", "xx", 0, 0);
+ x2("(?:x\?\?)+?", "", 0, 0);
+ x2("(?:x\?\?)+?", "x", 0, 0);
+ x2("(?:x\?\?)+?", "xx", 0, 0);
+ x2("(?:x*?)?", "", 0, 0);
+ x2("(?:x*?)?", "x", 0, 0);
+ x2("(?:x*?)?", "xx", 0, 0);
+ x2("(?:x*?)*", "", 0, 0);
+ x2("(?:x*?)*", "x", 0, 0);
+ x2("(?:x*?)*", "xx", 0, 0);
+ x2("(?:x*?)+", "", 0, 0);
+ x2("(?:x*?)+", "x", 0, 0);
+ x2("(?:x*?)+", "xx", 0, 0);
+ x2("(?:x*?)\?\?", "", 0, 0);
+ x2("(?:x*?)\?\?", "x", 0, 0);
+ x2("(?:x*?)\?\?", "xx", 0, 0);
+ x2("(?:x*?)*?", "", 0, 0);
+ x2("(?:x*?)*?", "x", 0, 0);
+ x2("(?:x*?)*?", "xx", 0, 0);
+ x2("(?:x*?)+?", "", 0, 0);
+ x2("(?:x*?)+?", "x", 0, 0);
+ x2("(?:x*?)+?", "xx", 0, 0);
+ x2("(?:x+?)?", "", 0, 0);
+ x2("(?:x+?)?", "x", 0, 1);
+ x2("(?:x+?)?", "xx", 0, 1);
+ x2("(?:x+?)*", "", 0, 0);
+ x2("(?:x+?)*", "x", 0, 1);
+ x2("(?:x+?)*", "xx", 0, 2);
+ n("(?:x+?)+", "");
+ x2("(?:x+?)+", "x", 0, 1);
+ x2("(?:x+?)+", "xx", 0, 2);
+ x2("(?:x+?)\?\?", "", 0, 0);
+ x2("(?:x+?)\?\?", "x", 0, 0);
+ x2("(?:x+?)\?\?", "xx", 0, 0);
+ x2("(?:x+?)*?", "", 0, 0);
+ x2("(?:x+?)*?", "x", 0, 0);
+ x2("(?:x+?)*?", "xx", 0, 0);
+ n("(?:x+?)+?", "");
+ x2("(?:x+?)+?", "x", 0, 1);
+ x2("(?:x+?)+?", "xx", 0, 1);
x2("a|b", "a", 0, 1);
x2("a|b", "b", 0, 1);
x2("|a", "a", 0, 0);
@@ -1348,9 +1461,12 @@ extern int main(int argc, char* argv[])
x2("((?(a)\\g<1>|b))", "aab", 0, 3);
x2("((?(a)\\g<1>))", "aab", 0, 2);
+ x2("((?(a)\\g<1>))", "", 0, 0);
x2("(b(?(a)|\\g<1>))", "bba", 0, 3);
e("(()(?(2)\\g<1>))", "", ONIGERR_NEVER_ENDING_RECURSION);
x2("(?(a)(?:b|c))", "ac", 0, 2);
+ x2("(?(a)(?:b|c))", "", 0, 0);
+ x2("(?(a)b)", "", 0, 0);
n("^(?(a)b|c)", "ac");
x2("(?i)a|b", "B", 0, 1);
n("((?i)a|b.)|c", "C");
@@ -1479,6 +1595,7 @@ extern int main(int argc, char* argv[])
e("[\\x61-\\x{0063-0065}]+", "", ONIGERR_INVALID_CODE_POINT_VALUE);
x2("[t\\x{0063 0071}]+", "tcqb", 0, 3);
x2("[\\W\\x{0063 0071}]+", "*cqa", 0, 3);
+ x2("(\\O|(?=z\\g<2>*))(\\g<0>){0}", "a", 0, 1);
n("a(b|)+d", "abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcd"); /* https://www.haijin-boys.com/discussions/5079 */
n(" \xfd", ""); /* https://bugs.php.net/bug.php?id=77370 */
@@ -1491,6 +1608,7 @@ extern int main(int argc, char* argv[])
n("(?x)\n (?<!\\+\\+|--)(?<=[({\\[,?=>:*]|&&|\\|\\||\\?|\\*\\/|^await|[^\\._$[:alnum:]]await|^return|[^\\._$[:alnum:]]return|^default|[^\\._$[:alnum:]]default|^yield|[^\\._$[:alnum:]]yield|^)\\s*\n (?!<\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=>])|,)) # look ahead is not type parameter of arrow\n (?=(<)\\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?<!\\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?<!\\.|-))(?=((<\\s*)|(\\s+))(?!\\?)|\\/?>))", " while (i < len && f(array[i]))"); /* Issue #192 */
x2("aaaaaaaaaaaaaaaaaaaaaaaあb", "aaaaaaaaaaaaaaaaaaaaaaaあb", 0, 27); /* Issue #221 */
+ n("d{65538}+{61533} ", "d{65538}+{61533} ");
e("x{55380}{77590}", "", ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE);
e("(xyz){40000}{99999}(?<name>vv)", "", ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE);
diff --git a/test/testc.c b/test/testc.c
index b3a34ea..5f7c4f0 100644
--- a/test/testc.c
+++ b/test/testc.c
@@ -1,8 +1,7 @@
/*
* testc.c
- * Copyright (c) 2019-2020 K.Kosako
+ * Copyright (c) 2019-2021 K.Kosako
*/
-#include "config.h"
#include <stdio.h>
#include <string.h>
diff --git a/test/testp.c b/test/testp.c
index b88d0e3..3158925 100644
--- a/test/testp.c
+++ b/test/testp.c
@@ -1,8 +1,7 @@
/*
* testp.c
- * Copyright (c) 2020 K.Kosako
+ * Copyright (c) 2020-2021 K.Kosako
*/
-#include "config.h"
#include <stdio.h>
#include <string.h>