From ec9d8c8861e3c5b4659c8be46d29b4ffc3d105cc Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Tue, 2 Jul 2024 00:20:21 +0900 Subject: [PATCH] fix #305: e() function bug --- test/test_back.c | 4 ++-- test/test_options.c | 4 ++-- test/test_syntax.c | 2 +- test/test_utf8.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_back.c b/test/test_back.c index 31003903..52f2e58f 100644 --- a/test/test_back.c +++ b/test/test_back.c @@ -1,6 +1,6 @@ /* * test_back.c - * Copyright (c) 2020-2021 K.Kosako + * Copyright (c) 2020-2024 K.Kosako */ #ifdef ONIG_ESCAPE_UCHAR_COLLISION #undef ONIG_ESCAPE_UCHAR_COLLISION @@ -64,7 +64,7 @@ static void xx(char* pattern, char* str, int from, int to, int mem, int not, r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)), (UChar* )(str + SLEN(str)), (UChar* )str, region, ONIG_OPTION_NONE); - if (r < ONIG_MISMATCH) { + if (r < ONIG_MISMATCH || error_no < ONIG_MISMATCH) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; if (error_no == 0) { diff --git a/test/test_options.c b/test/test_options.c index ce92ee1f..9aa2538d 100644 --- a/test/test_options.c +++ b/test/test_options.c @@ -1,6 +1,6 @@ /* * test_options.c - * Copyright (c) 2020-2021 K.Kosako + * Copyright (c) 2020-2024 K.Kosako */ #ifdef ONIG_ESCAPE_UCHAR_COLLISION #undef ONIG_ESCAPE_UCHAR_COLLISION @@ -64,7 +64,7 @@ static void xx(OnigOptionType options, char* pattern, char* str, r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)), (UChar* )str, (UChar* )(str + SLEN(str)), region, options); - if (r < ONIG_MISMATCH) { + if (r < ONIG_MISMATCH || error_no < ONIG_MISMATCH) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; if (error_no == 0) { diff --git a/test/test_syntax.c b/test/test_syntax.c index 9b169773..4dcecf89 100644 --- a/test/test_syntax.c +++ b/test/test_syntax.c @@ -65,7 +65,7 @@ static void xx(char* pattern, char* str, int from, int to, int mem, int not, r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)), (UChar* )str, (UChar* )(str + SLEN(str)), region, ONIG_OPTION_NONE); - if (r < ONIG_MISMATCH) { + if (r < ONIG_MISMATCH || error_no < ONIG_MISMATCH) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; if (error_no == 0) { diff --git a/test/test_utf8.c b/test/test_utf8.c index 74975a28..01c0a5c2 100644 --- a/test/test_utf8.c +++ b/test/test_utf8.c @@ -64,7 +64,7 @@ static void xx(char* pattern, char* str, int from, int to, int mem, int not, r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)), (UChar* )str, (UChar* )(str + SLEN(str)), region, ONIG_OPTION_NONE); - if (r < ONIG_MISMATCH) { + if (r < ONIG_MISMATCH || error_no < ONIG_MISMATCH) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; if (error_no == 0) { @@ -1648,8 +1648,8 @@ extern int main(int argc, char* argv[]) e("()(?Ii)", "", ONIGERR_INVALID_GROUP_OPTION); e("(?:)(?Ii)", "", ONIGERR_INVALID_GROUP_OPTION); e("^(?Ii)", "", ONIGERR_INVALID_GROUP_OPTION); - e("(?Ii)$", "", ONIGERR_INVALID_GROUP_OPTION); - e("(?Ii)|", "", ONIGERR_INVALID_GROUP_OPTION); + x2("(?Ii)$", "", 0, 0); + x2("(?Ii)|", "", 0, 0); e("(?Ii)|(?Ii)", "", ONIGERR_INVALID_GROUP_OPTION); x2("a*", "aabcaaa", 0, 2); x2("(?L)a*", "aabcaaa", 4, 7);