From f3975eba963e044fbfeb2e42ec8f40efed0934de Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Thu, 3 Oct 2024 10:49:27 +0200 Subject: [PATCH] pcre2: Version 10.44 (#4478) (#4678) * update(pcre2): Version 10.44 (#4478) * update(pcre2): Add new file to VS project files (version 10.44) (#4478) * fix(RegEx): Use generic pcre2 function names (without suffix _8). * update(pcre2): Fix configuration (define PCRE2_STATIC) (#4478) --- Foundation/CMakeLists.txt | 1 + Foundation/Foundation_vs160.vcxproj | 1 + Foundation/Foundation_vs160.vcxproj.filters | 3 + Foundation/Foundation_vs170.vcxproj | 1 + Foundation/Foundation_vs170.vcxproj.filters | 3 + Foundation/Makefile | 2 +- Foundation/src/RegularExpression.cpp | 60 +- Foundation/src/Unicode.cpp | 2 +- Foundation/src/pcre2.h | 35 +- Foundation/src/pcre2_auto_possess.c | 16 +- Foundation/src/pcre2_chartables.c | 5 +- Foundation/src/pcre2_chkdint.c | 93 + Foundation/src/pcre2_compile.c | 1302 +++-- Foundation/src/pcre2_config.h | 64 +- Foundation/src/pcre2_context.c | 54 +- Foundation/src/pcre2_convert.c | 8 + Foundation/src/pcre2_dfa_match.c | 167 +- Foundation/src/pcre2_error.c | 10 +- Foundation/src/pcre2_extuni.c | 28 +- Foundation/src/pcre2_find_bracket.c | 10 +- Foundation/src/pcre2_internal.h | 159 +- Foundation/src/pcre2_intmodedep.h | 58 +- Foundation/src/pcre2_jit_compile.c | 1430 +++-- Foundation/src/pcre2_jit_match.c | 16 +- Foundation/src/pcre2_jit_misc.c | 4 +- Foundation/src/pcre2_maketables.c | 6 +- Foundation/src/pcre2_match.c | 469 +- Foundation/src/pcre2_match_data.c | 12 + Foundation/src/pcre2_study.c | 104 +- Foundation/src/pcre2_substring.c | 7 +- Foundation/src/pcre2_tables.c | 12 +- Foundation/src/pcre2_ucd.c | 5720 ++++++++++--------- Foundation/src/pcre2_ucp.h | 48 +- Foundation/src/pcre2_ucptables.c | 529 +- Foundation/src/pcre2_valid_utf.c | 48 +- Foundation/src/pcre2_xclass.c | 53 +- 36 files changed, 6060 insertions(+), 4480 deletions(-) create mode 100644 Foundation/src/pcre2_chkdint.c diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index 4a9ac6260..9d623ac2c 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -42,6 +42,7 @@ else() POCO_SOURCES(SRCS pcre2 src/pcre2_auto_possess.c src/pcre2_chartables.c + src/pcre2_chkdint.c src/pcre2_compile.c src/pcre2_config.c src/pcre2_context.c diff --git a/Foundation/Foundation_vs160.vcxproj b/Foundation/Foundation_vs160.vcxproj index 32ac92c19..f0d0379f2 100644 --- a/Foundation/Foundation_vs160.vcxproj +++ b/Foundation/Foundation_vs160.vcxproj @@ -1047,6 +1047,7 @@ + diff --git a/Foundation/Foundation_vs160.vcxproj.filters b/Foundation/Foundation_vs160.vcxproj.filters index fa7089179..89f52a4a0 100644 --- a/Foundation/Foundation_vs160.vcxproj.filters +++ b/Foundation/Foundation_vs160.vcxproj.filters @@ -846,6 +846,9 @@ RegularExpression\PCRE2 Source Files + + RegularExpression\PCRE2 Source Files + RegularExpression\PCRE2 Source Files diff --git a/Foundation/Foundation_vs170.vcxproj b/Foundation/Foundation_vs170.vcxproj index 0689fc4f9..58905dbfe 100644 --- a/Foundation/Foundation_vs170.vcxproj +++ b/Foundation/Foundation_vs170.vcxproj @@ -1509,6 +1509,7 @@ + diff --git a/Foundation/Foundation_vs170.vcxproj.filters b/Foundation/Foundation_vs170.vcxproj.filters index c9fc58917..75bc6a9fc 100644 --- a/Foundation/Foundation_vs170.vcxproj.filters +++ b/Foundation/Foundation_vs170.vcxproj.filters @@ -846,6 +846,9 @@ RegularExpression\PCRE2 Source Files + + RegularExpression\PCRE2 Source Files + RegularExpression\PCRE2 Source Files diff --git a/Foundation/Makefile b/Foundation/Makefile index 86fe425db..90bb45d9d 100644 --- a/Foundation/Makefile +++ b/Foundation/Makefile @@ -35,7 +35,7 @@ objects = ArchiveStrategy Ascii ASCIIEncoding AsyncChannel AsyncNotificationCent zlib_objects = adler32 compress crc32 deflate \ infback inffast inflate inftrees trees zutil -pcre_objects = pcre2_auto_possess pcre2_chartables pcre2_compile pcre2_config \ +pcre_objects = pcre2_auto_possess pcre2_chartables pcre2_chkdint pcre2_compile pcre2_config \ pcre2_context pcre2_convert pcre2_dfa_match pcre2_error pcre2_extuni \ pcre2_find_bracket pcre2_jit_compile pcre2_maketables pcre2_match \ pcre2_match_data pcre2_newline pcre2_ord2utf pcre2_pattern_info \ diff --git a/Foundation/src/RegularExpression.cpp b/Foundation/src/RegularExpression.cpp index 0e8c64f43..6fd71f6a6 100644 --- a/Foundation/src/RegularExpression.cpp +++ b/Foundation/src/RegularExpression.cpp @@ -29,34 +29,34 @@ namespace class MatchData { public: - MatchData(pcre2_code_8* code): - _match(pcre2_match_data_create_from_pattern_8(reinterpret_cast(code), nullptr)) + MatchData(pcre2_code* code): + _match(pcre2_match_data_create_from_pattern(reinterpret_cast(code), nullptr)) { if (!_match) throw Poco::RegularExpressionException("cannot create match data"); } ~MatchData() { - if (_match) pcre2_match_data_free_8(_match); + if (_match) pcre2_match_data_free(_match); } std::uint32_t count() const { - return pcre2_get_ovector_count_8(_match); + return pcre2_get_ovector_count(_match); } const PCRE2_SIZE* data() const { - return pcre2_get_ovector_pointer_8(_match); + return pcre2_get_ovector_pointer(_match); } - operator pcre2_match_data_8*() + operator pcre2_match_data*() { return _match; } private: - pcre2_match_data_8* _match; + pcre2_match_data* _match; }; } @@ -72,40 +72,40 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo unsigned nameEntrySize; unsigned char* nameTable; - pcre2_compile_context_8* context = pcre2_compile_context_create_8(nullptr); + pcre2_compile_context* context = pcre2_compile_context_create(nullptr); if (!context) throw Poco::RegularExpressionException("cannot create compile context"); if (options & RE_NEWLINE_LF) - pcre2_set_newline_8(context, PCRE2_NEWLINE_LF); + pcre2_set_newline(context, PCRE2_NEWLINE_LF); else if (options & RE_NEWLINE_CRLF) - pcre2_set_newline_8(context, PCRE2_NEWLINE_CRLF); + pcre2_set_newline(context, PCRE2_NEWLINE_CRLF); else if (options & RE_NEWLINE_ANY) - pcre2_set_newline_8(context, PCRE2_NEWLINE_ANY); + pcre2_set_newline(context, PCRE2_NEWLINE_ANY); else if (options & RE_NEWLINE_ANYCRLF) - pcre2_set_newline_8(context, PCRE2_NEWLINE_ANYCRLF); + pcre2_set_newline(context, PCRE2_NEWLINE_ANYCRLF); else // default RE_NEWLINE_CR - pcre2_set_newline_8(context, PCRE2_NEWLINE_CR); + pcre2_set_newline(context, PCRE2_NEWLINE_CR); - _pcre = pcre2_compile_8(reinterpret_cast(pattern.c_str()), pattern.length(), compileOptions(options), &errorCode, &errorOffset, context); - pcre2_compile_context_free_8(context); + _pcre = pcre2_compile(reinterpret_cast(pattern.c_str()), pattern.length(), compileOptions(options), &errorCode, &errorOffset, context); + pcre2_compile_context_free(context); if (!_pcre) { PCRE2_UCHAR buffer[256]; - pcre2_get_error_message_8(errorCode, buffer, sizeof(buffer)); + pcre2_get_error_message(errorCode, buffer, sizeof(buffer)); std::ostringstream msg; msg << reinterpret_cast(buffer) << " (at offset " << errorOffset << ")"; throw RegularExpressionException(msg.str()); } - pcre2_pattern_info_8(reinterpret_cast(_pcre), PCRE2_INFO_NAMECOUNT, &nameCount); - pcre2_pattern_info_8(reinterpret_cast(_pcre), PCRE2_INFO_NAMEENTRYSIZE, &nameEntrySize); - pcre2_pattern_info_8(reinterpret_cast(_pcre), PCRE2_INFO_NAMETABLE, &nameTable); + pcre2_pattern_info(reinterpret_cast(_pcre), PCRE2_INFO_NAMECOUNT, &nameCount); + pcre2_pattern_info(reinterpret_cast(_pcre), PCRE2_INFO_NAMEENTRYSIZE, &nameEntrySize); + pcre2_pattern_info(reinterpret_cast(_pcre), PCRE2_INFO_NAMETABLE, &nameTable); for (int i = 0; i < nameCount; i++) { unsigned char* group = nameTable + 2 + (nameEntrySize * i); - int n = pcre2_substring_number_from_name_8(reinterpret_cast(_pcre), group); + int n = pcre2_substring_number_from_name(reinterpret_cast(_pcre), group); _groups[n] = std::string(reinterpret_cast(group)); } } @@ -113,7 +113,7 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo RegularExpression::~RegularExpression() { - if (_pcre) pcre2_code_free_8(reinterpret_cast(_pcre)); + if (_pcre) pcre2_code_free(reinterpret_cast(_pcre)); } @@ -121,8 +121,8 @@ int RegularExpression::match(const std::string& subject, std::string::size_type { poco_assert (offset <= subject.length()); - MatchData matchData(reinterpret_cast(_pcre)); - int rc = pcre2_match_8(reinterpret_cast(_pcre), reinterpret_cast(subject.c_str()), subject.size(), offset, matchOptions(options), matchData, nullptr); + MatchData matchData(reinterpret_cast(_pcre)); + int rc = pcre2_match(reinterpret_cast(_pcre), reinterpret_cast(subject.c_str()), subject.size(), offset, matchOptions(options), matchData, nullptr); if (rc == PCRE2_ERROR_NOMATCH) { mtch.offset = std::string::npos; @@ -140,7 +140,7 @@ int RegularExpression::match(const std::string& subject, std::string::size_type else if (rc < 0) { PCRE2_UCHAR buffer[256]; - pcre2_get_error_message_8(rc, buffer, sizeof(buffer)); + pcre2_get_error_message(rc, buffer, sizeof(buffer)); throw RegularExpressionException(std::string(reinterpret_cast(buffer))); } const PCRE2_SIZE* ovec = matchData.data(); @@ -156,8 +156,8 @@ int RegularExpression::match(const std::string& subject, std::string::size_type matches.clear(); - MatchData matchData(reinterpret_cast(_pcre)); - int rc = pcre2_match_8(reinterpret_cast(_pcre), reinterpret_cast(subject.c_str()), subject.size(), offset, options & 0xFFFF, matchData, nullptr); + MatchData matchData(reinterpret_cast(_pcre)); + int rc = pcre2_match(reinterpret_cast(_pcre), reinterpret_cast(subject.c_str()), subject.size(), offset, options & 0xFFFF, matchData, nullptr); if (rc == PCRE2_ERROR_NOMATCH) { return 0; @@ -173,7 +173,7 @@ int RegularExpression::match(const std::string& subject, std::string::size_type else if (rc < 0) { PCRE2_UCHAR buffer[256]; - pcre2_get_error_message_8(rc, buffer, sizeof(buffer)); + pcre2_get_error_message(rc, buffer, sizeof(buffer)); throw RegularExpressionException(std::string(reinterpret_cast(buffer))); } matches.reserve(rc); @@ -279,8 +279,8 @@ std::string::size_type RegularExpression::substOne(std::string& subject, std::st { if (offset >= subject.length()) return std::string::npos; - MatchData matchData(reinterpret_cast(_pcre)); - int rc = pcre2_match_8(reinterpret_cast(_pcre), reinterpret_cast(subject.c_str()), subject.size(), offset, matchOptions(options), matchData, nullptr); + MatchData matchData(reinterpret_cast(_pcre)); + int rc = pcre2_match(reinterpret_cast(_pcre), reinterpret_cast(subject.c_str()), subject.size(), offset, matchOptions(options), matchData, nullptr); if (rc == PCRE2_ERROR_NOMATCH) { return std::string::npos; @@ -296,7 +296,7 @@ std::string::size_type RegularExpression::substOne(std::string& subject, std::st else if (rc < 0) { PCRE2_UCHAR buffer[256]; - pcre2_get_error_message_8(rc, buffer, sizeof(buffer)); + pcre2_get_error_message(rc, buffer, sizeof(buffer)); throw RegularExpressionException(std::string(reinterpret_cast(buffer))); } const PCRE2_SIZE* ovec = matchData.data(); diff --git a/Foundation/src/Unicode.cpp b/Foundation/src/Unicode.cpp index 93dbf4f27..10b7cbf93 100644 --- a/Foundation/src/Unicode.cpp +++ b/Foundation/src/Unicode.cpp @@ -29,7 +29,7 @@ void Unicode::properties(int ch, CharacterProperties& props) { if (ch > UCP_MAX_CODEPOINT) ch = 0; const ucd_record* ucd = GET_UCD(ch); - props.category = static_cast(PRIV(ucp_gentype_8)[ucd->chartype]); + props.category = static_cast(PRIV(ucp_gentype)[ucd->chartype]); props.type = static_cast(ucd->chartype); props.script = static_cast