diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index c33b8bf96..3845d6cd8 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -173,7 +173,7 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;USE_POSIX_API;USE_BINARY_COMPATIBLE_POSIX_API;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) MultiThreadedDebug Level4 false @@ -202,7 +202,7 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;USE_POSIX_API;USE_BINARY_COMPATIBLE_POSIX_API;_WIN64;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;_WIN64;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) MultiThreadedDebug Level4 false @@ -231,7 +231,7 @@ true MaxSpeed NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;USE_POSIX_API;USE_BINARY_COMPATIBLE_POSIX_API;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) MultiThreaded Level4 false @@ -265,7 +265,7 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;USE_POSIX_API;USE_BINARY_COMPATIBLE_POSIX_API;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) MultiThreaded Level4 false @@ -294,7 +294,7 @@ true MaxSpeed NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;USE_POSIX_API;USE_BINARY_COMPATIBLE_POSIX_API;SCI_LEXER;_WIN64;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;SCI_LEXER;_WIN64;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) MultiThreaded Level4 false @@ -328,7 +328,7 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;USE_POSIX_API;USE_BINARY_COMPATIBLE_POSIX_API;SCI_LEXER;_WIN64;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;SCI_EMPTYCATALOGUE;ONIG_STATIC;SCI_LEXER;_WIN64;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) MultiThreaded Level4 false @@ -361,8 +361,6 @@ - - @@ -412,7 +410,6 @@ - diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index 67a7a416a..ed05d9ccb 100644 --- a/scintilla/Scintilla.vcxproj.filters +++ b/scintilla/Scintilla.vcxproj.filters @@ -183,12 +183,6 @@ src - - oniguruma\src - - - oniguruma\src - src @@ -344,9 +338,6 @@ oniguruma\src - - oniguruma\src - src diff --git a/scintilla/oniguruma/doc/API b/scintilla/oniguruma/doc/API index 30e9a264c..b164c68ba 100644 --- a/scintilla/oniguruma/doc/API +++ b/scintilla/oniguruma/doc/API @@ -1,4 +1,4 @@ -Oniguruma API Version 6.9.7 2021/03/03 +Oniguruma API Version 7.0.0 2021/04/26 #include @@ -20,7 +20,7 @@ Oniguruma API Version 6.9.7 2021/03/03 error: error code < 0 -# int onig_error_code_to_str(UChar* err_buf, int err_code, ...) +# int onig_error_code_to_str(UChar* err_buf, OnigPos err_code, ...) Get error message string. If this function is used for onig_new(), @@ -322,8 +322,7 @@ Oniguruma API Version 6.9.7 2021/03/03 -# int onig_search(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, - const UChar* range, OnigRegion* region, OnigOptionType option) +# OnigPos onig_search(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option) Search string and return search result and matching region. Do not pass invalid byte string in the regex character encoding. @@ -367,9 +366,7 @@ Oniguruma API Version 6.9.7 2021/03/03 will be shared with callout. -# int onig_search_with_param(regex_t* reg, const UChar* str, const UChar* end, - const UChar* start, const UChar* range, OnigRegion* region, - OnigOptionType option, OnigMatchParam* mp) +# OnigPos onig_search_with_param(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp) Search string and return search result and matching region. Do not pass invalid byte string in the regex character encoding. @@ -379,8 +376,7 @@ Oniguruma API Version 6.9.7 2021/03/03 8 mp: match parameter values (match_stack_limit, retry_limit_in_match, retry_limit_in_search) -# int onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, - OnigRegion* region, OnigOptionType option) +# OnigPos onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, OnigRegion* region, OnigOptionType option) Match string and return result and matching region. Do not pass invalid byte string in the regex character encoding. @@ -409,9 +405,7 @@ Oniguruma API Version 6.9.7 2021/03/03 ONIG_OPTION_CALLBACK_EACH_MATCH Call back for all successful matches. -# int onig_match_with_param(regex_t* reg, const UChar* str, const UChar* end, - const UChar* at, OnigRegion* region, - OnigOptionType option, OnigMatchParam* mp) +# OnigPos onig_match_with_param(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp) Match string and return result and matching region. Do not pass invalid byte string in the regex character encoding. @@ -423,7 +417,7 @@ Oniguruma API Version 6.9.7 2021/03/03 # int onig_scan(regex_t* reg, const UChar* str, const UChar* end, OnigRegion* region, OnigOptionType option, - int (*scan_callback)(int, int, OnigRegion*, void*), + int (*scan_callback)(int, OnigPos, OnigRegion*, void*), void* callback_arg) Scan string and callback with matching region. @@ -525,7 +519,7 @@ Oniguruma API Version 6.9.7 2021/03/03 2 at: index of regex array (zero origin) -# int onig_regset_search(OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, int* rmatch_pos) +# int onig_regset_search(OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, OnigPos* rmatch_pos) Perform a search with regset. @@ -558,7 +552,7 @@ Oniguruma API Version 6.9.7 2021/03/03 In most cases, ONIG_REGSET_POSITION_LEAD seems to be faster. -# int onig_regset_search_with_param(OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, OnigMatchParam* mps[], int* rmatch_pos) +# int onig_regset_search_with_param(OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, OnigMatchParam* mps[], OnigPos* rmatch_pos) Perform a search with regset and match-params. diff --git a/scintilla/oniguruma/scintilla/OnigurumaRegExEngine.cxx b/scintilla/oniguruma/scintilla/OnigurumaRegExEngine.cxx index a8b255ec1..f149fb9ca 100644 --- a/scintilla/oniguruma/scintilla/OnigurumaRegExEngine.cxx +++ b/scintilla/oniguruma/scintilla/OnigurumaRegExEngine.cxx @@ -42,7 +42,7 @@ #ifdef ONIG_ESCAPE_UCHAR_COLLISION #undef ONIG_ESCAPE_UCHAR_COLLISION #endif -#include "../oniguruma/src/oniguruma.h" // Oniguruma - Regular Expression Engine (v6.9.2) +#include "../oniguruma/src/oniguruma.h" // Oniguruma - Regular Expression Engine // --------------------------------------------------------------- #define UCharPtr(pchar) reinterpret_cast(pchar) @@ -76,10 +76,11 @@ static void SetSimpleOptions(OnigOptionType& onigOptions, EOLmode /*eolMode*/, onigOptions = ONIG_OPTION_DEFAULT; // Notepad3 forced options + ONIG_OPTION_ON(onigOptions, ONIG_OPTION_NEGATE_SINGLELINE); + ONIG_OPTION_OFF(onigOptions, ONIG_OPTION_POSIX_REGION); ONIG_OPTION_OFF(onigOptions, ONIG_OPTION_EXTEND); ONIG_OPTION_OFF(onigOptions, ONIG_OPTION_SINGLELINE); - ONIG_OPTION_ON(onigOptions, ONIG_OPTION_NEGATE_SINGLELINE); ONIG_OPTION_OFF(onigOptions, ONIG_OPTION_FIND_LONGEST); //ONIG_OPTION_OFF(onigOptions, ONIG_OPTION_ASCII_RANGE); @@ -137,6 +138,7 @@ public: { m_OnigSyntax.op |= ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END; // xcluded from ONIG_SYNTAX_DEFAULT ? onig_initialize(s_UsedEncodingsTypes, _ARRAYSIZE(s_UsedEncodingsTypes)); + ///onig_set_default_syntax(ONIG_SYNTAX_ONIGURUMA); // std is: ONIG_SYNTAX_ONIGURUMA onig_region_init(&m_Region); } @@ -322,7 +324,7 @@ Sci::Position OnigurumaRegExEngine::FindText(Document* doc, Sci::Position minPos auto const rangeBegPtr = UCharCPtr(doc->RangePointer(rangeBeg, rangeLen)); auto const rangeEndPtr = UCharCPtr(doc->RangePointer(rangeEnd, 0)); - OnigPosition result = ONIG_MISMATCH; + OnigPos result = ONIG_MISMATCH; try { onig_region_free(&m_Region, 0); /* 1:free self, 0:free contents only */ onig_region_init(&m_Region); @@ -693,11 +695,11 @@ public: onig_end(); } - OnigPosition Find(const OnigUChar *pattern, const OnigUChar *document, const bool caseSensitive, int *matchLen_out = nullptr); + OnigPos Find(const OnigUChar *pattern, const OnigUChar *document, const bool caseSensitive, int *matchLen_out = nullptr); - const OnigPosition GetMatchPos() const { return m_MatchPos; }; - const OnigPosition GetMatchLen() const { return m_MatchLen; }; - const OnigRegion& GetRegion() const { return m_Region; }; + constexpr OnigPos GetMatchPos() const { return m_MatchPos; }; + constexpr OnigPos GetMatchLen() const { return m_MatchLen; }; + const OnigRegion & GetRegion() const { return m_Region; }; private: @@ -713,23 +715,23 @@ private: OnigUChar m_ErrorInfo[ONIG_MAX_ERROR_MESSAGE_LEN]; - OnigPosition m_MatchPos; - OnigPosition m_MatchLen; + OnigPos m_MatchPos; + OnigPos m_MatchLen; }; // ============================================================================ -OnigPosition SimpleRegExEngine::Find(const OnigUChar* pattern, const OnigUChar* document, const bool caseSensitive, int* matchLen_out /*=nullptr*/) +OnigPos SimpleRegExEngine::Find(const OnigUChar* pattern, const OnigUChar* document, const bool caseSensitive, int* matchLen_out /*=nullptr*/) { - auto const patternLen = (pattern) ? OnigPosition(_mbslen(pattern)) : 0; + auto const patternLen = (pattern) ? OnigPos(_mbslen(pattern)) : 0; if (patternLen == 0) { - return OnigPosition(-1); + return OnigPos(-1); } - auto const stringLen = (document) ? OnigPosition(_mbslen(document)) : 0; + auto const stringLen = (document) ? OnigPos(_mbslen(document)) : 0; if (stringLen == 0) { - return OnigPosition(-1); + return OnigPos(-1); } // init search options @@ -748,7 +750,7 @@ OnigPosition SimpleRegExEngine::Find(const OnigUChar* pattern, const OnigUChar* if (res != ONIG_NORMAL) { //onig_error_code_to_str(m_ErrorInfo, res, &einfo); - return OnigPosition(-111); + return OnigPos(-111); } onig_region_free(&m_Region, 0); @@ -760,16 +762,16 @@ OnigPosition SimpleRegExEngine::Find(const OnigUChar* pattern, const OnigUChar* const UChar* rangeEnd = strgEnd; // start search - OnigPosition result = onig_search(m_RegExpr, strgBeg, strgEnd, + OnigPos result = onig_search(m_RegExpr, strgBeg, strgEnd, rangeBeg, rangeEnd, &m_Region, m_Options); if (result < ONIG_MISMATCH) { //onig_error_code_to_str(m_ErrorInfo, result); - return OnigPosition(-3); + return OnigPos(-3); } - m_MatchPos = OnigPosition(ONIG_MISMATCH); // not found - m_MatchLen = OnigPosition(0); + m_MatchPos = OnigPos(ONIG_MISMATCH); // not found + m_MatchLen = OnigPos(0); if (result >= 0) // found { @@ -787,12 +789,12 @@ OnigPosition SimpleRegExEngine::Find(const OnigUChar* pattern, const OnigUChar* { //onig_error_code_to_str(m_ErrorInfo, result); m_MatchPos = result; - m_MatchLen = OnigPosition(0); + m_MatchLen = OnigPos(0); } } catch (...) { // -1 is normally used for not found, -666 is used here for exception - return OnigPosition(-666); + return OnigPos(-666); } if (matchLen_out) { diff --git a/scintilla/oniguruma/src/onigposix.h b/scintilla/oniguruma/src/onigposix.h index 3514f80e1..e611f25ff 100644 --- a/scintilla/oniguruma/src/onigposix.h +++ b/scintilla/oniguruma/src/onigposix.h @@ -4,7 +4,7 @@ onigposix.h - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2020 K.Kosako + * Copyright (c) 2002-2021 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,7 +74,7 @@ extern "C" { #define REG_POSIX_ENCODING_UTF16_LE 5 -typedef int onig_posix_regoff_t; +typedef ptrdiff_t onig_posix_regoff_t; typedef struct { onig_posix_regoff_t rm_so; diff --git a/scintilla/oniguruma/src/oniguruma.h b/scintilla/oniguruma/src/oniguruma.h index 540f61e2e..5a9a68366 100644 --- a/scintilla/oniguruma/src/oniguruma.h +++ b/scintilla/oniguruma/src/oniguruma.h @@ -34,11 +34,11 @@ extern "C" { #endif #define ONIGURUMA -#define ONIGURUMA_VERSION_MAJOR 6 -#define ONIGURUMA_VERSION_MINOR 9 -#define ONIGURUMA_VERSION_TEENY 7 +#define ONIGURUMA_VERSION_MAJOR 7 +#define ONIGURUMA_VERSION_MINOR 0 +#define ONIGURUMA_VERSION_TEENY 0 -#define ONIGURUMA_VERSION_INT 60907 +#define ONIGURUMA_VERSION_INT 70000 #ifndef P_ #if defined(__STDC__) || defined(_WIN32) @@ -80,13 +80,17 @@ extern "C" { #define UChar OnigUChar #endif -typedef int OnigPosition; // extent - typedef unsigned int OnigCodePoint; typedef unsigned char OnigUChar; typedef unsigned int OnigCtype; typedef unsigned int OnigLen; +#ifndef ONIG_NO_STANDARD_C_HEADERS +#include /* for ptrdiff_t */ +#endif + +typedef ptrdiff_t OnigPos; + #define ONIG_INFINITE_DISTANCE ~((OnigLen )0) typedef unsigned int OnigCaseFoldType; /* case fold flag */ @@ -671,8 +675,8 @@ ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax; typedef struct OnigCaptureTreeNodeStruct { int group; /* group number */ - int beg; - int end; + OnigPos beg; + OnigPos end; int allocated; int num_childs; struct OnigCaptureTreeNodeStruct** childs; @@ -682,8 +686,8 @@ typedef struct OnigCaptureTreeNodeStruct { struct re_registers { int allocated; int num_regs; - int* beg; - int* end; + OnigPos* beg; + OnigPos* end; /* extended */ OnigCaptureTreeNode* history_root; /* capture history tree root */ }; @@ -816,9 +820,9 @@ int onig_initialize P_((OnigEncoding encodings[], int number_of_encodings)); ONIG_EXTERN int onig_init P_((void)); ONIG_EXTERN -int ONIG_VARIADIC_FUNC_ATTR onig_error_code_to_str PV_((OnigUChar* s, int err_code, ...)); +int ONIG_VARIADIC_FUNC_ATTR onig_error_code_to_str PV_((OnigUChar* s, OnigPos err_code, ...)); ONIG_EXTERN -int onig_is_error_code_needs_param PV_((int code)); +int onig_is_error_code_needs_param PV_((OnigPos code)); ONIG_EXTERN void onig_set_warn_func P_((OnigWarnFunc f)); ONIG_EXTERN @@ -835,15 +839,15 @@ void onig_free P_((OnigRegex)); ONIG_EXTERN void onig_free_body P_((OnigRegex)); ONIG_EXTERN -int onig_scan(OnigRegex reg, const OnigUChar* str, const OnigUChar* end, OnigRegion* region, OnigOptionType option, int (*scan_callback)(int, int, OnigRegion*, void*), void* callback_arg); +int onig_scan(OnigRegex reg, const OnigUChar* str, const OnigUChar* end, OnigRegion* region, OnigOptionType option, int (*scan_callback)(int, OnigPos, OnigRegion*, void*), void* callback_arg); ONIG_EXTERN -int onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option)); +OnigPos onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option)); ONIG_EXTERN -int onig_search_with_param P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp)); +OnigPos onig_search_with_param P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp)); ONIG_EXTERN -int onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option)); +OnigPos onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option)); ONIG_EXTERN -int onig_match_with_param P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp)); +OnigPos onig_match_with_param P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp)); ONIG_EXTERN int onig_regset_new P_((OnigRegSet** rset, int n, regex_t* regs[])); @@ -860,9 +864,9 @@ regex_t* onig_regset_get_regex P_((OnigRegSet* set, int at)); ONIG_EXTERN OnigRegion* onig_regset_get_region P_((OnigRegSet* set, int at)); ONIG_EXTERN -int onig_regset_search P_((OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, int* rmatch_pos)); +int onig_regset_search P_((OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, OnigPos* rmatch_pos)); ONIG_EXTERN -int onig_regset_search_with_param P_((OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, OnigMatchParam* mps[], int* rmatch_pos)); +int onig_regset_search_with_param P_((OnigRegSet* set, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegSetLead lead, OnigOptionType option, OnigMatchParam* mps[], OnigPos* rmatch_pos)); ONIG_EXTERN OnigRegion* onig_region_new P_((void)); diff --git a/scintilla/oniguruma/src/regcomp.c b/scintilla/oniguruma/src/regcomp.c index d80551dc9..921a05270 100644 --- a/scintilla/oniguruma/src/regcomp.c +++ b/scintilla/oniguruma/src/regcomp.c @@ -6922,7 +6922,7 @@ set_optimize_exact(regex_t* reg, OptStr* e) } reg->dist_min = e->mm.min; - reg->dist_max = e->mm.max; + reg->dist_max = (OnigSize )e->mm.max; if (reg->dist_min != INFINITE_LEN) { int n = (int )(reg->exact_end - reg->exact); @@ -6942,7 +6942,7 @@ set_optimize_map(regex_t* reg, OptMap* m) reg->optimize = OPTIMIZE_MAP; reg->dist_min = m->mm.min; - reg->dist_max = m->mm.max; + reg->dist_max = (OnigSize )m->mm.max; if (reg->dist_min != INFINITE_LEN) { reg->threshold_len = reg->dist_min + ONIGENC_MBC_MINLEN(reg->enc); @@ -7011,6 +7011,9 @@ set_optimize_info_from_tree(Node* node, regex_t* reg, ParseEnv* scan_env) reg->sub_anchor |= opt.anc.right & ANCR_END_LINE; } + if (reg->dist_max == INFINITE_LEN) + reg->dist_max = INFINITE_SIZE; + #if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH) print_optimize_info(DBGFP, reg); #endif @@ -7191,10 +7194,10 @@ print_optimize_info(FILE* f, regex_t* reg) } fprintf(f, "]: length: %ld, dmin: %u, ", (reg->exact_end - reg->exact), reg->dist_min); - if (reg->dist_max == INFINITE_LEN) + if (reg->dist_max == INFINITE_SIZE) fprintf(f, "dmax: inf.\n"); else - fprintf(f, "dmax: %u\n", reg->dist_max); + fprintf(f, "dmax: %lu\n", reg->dist_max); } else if (reg->optimize & OPTIMIZE_MAP) { int c, i, n = 0; @@ -7202,8 +7205,8 @@ print_optimize_info(FILE* f, regex_t* reg) for (i = 0; i < CHAR_MAP_SIZE; i++) if (reg->map[i]) n++; - fprintf(f, "map: n=%d, dmin: %u, dmax: %u\n", - n, reg->dist_min, reg->dist_max); + fprintf(f, "map: n=%d, dmin: %u, dmax: %lu\n", + n, reg->dist_min, reg->dist_max); if (n > 0) { c = 0; fputc('[', f); @@ -7319,7 +7322,7 @@ onig_free(regex_t* reg) static void print_tree P_((FILE* f, Node* node)); #endif -extern int onig_init_for_match_at(regex_t* reg); +extern OnigPos onig_init_for_match_at(regex_t* reg); static int parse_and_tune(regex_t* reg, const UChar* pattern, const UChar* pattern_end, ParseEnv *scan_env, Node** rroot, diff --git a/scintilla/oniguruma/src/regerror.c b/scintilla/oniguruma/src/regerror.c index 18a5bdd22..4e4f07941 100644 --- a/scintilla/oniguruma/src/regerror.c +++ b/scintilla/oniguruma/src/regerror.c @@ -35,7 +35,7 @@ #include "regint.h" extern UChar* -onig_error_code_to_format(int code) +onig_error_code_to_format(OnigPos code) { char *p; @@ -268,7 +268,7 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end, extern int -onig_is_error_code_needs_param(int code) +onig_is_error_code_needs_param(OnigPos code) { switch (code) { case ONIGERR_UNDEFINED_NAME_REFERENCE: @@ -288,7 +288,7 @@ onig_is_error_code_needs_param(int code) #define MAX_ERROR_PAR_LEN 30 extern int ONIG_VARIADIC_FUNC_ATTR -onig_error_code_to_str(UChar* s, int code, ...) +onig_error_code_to_str(UChar* s, OnigPos code, ...) { UChar *p, *q; OnigErrorInfo* einfo; diff --git a/scintilla/oniguruma/src/regexec.c b/scintilla/oniguruma/src/regexec.c index 396f7d678..8179fd52d 100644 --- a/scintilla/oniguruma/src/regexec.c +++ b/scintilla/oniguruma/src/regexec.c @@ -70,7 +70,7 @@ const OnigUChar* const _CRLF = "\r\n\0"; static int forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start, UChar* range, UChar** low, UChar** high); -static int +static OnigPos search_in_range(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, const UChar* range, /* match range */ const UChar* data_range, /* subject string range */ OnigRegion* region, OnigOptionType option, OnigMatchParam* mp); @@ -178,8 +178,8 @@ typedef struct { #endif OnigMatchParam* mp; #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE - int best_len; /* for ONIG_OPTION_FIND_LONGEST */ - UChar* best_s; + OnigPos best_len; /* for ONIG_OPTION_FIND_LONGEST */ + UChar* best_s; #endif #ifdef USE_CALL unsigned long subexp_call_in_search_counter; @@ -923,8 +923,8 @@ onig_region_resize(OnigRegion* region, int n) n = ONIG_NREGION; if (region->allocated == 0) { - region->beg = (int* )xmalloc(n * sizeof(int)); - region->end = (int* )xmalloc(n * sizeof(int)); + region->beg = (OnigPos* )xmalloc(n * sizeof(*(region->beg))); + region->end = (OnigPos* )xmalloc(n * sizeof(*(region->end))); if (region->beg == 0 || region->end == 0) return ONIGERR_MEMORY; @@ -932,8 +932,8 @@ onig_region_resize(OnigRegion* region, int n) region->allocated = n; } else if (region->allocated < n) { - region->beg = (int* )xrealloc(region->beg, n * sizeof(int)); - region->end = (int* )xrealloc(region->end, n * sizeof(int)); + region->beg = (OnigPos* )xrealloc(region->beg, n * sizeof(*(region->beg))); + region->end = (OnigPos* )xrealloc(region->end, n * sizeof(*(region->end))); if (region->beg == 0 || region->end == 0) return ONIGERR_MEMORY; @@ -975,8 +975,8 @@ onig_region_init(OnigRegion* region) { region->num_regs = 0; region->allocated = 0; - region->beg = (int* )0; - region->end = (int* )0; + region->beg = (OnigPos* )0; + region->end = (OnigPos* )0; region->history_root = (OnigCaptureTreeNode* )0; } @@ -1010,24 +1010,24 @@ onig_region_free(OnigRegion* r, int free_self) extern void onig_region_copy(OnigRegion* to, OnigRegion* from) { -#define RREGC_SIZE (sizeof(int) * from->num_regs) +#define RREGC_SIZE (sizeof(OnigPos) * from->num_regs) int i; if (to == from) return; if (to->allocated == 0) { if (from->num_regs > 0) { - to->beg = (int* )xmalloc(RREGC_SIZE); + to->beg = (OnigPos* )xmalloc(RREGC_SIZE); if (IS_NULL(to->beg)) return; - to->end = (int* )xmalloc(RREGC_SIZE); + to->end = (OnigPos* )xmalloc(RREGC_SIZE); if (IS_NULL(to->end)) return; to->allocated = from->num_regs; } } else if (to->allocated < from->num_regs) { - to->beg = (int* )xrealloc(to->beg, RREGC_SIZE); + to->beg = (OnigPos* )xrealloc(to->beg, RREGC_SIZE); if (IS_NULL(to->beg)) return; - to->end = (int* )xrealloc(to->end, RREGC_SIZE); + to->end = (OnigPos* )xrealloc(to->end, RREGC_SIZE); if (IS_NULL(to->end)) return; to->allocated = from->num_regs; } @@ -2433,7 +2433,7 @@ stack_double(int* is_alloca, char** arg_alloc_base, } while(0) static int string_cmp_ic(OnigEncoding enc, int case_fold_flag, - UChar* s1, UChar** ps2, int mblen) + UChar* s1, UChar** ps2, int byte_len) { UChar buf1[ONIGENC_MBC_CASE_FOLD_MAXLEN]; UChar buf2[ONIGENC_MBC_CASE_FOLD_MAXLEN]; @@ -2441,8 +2441,8 @@ static int string_cmp_ic(OnigEncoding enc, int case_fold_flag, int len1, len2; s2 = *ps2; - end1 = s1 + mblen; - end2 = s2 + mblen; + end1 = s1 + byte_len; + end2 = s2 + byte_len; while (s1 < end1) { len1 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s1, end1, buf1); len2 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s2, end2, buf2); @@ -2486,7 +2486,7 @@ static int string_cmp_ic(OnigEncoding enc, int case_fold_flag, #define ON_STR_END(s) ((s) == end) #define DATA_ENSURE_CHECK1 (s < right_range) #define DATA_ENSURE_CHECK(n) (s + (n) <= right_range) -#define DATA_ENSURE(n) if (right_range - s < (n)) goto fail +#define DATA_ENSURE(n) if (right_range - s < (OnigPos )(n)) goto fail #define INIT_RIGHT_RANGE right_range = (UChar* )in_right_range @@ -2715,7 +2715,7 @@ onig_print_statistics(FILE* f) /* matching region of POSIX API */ -typedef int regoff_t; +typedef ptrdiff_t regoff_t; typedef struct { regoff_t rm_so; @@ -2766,10 +2766,11 @@ typedef struct { #define MATCH_DEBUG_OUT(offset) do {\ Operation *xp;\ UChar *q, *bp, buf[50];\ - int len, spos;\ - spos = IS_NOT_NULL(s) ? (int )(s - str) : -1;\ + int len;\ + ptrdiff_t spos;\ + spos = IS_NOT_NULL(s) ? s - str : -1;\ xp = p - (offset);\ - fprintf(DBGFP, "%7u: %7ld: %4d> \"",\ + fprintf(DBGFP, "%7u: %7ld: %ld> \"",\ counter, GET_STACK_INDEX(stk), spos);\ counter++;\ bp = buf;\ @@ -2826,7 +2827,7 @@ typedef struct { /* match data(str - end) from position (sstart). */ -static int +static OnigPos match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* in_right_range, const UChar* sstart, MatchArg* msa) @@ -2943,7 +2944,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, }; #endif - int i, n, num_mem, best_len, pop_level; + OnigPos best_len; + int i, num_mem, pop_level; LengthType tlen, tlen2; MemNumType mem; RelAddrType addr; @@ -3030,8 +3032,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, #ifdef ONIG_DEBUG_MATCH fprintf(DBGFP, "match_at: str: %p, end: %p, start: %p\n", str, end, sstart); - fprintf(DBGFP, "size: %d, start offset: %d\n", - (int )(end - str), (int )(sstart - str)); + fprintf(DBGFP, "size: %ld, start offset: %ld\n", end - str, sstart - str); #endif best_len = ONIG_MISMATCH; @@ -3045,7 +3046,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, BYTECODE_INTERPRETER_START { CASE_OP(END) - n = (int )(s - sstart); + { + OnigPos n; + n = s - sstart; if (n == 0 && OPTON_FIND_NOT_EMPTY(options)) { best_len = ONIG_MISMATCH; goto fail; /* for retry */ @@ -3099,12 +3102,12 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, } else { #endif /* USE_POSIX_API */ - region->beg[0] = (int )(keep - str); - region->end[0] = (int )(s - str); + region->beg[0] = keep - str; + region->end[0] = s - str; for (i = 1; i <= num_mem; i++) { if (mem_end_stk[i].i != INVALID_STACK_INDEX) { - region->beg[i] = (int )(STACK_MEM_START(reg, i) - str); - region->end[i] = (int )(STACK_MEM_END(reg, i) - str); + region->beg[i] = STACK_MEM_START(reg, i) - str; + region->end[i] = STACK_MEM_END(reg, i) - str; } else { region->beg[i] = region->end[i] = ONIG_REGION_NOTPOS; @@ -3125,8 +3128,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, } node->group = 0; - node->beg = (int )(keep - str); - node->end = (int )(s - str); + node->beg = keep - str; + node->end = s - str; stkp = stk_base; i = make_capture_history_tree(region->history_root, &stkp, @@ -3157,7 +3160,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, /* default behavior: return first-matching result. */ goto match_at_end; - + } CASE_OP(STR_1) DATA_ENSURE(1); ps = p->exact.s; @@ -3404,6 +3407,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, JUMP_OUT_WITH_SPREV_SET; CASE_OP(ANYCHAR) + { + int n; DATA_ENSURE(1); n = enclen(encode, s); DATA_ENSURE(n); @@ -3411,16 +3416,22 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, s += n; INC_OP; JUMP_OUT_WITH_SPREV_SET; + } CASE_OP(ANYCHAR_ML) + { + int n; DATA_ENSURE(1); n = enclen(encode, s); DATA_ENSURE(n); s += n; INC_OP; JUMP_OUT_WITH_SPREV_SET; + } CASE_OP(ANYCHAR_STAR) + { + int n; INC_OP; while (DATA_ENSURE_CHECK1) { STACK_PUSH_ALT(p, s); @@ -3430,8 +3441,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, s += n; } JUMP_OUT; + } CASE_OP(ANYCHAR_ML_STAR) + { + int n; INC_OP; while (DATA_ENSURE_CHECK1) { STACK_PUSH_ALT(p, s); @@ -3445,10 +3459,12 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, } } JUMP_OUT; + } CASE_OP(ANYCHAR_STAR_PEEK_NEXT) { UChar c; + int n; c = p->anychar_star_peek_next.c; INC_OP; @@ -3467,6 +3483,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, CASE_OP(ANYCHAR_ML_STAR_PEEK_NEXT) { UChar c; + int n; c = p->anychar_star_peek_next.c; INC_OP; @@ -3819,13 +3836,14 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, backref: { UChar *pstart, *pend; + OnigPos n; if (mem_end_stk[mem].i == INVALID_STACK_INDEX) goto fail; if (mem_start_stk[mem].i == INVALID_STACK_INDEX) goto fail; pstart = STACK_MEM_START(reg, mem); pend = STACK_MEM_END(reg, mem); - n = (int )(pend - pstart); + n = pend - pstart; if (n != 0) { DATA_ENSURE(n); STRING_CMP(s, pstart, n); @@ -3838,13 +3856,14 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, mem = p->backref_n.n1; { UChar *pstart, *pend; + OnigPos n; if (mem_end_stk[mem].i == INVALID_STACK_INDEX) goto fail; if (mem_start_stk[mem].i == INVALID_STACK_INDEX) goto fail; pstart = STACK_MEM_START(reg, mem); pend = STACK_MEM_END(reg, mem); - n = (int )(pend - pstart); + n = pend - pstart; if (n != 0) { DATA_ENSURE(n); STRING_CMP_IC(case_fold_flag, pstart, &s, n); @@ -3857,6 +3876,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, { int is_fail; UChar *pstart, *pend, *swork; + OnigPos n; tlen = p->backref_general.num; for (i = 0; i < tlen; i++) { @@ -3867,7 +3887,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, pstart = STACK_MEM_START(reg, mem); pend = STACK_MEM_END(reg, mem); - n = (int )(pend - pstart); + n = pend - pstart; if (n != 0) { DATA_ENSURE(n); swork = s; @@ -3886,6 +3906,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, { int is_fail; UChar *pstart, *pend, *swork; + OnigPos n; tlen = p->backref_general.num; for (i = 0; i < tlen; i++) { @@ -3896,7 +3917,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, pstart = STACK_MEM_START(reg, mem); pend = STACK_MEM_END(reg, mem); - n = (int )(pend - pstart); + n = pend - pstart; if (n != 0) { DATA_ENSURE(n); swork = s; @@ -3913,20 +3934,20 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, #ifdef USE_BACKREF_WITH_LEVEL CASE_OP(BACKREF_WITH_LEVEL_IC) - n = 1; /* ignore case */ + i = 1; /* ignore case */ goto backref_with_level; CASE_OP(BACKREF_WITH_LEVEL) { int level; MemNumType* mems; - n = 0; + i = 0; backref_with_level: level = p->backref_general.nest_level; tlen = p->backref_general.num; mems = tlen == 1 ? &(p->backref_general.n1) : p->backref_general.ns; - if (! backref_match_at_nested_level(reg, stk, stk_base, n, + if (! backref_match_at_nested_level(reg, stk, stk_base, i, case_fold_flag, level, (int )tlen, mems, &s, end)) { goto fail; } @@ -4137,6 +4158,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, JUMP_OUT; CASE_OP(REPEAT_INC) + { + int n; + mem = p->repeat_inc.id; /* mem: OP_REPEAT ID */ STACK_GET_REPEAT_COUNT(mem, n); n++; @@ -4154,8 +4178,12 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, } STACK_PUSH_REPEAT_INC(mem, n); CHECK_INTERRUPT_JUMP_OUT; + } CASE_OP(REPEAT_INC_NG) + { + int n; + mem = p->repeat_inc.id; /* mem: OP_REPEAT ID */ STACK_GET_REPEAT_COUNT(mem, n); n++; @@ -4173,6 +4201,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, } } CHECK_INTERRUPT_JUMP_OUT; + } #ifdef USE_CALL CASE_OP(CALL) @@ -4490,9 +4519,10 @@ regset_search_body_position_lead(OnigRegSet* set, const UChar* str, const UChar* end, const UChar* start, const UChar* range, /* match start range */ const UChar* orig_range, /* data range */ - OnigOptionType option, MatchArg* msas, int* rmatch_pos) + OnigOptionType option, MatchArg* msas, OnigPos* rmatch_pos) { - int r, n, i; + OnigPos r; + int n, i; UChar *s; UChar *low, *high; UChar* sch_range; @@ -4512,7 +4542,7 @@ regset_search_body_position_lead(OnigRegSet* set, sr[i].state = SRS_DEAD; if (reg->optimize != OPTIMIZE_NONE) { - if (reg->dist_max != INFINITE_LEN) { + if (reg->dist_max != INFINITE_SIZE) { if (DIST_CAST(end - range) > reg->dist_max) sch_range = (UChar* )range + reg->dist_max; else @@ -4625,23 +4655,24 @@ regset_search_body_position_lead(OnigRegSet* set, xfree(sr); return ONIG_MISMATCH; + /* error */ finish: xfree(sr); - return r; + return (int )r; match: xfree(sr); - *rmatch_pos = (int )(s - str); + *rmatch_pos = s - str; return i; } static inline int regset_search_body_regex_lead(OnigRegSet* set, - const UChar* str, const UChar* end, - const UChar* start, const UChar* orig_range, OnigRegSetLead lead, - OnigOptionType option, OnigMatchParam* mps[], int* rmatch_pos) + const UChar* str, const UChar* end, + const UChar* start, const UChar* orig_range, OnigRegSetLead lead, + OnigOptionType option, OnigMatchParam* mps[], OnigPos* rmatch_pos) { - int r; + OnigPos r; int i; int n; int match_index; @@ -4682,7 +4713,7 @@ onig_regset_search_with_param(OnigRegSet* set, const UChar* str, const UChar* end, const UChar* start, const UChar* range, OnigRegSetLead lead, OnigOptionType option, OnigMatchParam* mps[], - int* rmatch_pos) + OnigPos* rmatch_pos) { int r; int i; @@ -4729,7 +4760,7 @@ onig_regset_search_with_param(OnigRegSet* set, } if (set->anchor != OPTIMIZE_NONE && str < end) { - UChar *min_semi_end, *max_semi_end; + UChar *min_semi_end; if ((set->anchor & ANCR_BEGIN_POSITION) != 0) { /* search start-position only */ @@ -4742,26 +4773,25 @@ onig_regset_search_with_param(OnigRegSet* set, range = str + 1; } else if ((set->anchor & ANCR_END_BUF) != 0) { - min_semi_end = max_semi_end = (UChar* )end; + min_semi_end = (UChar* )end; end_buf: - if ((OnigLen )(max_semi_end - str) < set->anc_dmin) + if (DIST_CAST(end - str) < set->anc_dmin) goto mismatch_no_msa; - if ((OnigLen )(min_semi_end - start) > set->anc_dmax) { + if (DIST_CAST(min_semi_end - start) > set->anc_dmax) { start = min_semi_end - set->anc_dmax; if (start < end) start = onigenc_get_right_adjust_char_head(enc, str, start); } - if ((OnigLen )(max_semi_end - (range - 1)) < set->anc_dmin) { - range = max_semi_end - set->anc_dmin + 1; + if (DIST_CAST(end - (range - 1)) < set->anc_dmin) { + range = end - set->anc_dmin + 1; } if (start > range) goto mismatch_no_msa; } else if ((set->anchor & ANCR_SEMI_END_BUF) != 0) { UChar* pre_end = ONIGENC_STEP_BACK(enc, str, end, 1); - max_semi_end = (UChar* )end; if (ONIGENC_IS_MBC_NEWLINE(enc, pre_end, end)) { min_semi_end = pre_end; @@ -4786,7 +4816,7 @@ onig_regset_search_with_param(OnigRegSet* set, } } else if (str == end) { /* empty string */ - start = end = str; + start = str; s = (UChar* )start; msas = (MatchArg* )xmalloc(sizeof(*msas) * set->n); @@ -4802,13 +4832,17 @@ onig_regset_search_with_param(OnigRegSet* set, /* Can't use REGSET_MATCH_AND_RETURN_CHECK() because r must be set regex index (i) */ - r = match_at(reg, str, end, end, s, msas + i); - if (r != ONIG_MISMATCH) { - if (r >= 0) { + OnigPos pos; + pos = match_at(reg, str, end, end, s, msas + i); + if (pos != ONIG_MISMATCH) { + if (pos >= 0) { r = i; goto match; } - else goto finish; /* error */ + else { + r = (int )pos; + goto finish; /* error */ + } } } } @@ -4871,8 +4905,8 @@ onig_regset_search_with_param(OnigRegSet* set, extern int onig_regset_search(OnigRegSet* set, const UChar* str, const UChar* end, - const UChar* start, const UChar* range, - OnigRegSetLead lead, OnigOptionType option, int* rmatch_pos) + const UChar* start, const UChar* range, + OnigRegSetLead lead, OnigOptionType option, OnigPos* rmatch_pos) { int r; int i; @@ -5103,11 +5137,11 @@ map_search_backward(OnigEncoding enc, UChar map[], } return (UChar* )NULL; } -extern int +extern OnigPos onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, OnigRegion* region, OnigOptionType option) { - int r; + OnigPos r; OnigMatchParam mp; onig_initialize_match_param(&mp); @@ -5116,12 +5150,12 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, return r; } -extern int +extern OnigPos onig_match_with_param(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp) { - int r; + OnigPos r; MatchArg msa; #ifndef USE_POSIX_API @@ -5135,7 +5169,7 @@ onig_match_with_param(regex_t* reg, const UChar* str, const UChar* end, && !OPTON_POSIX_REGION(option) #endif ) { - r = onig_region_resize_clear(region, reg->num_mem + 1); + r = (OnigPos )onig_region_resize_clear(region, reg->num_mem + 1); } else r = 0; @@ -5260,7 +5294,7 @@ forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start, *high = p; } else { - if (reg->dist_max != INFINITE_LEN) { + if (reg->dist_max != INFINITE_SIZE) { if (DIST_CAST(p - str) < reg->dist_max) { *low = (UChar* )str; } @@ -5280,9 +5314,8 @@ forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start, #ifdef ONIG_DEBUG_SEARCH fprintf(DBGFP, - "forward_search success: low: %d, high: %d, dmin: %u, dmax: %u\n", - (int )(*low - str), (int )(*high - str), - reg->dist_min, reg->dist_max); + "forward_search success: low: %ld, high: %ld, dmin: %u, dmax: %lu\n", + *low - str, *high - str, reg->dist_min, reg->dist_max); #endif return 1; /* success */ } @@ -5364,7 +5397,7 @@ backward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* s, } } - if (reg->dist_max != INFINITE_LEN) { + if (reg->dist_max != INFINITE_SIZE) { if (DIST_CAST(p - str) < reg->dist_max) *low = (UChar* )str; else @@ -5398,12 +5431,12 @@ backward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* s, } -extern int +extern OnigPos onig_search(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option) { - int r; + OnigPos r; OnigMatchParam mp; const UChar* data_range; @@ -5423,22 +5456,22 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, } -static int +static OnigPos search_in_range(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, const UChar* range, /* match start range */ const UChar* data_range, /* subject string range */ OnigRegion* region, OnigOptionType option, OnigMatchParam* mp) { - int r; + OnigPos r; UChar *s; MatchArg msa; const UChar *orig_start = start; #ifdef ONIG_DEBUG_SEARCH fprintf(DBGFP, - "onig_search (entry point): str: %p, end: %d, start: %d, range: %d\n", - str, (int )(end - str), (int )(start - str), (int )(range - str)); + "onig_search (entry point): str: %p, end: %ld, start: %ld, range: %ld\n", + str, end - str, start - str, range - str); #endif ADJUST_MATCH_PARAM(reg, mp); @@ -5455,7 +5488,7 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, && ! OPTON_POSIX_REGION(option) #endif ) { - r = onig_region_resize_clear(region, reg->num_mem + 1); + r = (OnigPos )onig_region_resize_clear(region, reg->num_mem + 1); if (r != 0) goto finish_no_msa; } @@ -5481,7 +5514,7 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, /* anchor optimize: resume search range */ if (reg->anchor != 0 && str < end) { - UChar *min_semi_end, *max_semi_end; + UChar *min_semi_end; if (reg->anchor & ANCR_BEGIN_POSITION) { /* search start-position only */ @@ -5507,10 +5540,10 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, } } else if (reg->anchor & ANCR_END_BUF) { - min_semi_end = max_semi_end = (UChar* )end; + min_semi_end = (UChar* )end; end_buf: - if ((OnigLen )(max_semi_end - str) < reg->anc_dist_min) + if (DIST_CAST(end - str) < reg->anc_dist_min) goto mismatch_no_msa; if (range > start) { @@ -5520,11 +5553,11 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, if (start < end) start = onigenc_get_right_adjust_char_head(reg->enc, str, start); } - if (DIST_CAST(max_semi_end - (range - 1)) < reg->anc_dist_min) { - if (DIST_CAST(max_semi_end - str + 1) < reg->anc_dist_min) + if (DIST_CAST(end - (range - 1)) < reg->anc_dist_min) { + if (DIST_CAST(end - str + 1) < reg->anc_dist_min) goto mismatch_no_msa; else - range = max_semi_end - reg->anc_dist_min + 1; + range = end - reg->anc_dist_min + 1; } if (start > range) goto mismatch_no_msa; @@ -5536,11 +5569,11 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, DIST_CAST(min_semi_end - range) > reg->anc_dist_max) { range = min_semi_end - reg->anc_dist_max; } - if (DIST_CAST(max_semi_end - start) < reg->anc_dist_min) { - if (DIST_CAST(max_semi_end - str) < reg->anc_dist_min) + if (DIST_CAST(end - start) < reg->anc_dist_min) { + if (DIST_CAST(end - str) < reg->anc_dist_min) goto mismatch_no_msa; else { - start = max_semi_end - reg->anc_dist_min; + start = end - reg->anc_dist_min; start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, start); } } @@ -5550,7 +5583,6 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, else if (reg->anchor & ANCR_SEMI_END_BUF) { UChar* pre_end = ONIGENC_STEP_BACK(reg->enc, str, end, 1); - max_semi_end = (UChar* )end; if (ONIGENC_IS_MBC_NEWLINE(reg->enc, pre_end, end)) { min_semi_end = pre_end; @@ -5593,8 +5625,8 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, } #ifdef ONIG_DEBUG_SEARCH - fprintf(DBGFP, "onig_search(apply anchor): end: %d, start: %d, range: %d\n", - (int )(end - str), (int )(start - str), (int )(range - str)); + fprintf(DBGFP, "onig_search(apply anchor): end: %ld, start: %ld, range: %ld\n", + end - str, start - str, range - str); #endif MATCH_ARG_INIT(msa, reg, option, region, orig_start, mp); @@ -5605,7 +5637,7 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, UChar *sch_range, *low, *high; if (reg->dist_max != 0) { - if (reg->dist_max == INFINITE_LEN) + if (reg->dist_max == INFINITE_SIZE) sch_range = (UChar* )end; else { if (DIST_CAST(end - range) < reg->dist_max) @@ -5621,7 +5653,7 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, if ((end - start) < reg->threshold_len) goto mismatch; - if (reg->dist_max != INFINITE_LEN) { + if (reg->dist_max != INFINITE_SIZE) { do { if (! forward_search(reg, str, end, s, sch_range, &low, &high)) goto mismatch; @@ -5689,7 +5721,7 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, else min_range = end; - if (reg->dist_max != INFINITE_LEN) { + if (reg->dist_max != INFINITE_SIZE) { do { if (DIST_CAST(end - s) > reg->dist_max) sch_start = s + reg->dist_max; @@ -5751,7 +5783,7 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, #ifdef ONIG_DEBUG if (r != ONIG_MISMATCH) - fprintf(DBGFP, "onig_search: error %d\n", r); + fprintf(DBGFP, "onig_search: error %ld\n", r); #endif return r; @@ -5760,19 +5792,19 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end, finish_no_msa: #ifdef ONIG_DEBUG if (r != ONIG_MISMATCH) - fprintf(DBGFP, "onig_search: error %d\n", r); + fprintf(DBGFP, "onig_search: error %ld\n", r); #endif return r; match: MATCH_ARG_FREE(msa); - return (int )(s - str); + return s - str; } -extern int +extern OnigPos onig_search_with_param(regex_t* reg, const UChar* str, const UChar* end, - const UChar* start, const UChar* range, OnigRegion* region, - OnigOptionType option, OnigMatchParam* mp) + const UChar* start, const UChar* range, OnigRegion* region, + OnigOptionType option, OnigMatchParam* mp) { const UChar* data_range; @@ -5788,10 +5820,10 @@ onig_search_with_param(regex_t* reg, const UChar* str, const UChar* end, extern int onig_scan(regex_t* reg, const UChar* str, const UChar* end, OnigRegion* region, OnigOptionType option, - int (*scan_callback)(int, int, OnigRegion*, void*), + int (*scan_callback)(int, OnigPos, OnigRegion*, void*), void* callback_arg) { - int r; + OnigPos r; int n; int rs; const UChar* start; @@ -5827,7 +5859,7 @@ onig_scan(regex_t* reg, const UChar* str, const UChar* end, break; } else { /* error */ - return r; + return (int )r; } } @@ -5958,7 +5990,7 @@ update_regset_by_reg(OnigRegSet* set, regex_t* reg) set->anc_dmin = reg->anc_dist_min; set->anc_dmax = reg->anc_dist_max; set->all_low_high = - (reg->optimize == OPTIMIZE_NONE || reg->dist_max == INFINITE_LEN) ? 0 : 1; + (reg->optimize == OPTIMIZE_NONE || reg->dist_max == INFINITE_SIZE) ? 0 : 1; set->anychar_inf = (reg->anchor & ANCR_ANYCHAR_INF) != 0 ? 1 : 0; } else { @@ -5979,7 +6011,7 @@ update_regset_by_reg(OnigRegSet* set, regex_t* reg) set->anchor = anchor; - if (reg->optimize == OPTIMIZE_NONE || reg->dist_max == INFINITE_LEN) + if (reg->optimize == OPTIMIZE_NONE || reg->dist_max == INFINITE_SIZE) set->all_low_high = 0; if ((reg->anchor & ANCR_ANYCHAR_INF) != 0) @@ -6105,7 +6137,7 @@ onig_regset_get_region(OnigRegSet* set, int at) #ifdef USE_DIRECT_THREADED_CODE -extern int +extern OnigPos onig_init_for_match_at(regex_t* reg) { return match_at(reg, (const UChar* )NULL, (const UChar* )NULL, diff --git a/scintilla/oniguruma/src/regint.h b/scintilla/oniguruma/src/regint.h index 9856a9611..8cdf6befb 100644 --- a/scintilla/oniguruma/src/regint.h +++ b/scintilla/oniguruma/src/regint.h @@ -287,6 +287,10 @@ typedef unsigned __int64 uint64_t; #endif #endif /* _WIN32 */ +typedef size_t OnigSize; + +#define INFINITE_SIZE ~((OnigSize )0) + #if SIZEOF_VOIDP == SIZEOF_LONG typedef unsigned long hash_data_type; #elif SIZEOF_VOIDP == SIZEOF_LONG_LONG @@ -925,7 +929,7 @@ struct re_pattern_buffer { unsigned char map[CHAR_MAP_SIZE]; /* used as BMH skip or char-map */ int map_offset; OnigLen dist_min; /* min-distance of exact or map */ - OnigLen dist_max; /* max-distance of exact or map */ + OnigSize dist_max; /* max-distance of exact or map */ RegexExt* extp; }; @@ -937,7 +941,7 @@ struct re_pattern_buffer { extern void onig_add_end_call(void (*func)(void)); extern void onig_warning(const char* s); -extern UChar* onig_error_code_to_format P_((int code)); +extern UChar* onig_error_code_to_format P_((OnigPos code)); extern void ONIG_VARIADIC_FUNC_ATTR onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...)); extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo)); extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, void* /* CClassNode* */ cc)); diff --git a/scintilla/oniguruma/src/regposix.c b/scintilla/oniguruma/src/regposix.c index 7534d4d70..811f61137 100644 --- a/scintilla/oniguruma/src/regposix.c +++ b/scintilla/oniguruma/src/regposix.c @@ -66,7 +66,7 @@ typedef struct { } O2PERR; static int -onig2posix_error_code(int code) +onig2posix_error_code(OnigPos code) { static const O2PERR o2p[] = { { ONIG_MISMATCH, REG_NOMATCH }, @@ -147,11 +147,13 @@ onig2posix_error_code(int code) }; int i; + int icode; if (code >= 0) return 0; + icode = (int )code; for (i = 0; i < (int )(sizeof(o2p) / sizeof(o2p[0])); i++) { - if (code == o2p[i].onig_err) + if (icode == o2p[i].onig_err) return o2p[i].posix_err; } @@ -197,6 +199,7 @@ onig_posix_regexec(onig_posix_regex_t* reg, const char* str, size_t nmatch, onig_posix_regmatch_t pmatch[], int posix_options) { int r, i, len; + OnigPos pos; UChar* end; onig_posix_regmatch_t* pm; OnigOptionType options; @@ -221,22 +224,22 @@ onig_posix_regexec(onig_posix_regex_t* reg, const char* str, size_t nmatch, ENC_STRING_LEN(ONIG_C(reg)->enc, str, len); end = (UChar* )(str + len); - r = onig_search(ONIG_C(reg), (UChar* )str, end, (UChar* )str, end, - (OnigRegion* )pm, options); + pos = onig_search(ONIG_C(reg), (UChar* )str, end, (UChar* )str, end, + (OnigRegion* )pm, options); - if (r >= 0) { + if (pos >= 0) { r = 0; /* Match */ if (pm != pmatch && pm != NULL) { xmemcpy(pmatch, pm, sizeof(onig_posix_regmatch_t) * nmatch); } } - else if (r == ONIG_MISMATCH) { + else if (pos == ONIG_MISMATCH) { r = REG_NOMATCH; for (i = 0; i < (int )nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = ONIG_REGION_NOTPOS; } else { - r = onig2posix_error_code(r); + r = onig2posix_error_code(pos); } if (pm != pmatch && pm != NULL) diff --git a/scintilla/oniguruma/version.txt b/scintilla/oniguruma/version.txt index aa902ca82..66ce77b7e 100644 --- a/scintilla/oniguruma/version.txt +++ b/scintilla/oniguruma/version.txt @@ -1 +1 @@ -6.9.7 +7.0.0