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