diff --git a/PowerEditor/scintilla.original.forUpdating/lexilla542.zip b/PowerEditor/scintilla.original.forUpdating/lexilla543.zip similarity index 73% rename from PowerEditor/scintilla.original.forUpdating/lexilla542.zip rename to PowerEditor/scintilla.original.forUpdating/lexilla543.zip index 40d76b2b1..ecee8844a 100644 Binary files a/PowerEditor/scintilla.original.forUpdating/lexilla542.zip and b/PowerEditor/scintilla.original.forUpdating/lexilla543.zip differ diff --git a/PowerEditor/scintilla.original.forUpdating/scintilla554.zip b/PowerEditor/scintilla.original.forUpdating/scintilla555.zip similarity index 67% rename from PowerEditor/scintilla.original.forUpdating/scintilla554.zip rename to PowerEditor/scintilla.original.forUpdating/scintilla555.zip index 0badd1f17..d9a249ecc 100644 Binary files a/PowerEditor/scintilla.original.forUpdating/scintilla554.zip and b/PowerEditor/scintilla.original.forUpdating/scintilla555.zip differ diff --git a/boostregex/BoostRegExSearch.cxx b/boostregex/BoostRegExSearch.cxx index 76607b11a..dc3125f67 100644 --- a/boostregex/BoostRegExSearch.cxx +++ b/boostregex/BoostRegExSearch.cxx @@ -1,12 +1,12 @@ /** * Copyright (c) since 2009 Simon Steele - http://untidy.net/ * Based on the work of Simon Steele for Programmer's Notepad 2 (http://untidy.net) - * Converted from boost::xpressive to boost::regex and performance improvements + * Converted from boost::xpressive to boost::regex and performance improvements * (principally caching the compiled regex), and support for UTF8 encoded text * (c) 2012 Dave Brotherstone - Changes for boost::regex * (c) 2013 Francois-R.Boyer@PolyMtl.ca - Empty match modes and best match backward search * (c) 2019 Don Ho - Adapt for upgrading Scitilla (to version 4.1.4) and boost (to version 1.70) - * + * */ #include @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "Scintilla.h" #include "ScintillaTypes.h" @@ -54,16 +56,16 @@ class BoostRegexSearch : public RegexSearchBase { public: BoostRegexSearch() {} - + virtual ~BoostRegexSearch() { delete[] _substituted; _substituted = nullptr; } - + virtual Sci::Position FindText(Document* doc, Sci::Position minPos, Sci::Position maxPos, const char *regex, bool caseSensitive, bool word, bool wordStart, Scintilla::FindOption sciSearchFlags, Sci::Position *lengthRet) override; - + virtual const char *SubstituteByPosition(Document* doc, const char *text, Sci::Position *length) override; private: @@ -82,38 +84,38 @@ private: _position = -1; return *this; } - + void set(Document* document = NULL, Sci::Position position = -1, Sci::Position endPosition = -1) { setDocument(document); _position = position; _endPositionForContinuationCheck = _endPosition = endPosition; _documentModified = false; } - + bool isContinuationSearch(Document* document, Sci::Position startPosition, int direction) { if (hasDocumentChanged(document)) return false; - if (direction > 0) + if (direction > 0) return startPosition == _endPositionForContinuationCheck; else return startPosition == _position; } - bool isEmpty() { + bool isEmpty() const { return _position == _endPosition; } - Sci::Position position() { + Sci::Position position() const { return _position; } - Sci::Position endPosition() { + Sci::Position endPosition() const { return _endPosition; } - Sci::Position length() { + Sci::Position length() const { return _endPosition - _position; } - int found() { + int found() const { return _position >= 0; } - + private: bool hasDocumentChanged(Document* currentDocument) { return currentDocument != _document || _documentModified; @@ -128,7 +130,7 @@ private: _document->AddWatcher(this, NULL); } } - + // DocWatcher, so we can track modifications to know if we should consider a search to be a continuation of last search: virtual void NotifyModified(Document* modifiedDocument, DocModification mh, void* /*userData*/) { @@ -156,7 +158,7 @@ private: { if (deletedDocument == _document) { - // We set the _document here, as we don't want to call the RemoveWatcher on this deleted document. + // We set the _document here, as we don't want to call the RemoveWatcher on this deleted document. // Calling RemoveWatcher inside NotifyDeleted results in a crash, as NotifyDeleted is called whilst // iterating on the watchers list (since Scintilla 3.x). Before 3.x, it was just a really bad idea. _document = NULL; @@ -168,13 +170,14 @@ private: virtual void NotifyStyleNeeded(Document* /*document*/, void* /*userData*/, Sci::Position /*endPos*/) {} virtual void NotifyLexerChanged(Document* /*document*/, void* /*userData*/) {} virtual void NotifyErrorOccurred(Document* /*document*/, void* /*userData*/, Scintilla::Status /*status*/) {} - + virtual void NotifyGroupCompleted(Document* /*document*/, void* /*userData*/) noexcept {} + Document* _document; bool _documentModified; Sci::Position _position, _endPosition; Sci::Position _endPositionForContinuationCheck; }; - + class CharTPtr { // Automatically translatable from utf8 to wchar_t*, if required, with allocation and deallocation on destruction; char* is not deallocated. public: CharTPtr(const char* ptr) : _charPtr(ptr), _wcharPtr(NULL) {} @@ -209,20 +212,20 @@ private: typedef CharT Char; typedef basic_regex Regex; typedef match_results MatchResults; - + MatchResults _match; private: Regex _regex; std::string _lastRegexString; int _lastCompileFlags; }; - + class SearchParameters { public: - Sci::Position nextCharacter(Sci::Position position); - bool isLineStart(Sci::Position position); - bool isLineEnd(Sci::Position position); - + Sci::Position nextCharacter(Sci::Position position) const; + bool isLineStart(Sci::Position position) const; + bool isLineEnd(Sci::Position position) const; + Document* _document; const char *_regexString; int _compileFlags; @@ -234,17 +237,17 @@ private: bool _is_allowed_empty_at_start_position; bool _skip_windows_line_end_as_one_character; }; - + static wchar_t *utf8ToWchar(const char *utf8); static char *wcharToUtf8(const wchar_t *w); static char *stringToCharPtr(const std::string& str); static char *stringToCharPtr(const std::wstring& str); - + EncodingDependent _ansi; EncodingDependent _utf8; - + char *_substituted = nullptr; - + Match _lastMatch; int _lastDirection = 0; }; @@ -272,9 +275,9 @@ Sci::Position BoostRegexSearch::FindText(Document* doc, Sci::Position startPosit g_exceptionMessage.clear(); try { SearchParameters search{}; - + search._document = doc; - + if (startPosition > endPosition || (startPosition == endPosition && _lastDirection < 0)) // If we search in an empty region, suppose the direction is the same as last search (this is only important to verify if there can be an empty match in that empty region). { @@ -293,26 +296,26 @@ Sci::Position BoostRegexSearch::FindText(Document* doc, Sci::Position startPosit // Range endpoints should not be inside DBCS characters, but just in case, move them. search._startPosition = doc->MovePositionOutsideChar(search._startPosition, 1, false); search._endPosition = doc->MovePositionOutsideChar(search._endPosition, 1, false); - + const bool isUtf8 = (doc->CodePage() == SC_CP_UTF8); - search._compileFlags = + search._compileFlags = regex_constants::ECMAScript | (caseSensitive ? 0 : regex_constants::icase); search._regexString = regexString; - search._boostRegexFlags = + search._boostRegexFlags = ((static_cast(sciSearchFlags) & SCFIND_REGEXP_DOTMATCHESNL) ? regex_constants::match_default : regex_constants::match_not_dot_newline); - + const int empty_match_style = static_cast(sciSearchFlags) & SCFIND_REGEXP_EMPTYMATCH_MASK; const int allow_empty_at_start = static_cast(sciSearchFlags) & SCFIND_REGEXP_EMPTYMATCH_ALLOWATSTART; search._is_allowed_empty = empty_match_style != SCFIND_REGEXP_EMPTYMATCH_NONE; - search._is_allowed_empty_at_start_position = search._is_allowed_empty && + search._is_allowed_empty_at_start_position = search._is_allowed_empty && (allow_empty_at_start || !_lastMatch.isContinuationSearch(doc, startPosition, search._direction) || (empty_match_style == SCFIND_REGEXP_EMPTYMATCH_ALL && !_lastMatch.isEmpty()) // If last match is empty and this is a continuation, then we would have same empty match at start position, if it was allowed. ); search._skip_windows_line_end_as_one_character = (static_cast(sciSearchFlags) & SCFIND_REGEXP_SKIPCRLFASONE) != 0; - + Match match = isUtf8 ? _utf8.FindText(search) : _ansi.FindText(search); @@ -394,7 +397,7 @@ BoostRegexSearch::Match BoostRegexSearch::EncodingDependent::compileRegex } } -Sci::Position BoostRegexSearch::SearchParameters::nextCharacter(Sci::Position position) +Sci::Position BoostRegexSearch::SearchParameters::nextCharacter(Sci::Position position) const { if (_skip_windows_line_end_as_one_character && _document->CharAt(position) == '\r' && _document->CharAt(position+1) == '\n') return position + 2; @@ -437,14 +440,14 @@ Sci::Position BoostRegexSearch::SearchParameters::nextCharacter(Sci::Position po return _document->NextPosition(position, 1); } -bool BoostRegexSearch::SearchParameters::isLineStart(Sci::Position position) +bool BoostRegexSearch::SearchParameters::isLineStart(Sci::Position position) const { return (position == 0) || _document->CharAt(position-1) == '\n' || (_document->CharAt(position-1) == '\r' && _document->CharAt(position) != '\n'); } -bool BoostRegexSearch::SearchParameters::isLineEnd(Sci::Position position) +bool BoostRegexSearch::SearchParameters::isLineEnd(Sci::Position position) const { return (position == _document->Length()) || _document->CharAt(position) == '\r' diff --git a/boostregex/UTF8DocumentIterator.cxx b/boostregex/UTF8DocumentIterator.cxx index 8e6067ae4..78b5639fa 100644 --- a/boostregex/UTF8DocumentIterator.cxx +++ b/boostregex/UTF8DocumentIterator.cxx @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "ILoader.h" #include "ILexer.h" diff --git a/lexilla/.gitattributes b/lexilla/.gitattributes index 5bfdda95f..25d651539 100644 --- a/lexilla/.gitattributes +++ b/lexilla/.gitattributes @@ -52,6 +52,7 @@ **.nix text **.octave text **.p text +**.pas text **.pl text **.p6 text **.ps1 text diff --git a/lexilla/cppcheck.suppress b/lexilla/cppcheck.suppress index 9da560dd7..7ad8796a3 100644 --- a/lexilla/cppcheck.suppress +++ b/lexilla/cppcheck.suppress @@ -31,7 +31,6 @@ passedByValue missingIncludeSystem // Passing temporary string into hidden object creator functions: they do not hold the argument -danglingTemporaryLifetime:lexilla/access/LexillaAccess.cxx returnDanglingLifetime:lexilla/access/LexillaAccess.cxx // cppcheck 2.11 limits checking of complex functions unless --check-level=exhaustive but that @@ -45,6 +44,9 @@ checkLevelNormal:lexilla/lexers/LexRuby.cxx // Physically but not logically const. constVariablePointer:lexilla/examples/CheckLexilla/CheckLexilla.c +// cppcheck appears to be incorrectly determining control flow: target_end is used after write +unreadVariable:lexilla/lexers/LexRuby.cxx + // Suppress most lexer warnings since the lexers are maintained by others redundantCondition:lexilla/lexers/LexA68k.cxx constParameterReference:lexilla/lexers/LexAbaqus.cxx @@ -61,6 +63,7 @@ constParameterReference:lexilla/lexers/LexBash.cxx knownConditionTrueFalse:lexilla/lexers/LexBash.cxx variableScope:lexilla/lexers/LexBash.cxx constVariable:lexilla/lexers/LexBasic.cxx +constParameterReference:lexilla/lexers/LexBullant.cxx constParameterReference:lexilla/lexers/LexCLW.cxx knownConditionTrueFalse:lexilla/lexers/LexCLW.cxx variableScope:lexilla/lexers/LexCmake.cxx @@ -105,6 +108,7 @@ unreadVariable:lexilla/lexers/LexJulia.cxx variableScope:lexilla/lexers/LexJulia.cxx variableScope:lexilla/lexers/LexLaTeX.cxx constParameterReference:lexilla/lexers/LexLaTeX.cxx +constParameterReference:lexilla/lexers/LexLisp.cxx constParameterPointer:lexilla/lexers/LexMagik.cxx constParameterReference:lexilla/lexers/LexMagik.cxx constParameterReference:lexilla/lexers/LexMarkdown.cxx @@ -147,6 +151,8 @@ redundantInitialization:lexilla/lexers/LexRegistry.cxx constParameterReference:lexilla/lexers/LexRuby.cxx constParameterReference:lexilla/lexers/LexRust.cxx knownConditionTrueFalse:lexilla/lexers/LexScriptol.cxx +constParameterReference:lexilla/lexers/LexScriptol.cxx +constParameterPointer:lexilla/lexers/LexSmalltalk.cxx variableScope:lexilla/lexers/LexSpecman.cxx unreadVariable:lexilla/lexers/LexSpice.cxx constParameterReference:lexilla/lexers/LexSpice.cxx @@ -157,6 +163,7 @@ clarifyCalculation:lexilla/lexers/LexTADS3.cxx constParameterReference:lexilla/lexers/LexTADS3.cxx constParameterReference:lexilla/lexers/LexTAL.cxx constVariableReference:lexilla/lexers/LexTCL.cxx +constParameterPointer:lexilla/lexers/LexTCMD.cxx invalidscanf:lexilla/lexers/LexTCMD.cxx constParameterReference:lexilla/lexers/LexTeX.cxx variableScope:lexilla/lexers/LexTeX.cxx @@ -166,6 +173,7 @@ constParameterReference:lexilla/lexers/LexVerilog.cxx variableScope:lexilla/lexers/LexVerilog.cxx badBitmaskCheck:lexilla/lexers/LexVerilog.cxx uselessCallsSubstr:lexilla/lexers/LexVerilog.cxx +duplicateCondition:lexilla/lexers/LexVerilog.cxx constParameterReference:lexilla/lexers/LexVHDL.cxx constVariable:lexilla/lexers/LexVHDL.cxx shadowVariable:lexilla/lexers/LexVHDL.cxx @@ -191,12 +199,60 @@ constParameterCallback:lexilla/lexers/LexPython.cxx constParameterCallback:lexilla/lexers/LexScriptol.cxx constParameterCallback:lexilla/lexers/LexVB.cxx +constVariableReference:lexilla/lexers/LexA68k.cxx +constVariableReference:lexilla/lexers/LexAPDL.cxx +constVariableReference:lexilla/lexers/LexASY.cxx +constVariableReference:lexilla/lexers/LexAVE.cxx +constVariableReference:lexilla/lexers/LexAVS.cxx +constVariableReference:lexilla/lexers/LexAU3.cxx +constVariableReference:lexilla/lexers/LexAsn1.cxx constVariableReference:lexilla/lexers/LexBibTeX.cxx +constVariableReference:lexilla/lexers/LexCaml.cxx +constVariableReference:lexilla/lexers/LexCLW.cxx +constVariableReference:lexilla/lexers/LexCmake.cxx +constVariableReference:lexilla/lexers/LexCOBOL.cxx +constVariableReference:lexilla/lexers/LexCoffeeScript.cxx +constVariableReference:lexilla/lexers/LexCsound.cxx constVariableReference:lexilla/lexers/LexCSS.cxx constVariableReference:lexilla/lexers/LexCrontab.cxx +constVariableReference:lexilla/lexers/LexDataflex.cxx +constVariableReference:lexilla/lexers/LexDMAP.cxx +constVariableReference:lexilla/lexers/LexECL.cxx +constVariableReference:lexilla/lexers/LexEiffel.cxx +constVariableReference:lexilla/lexers/LexEScript.cxx +constVariableReference:lexilla/lexers/LexErlang.cxx +constVariableReference:lexilla/lexers/LexFlagship.cxx +constVariableReference:lexilla/lexers/LexForth.cxx +constVariableReference:lexilla/lexers/LexFortran.cxx +constVariableReference:lexilla/lexers/LexGAP.cxx constVariableReference:lexilla/lexers/LexGui4Cli.cxx +constVariableReference:lexilla/lexers/LexKix.cxx +constVariableReference:lexilla/lexers/LexKVIrc.cxx +constVariableReference:lexilla/lexers/LexLout.cxx +constVariableReference:lexilla/lexers/LexMagik.cxx +constVariableReference:lexilla/lexers/LexMatlab.cxx constVariableReference:lexilla/lexers/LexMetapost.cxx +constVariableReference:lexilla/lexers/LexMMIXAL.cxx +constVariableReference:lexilla/lexers/LexMSSQL.cxx +constVariableReference:lexilla/lexers/LexNsis.cxx constVariableReference:lexilla/lexers/LexOpal.cxx +constVariableReference:lexilla/lexers/LexPOV.cxx +constVariableReference:lexilla/lexers/LexPascal.cxx +constVariableReference:lexilla/lexers/LexPB.cxx +constVariableReference:lexilla/lexers/LexPowerPro.cxx +constVariableReference:lexilla/lexers/LexPS.cxx +constVariableReference:lexilla/lexers/LexRebol.cxx +constVariableReference:lexilla/lexers/LexSAS.cxx +constVariableReference:lexilla/lexers/LexSML.cxx +constVariableReference:lexilla/lexers/LexSorcus.cxx +constVariableReference:lexilla/lexers/LexSpecman.cxx +constVariableReference:lexilla/lexers/LexStata.cxx +constVariableReference:lexilla/lexers/LexTACL.cxx +constVariableReference:lexilla/lexers/LexTADS3.cxx +constVariableReference:lexilla/lexers/LexTAL.cxx +constVariableReference:lexilla/lexers/LexTCMD.cxx +constVariableReference:lexilla/lexers/LexTeX.cxx +constVariableReference:lexilla/lexers/LexVHDL.cxx // Suppress everything in test example files *:lexilla/test/examples/* diff --git a/lexilla/doc/Lexilla.html b/lexilla/doc/Lexilla.html index 35ffbfb98..f8d4f15da 100644 --- a/lexilla/doc/Lexilla.html +++ b/lexilla/doc/Lexilla.html @@ -9,7 +9,7 @@ - +