summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_back.c10
-rw-r--r--test/test_regset.c11
-rw-r--r--test/test_syntax.c8
-rw-r--r--test/test_utf8.c35
-rw-r--r--test/testc.c8
-rw-r--r--test/testu.c14
6 files changed, 79 insertions, 7 deletions
diff --git a/test/test_back.c b/test/test_back.c
index 9a337b9..6bf5159 100644
--- a/test/test_back.c
+++ b/test/test_back.c
@@ -18,6 +18,10 @@ 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;
@@ -25,6 +29,10 @@ static OnigRegion* region;
static void xx(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;
@@ -1419,7 +1427,7 @@ extern int main(int argc, char* argv[])
x2("\\p{Common}", "\xe3\x8b\xbf", 0, 3); /* U+32FF */
x2("\\p{In_Enclosed_CJK_Letters_and_Months}", "\xe3\x8b\xbf", 0, 3); /* U+32FF */
- e("\\x{7fffffff}", "", ONIGERR_TOO_BIG_WIDE_CHAR_VALUE);
+ e("\\x{7fffffff}", "", ONIGERR_INVALID_CODE_POINT_VALUE);
e("[\\x{7fffffff}]", "", ONIGERR_INVALID_CODE_POINT_VALUE);
e("\\u040", "@", ONIGERR_INVALID_CODE_POINT_VALUE);
e("(?<abc>\\g<abc>)", "zzzz", ONIGERR_NEVER_ENDING_RECURSION);
diff --git a/test/test_regset.c b/test/test_regset.c
index c8442a1..7476ec4 100644
--- a/test/test_regset.c
+++ b/test/test_regset.c
@@ -50,6 +50,7 @@ make_regset(int line_no, int n, char* pat[], OnigRegSet** rset, int error_no)
nfail++;
}
}
+ onig_regset_free(set);
return r;
}
@@ -96,6 +97,7 @@ time_test(int repeat, int n, char* ps[], char* s, char* end, double* rt_set, dou
ONIG_REGSET_POSITION_LEAD, ONIG_OPTION_NONE, &match_pos);
if (r < 0) {
fprintf(stderr, "FAIL onig_regset_search(POSITION_LEAD): %d\n", r);
+ onig_regset_free(set);
return r;
}
}
@@ -109,6 +111,7 @@ time_test(int repeat, int n, char* ps[], char* s, char* end, double* rt_set, dou
ONIG_REGSET_REGEX_LEAD, ONIG_OPTION_NONE, &match_pos);
if (r < 0) {
fprintf(stderr, "FAIL onig_regset_search(REGEX_LEAD): %d\n", r);
+ onig_regset_free(set);
return r;
}
}
@@ -158,7 +161,10 @@ time_compare(int n, char* ps[], char* s, char* end)
for (i = 0; i < n; i++) {
fisher_yates_shuffle(n, ps, cps);
r = time_test(repeat, n, cps, s, end, &t_set, &t_reg);
- if (r != 0) return ;
+ if (r != 0) {
+ free(cps);
+ return ;
+ }
total_set += t_set;
total_reg += t_reg;
}
@@ -231,6 +237,7 @@ xx(int line_no, int n, char* ps[], char* s, int from, int to, int mem, int not,
if (region == 0) {
fprintf(stderr, "ERROR: %d: can't get region.\n", line_no);
nerror++;
+ onig_regset_free(set);
return ;
}
@@ -285,7 +292,7 @@ n(int line_no, int n, char* ps[], char* s)
static int
get_all_content_of_file(char* path, char** rs, char** rend)
{
- size_t len;
+ ssize_t len;
size_t n;
char* line;
FILE* fp;
diff --git a/test/test_syntax.c b/test/test_syntax.c
index df80e59..06fef45 100644
--- a/test/test_syntax.c
+++ b/test/test_syntax.c
@@ -17,6 +17,10 @@ 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;
@@ -26,6 +30,10 @@ static OnigSyntaxType* Syntax;
static void xx(char* pattern, char* str, int from, int to, int mem, int not,
int error_no)
{
+#ifdef __TRUSTINSOFT_ANALYZER__
+ if (nall++ % TIS_TEST_CHOOSE_MAX != TIS_TEST_CHOOSE_CURRENT) return;
+#endif
+
int r;
regex_t* reg;
OnigErrorInfo einfo;
diff --git a/test/test_utf8.c b/test/test_utf8.c
index 1bbc071..7a4322d 100644
--- a/test/test_utf8.c
+++ b/test/test_utf8.c
@@ -18,6 +18,10 @@ 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;
@@ -25,6 +29,10 @@ static OnigRegion* region;
static void xx(char* pattern, char* str, int from, int to, int mem, int not,
int error_no)
{
+#ifdef __TRUSTINSOFT_ANALYZER__
+ if (nall++ % TIS_TEST_CHOOSE_MAX != TIS_TEST_CHOOSE_CURRENT) return;
+#endif
+
int r;
regex_t* reg;
OnigErrorInfo einfo;
@@ -545,6 +553,17 @@ extern int main(int argc, char* argv[])
x2("(?<=a|bc||defghij|klmnopq|r)z", "rz", 1, 2);
x3("(?<=(abc))d", "abcd", 0, 3, 1);
x2("(?<=(?i:abc))d", "ABCd", 3, 4);
+ x2("(?<=^|b)c", " cbc", 3, 4);
+ x2("(?<=a|^|b)c", " cbc", 3, 4);
+ x2("(?<=a|(^)|b)c", " cbc", 3, 4);
+ x2("(?<=a|(^)|b)c", "cbc", 0, 1);
+ n("(Q)|(?<=a|(?(1))|b)c", "czc");
+ x2("(Q)(?<=a|(?(1))|b)c", "cQc", 1, 3);
+ x2("(?<=a|(?~END)|b)c", "ENDc", 3, 4);
+ n("(?<!^|b)c", "cbc");
+ n("(?<!a|^|b)c", "cbc");
+ n("(?<!a|(?:^)|b)c", "cbc");
+ x2("(?<!a|(?:^)|b)c", " cbc", 1, 2);
x2("(a)\\g<1>", "aa", 0, 2);
x2("(?<!a)b", "cb", 1, 2);
n("(?<!a)b", "ab");
@@ -682,6 +701,13 @@ extern int main(int argc, char* argv[])
x2("(?~)", "", 0, 0);
x2("(?~)", "A", 0, 0);
+ x2("(?~ab)", "abc", 0, 0);
+ x2("(?~abc)", "abc", 0, 0);
+ x2("(?~abc|ab)", "abc", 0, 0);
+ x2("(?~ab|abc)", "abc", 0, 0);
+ x2("(?~a.c)", "abc", 0, 0);
+ x2("(?~a.c|ab)", "abc", 0, 0);
+ x2("(?~ab|a.c)", "abc", 0, 0);
x2("aaaaa(?~)", "aaaaaaaaaa", 0, 5);
x2("(?~(?:|aaa))", "aaa", 0, 0);
x2("(?~aaa|)", "aaa", 0, 0);
@@ -1316,6 +1342,9 @@ extern int main(int argc, char* argv[])
n("(?<!v|t|^a+.*[efg])z", "abcdfz");
n("(?<!^(?:v|t|a+.*[efg]))z", "abcdfz");
x2("(?<!v|^t|^a+.*[efg])z", "uabcdfz", 6, 7);
+ n("(\\k<2>)|(?<=(\\k<1>))", "");
+ x2("(a|\\k<2>)|(?<=(\\k<1>))", "a", 0, 1);
+ x2("(a|\\k<2>)|(?<=b(\\k<1>))", "ba", 1, 2);
x2("((?(a)\\g<1>|b))", "aab", 0, 3);
x2("((?(a)\\g<1>))", "aab", 0, 2);
@@ -1459,6 +1488,10 @@ extern int main(int argc, char* argv[])
e("(?i)000000000000000000000\xf0", "", ONIGERR_INVALID_CODE_POINT_VALUE); /* https://bugs.php.net/bug.php?id=77382 */
n("0000\\\xf5", "0"); /* https://bugs.php.net/bug.php?id=77385 */
n("(?i)FFF00000000000000000\xfd", ""); /* https://bugs.php.net/bug.php?id=77394 */
+ 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 */
+
e("x{55380}{77590}", "", ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE);
e("(xyz){40000}{99999}(?<name>vv)", "", ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE);
e("f{90000,90000}{80000,80000}", "", ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE);
@@ -1467,7 +1500,7 @@ extern int main(int argc, char* argv[])
x2("\\p{Common}", "\xe3\x8b\xbf", 0, 3); /* U+32FF */
x2("\\p{In_Enclosed_CJK_Letters_and_Months}", "\xe3\x8b\xbf", 0, 3); /* U+32FF */
- e("\\x{7fffffff}", "", ONIGERR_TOO_BIG_WIDE_CHAR_VALUE);
+ e("\\x{7fffffff}", "", ONIGERR_INVALID_CODE_POINT_VALUE);
e("[\\x{7fffffff}]", "", ONIGERR_INVALID_CODE_POINT_VALUE);
e("\\u040", "@", ONIGERR_INVALID_CODE_POINT_VALUE);
e("(?<abc>\\g<abc>)", "zzzz", ONIGERR_NEVER_ENDING_RECURSION);
diff --git a/test/testc.c b/test/testc.c
index fbede67..b3a34ea 100644
--- a/test/testc.c
+++ b/test/testc.c
@@ -14,11 +14,19 @@ 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(char* pattern, char* str, int from, int to, int mem, int not)
{
+#ifdef __TRUSTINSOFT_ANALYZER__
+ if (nall++ % TIS_TEST_CHOOSE_MAX != TIS_TEST_CHOOSE_CURRENT) return;
+#endif
+
int r;
regex_t* reg;
OnigErrorInfo einfo;
diff --git a/test/testu.c b/test/testu.c
index 24397ab..c1971e7 100644
--- a/test/testu.c
+++ b/test/testu.c
@@ -14,6 +14,10 @@ static int nsucc = 0;
static int nfail = 0;
static int nerror = 0;
+#ifdef __TRUSTINSOFT_ANALYZER__
+static int nall = 0;
+#endif
+
static FILE* err_file;
#ifndef POSIX_TEST
@@ -36,7 +40,7 @@ static void uconv(char* from, char* to, int len)
if (c == 0) {
c = (unsigned char )from[i+1];
if (c < 0x20 || c >= 0x7f || c == 0x5c || c == 0x22) {
- sprintf(q, "\\%03o", c);
+ sprintf(q, "\\%03o", (unsigned int )c);
q += 4;
}
else {
@@ -45,10 +49,10 @@ static void uconv(char* from, char* to, int len)
}
}
else {
- sprintf(q, "\\%03o", c);
+ sprintf(q, "\\%03o", (unsigned int )c);
q += 4;
c = (unsigned char )from[i+1];
- sprintf(q, "\\%03o", c);
+ sprintf(q, "\\%03o", (unsigned int )c);
q += 4;
}
}
@@ -58,6 +62,10 @@ static void uconv(char* from, char* to, int len)
static void xx(char* pattern, char* str, int from, int to, int mem, int not)
{
+#ifdef __TRUSTINSOFT_ANALYZER__
+ if (nall++ % TIS_TEST_CHOOSE_MAX != TIS_TEST_CHOOSE_CURRENT) return;
+#endif
+
int r;
char cpat[4000], cstr[4000];