Browse Source

Fix Find in Files crash

pull/11115/head
Don Ho 3 years ago
parent
commit
993506af0a
  1. 6
      PowerEditor/src/MISC/Common/Common.cpp
  2. 2
      PowerEditor/src/MISC/Common/Common.h
  3. 4
      PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
  4. 2
      PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
  5. 2
      PowerEditor/src/ScintillaComponent/ScintillaEditView.h
  6. 6
      scintilla/include/Scintilla.h
  7. 6
      scintilla/lexers/LexSearchResult.cxx

6
PowerEditor/src/MISC/Common/Common.cpp

@ -449,7 +449,7 @@ const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, siz
}
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, long* mstart, long* mend)
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, intptr_t* mstart, intptr_t* mend)
{
if (nullptr == wcharStr2Convert)
return nullptr;
@ -462,8 +462,8 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, si
if (*mstart < lstrlenW(wcharStr2Convert) && *mend < lstrlenW(wcharStr2Convert))
{
*mstart = WideCharToMultiByte(cp, 0, wcharStr2Convert, *mstart, NULL, 0, NULL, NULL);
*mend = WideCharToMultiByte(cp, 0, wcharStr2Convert, *mend, NULL, 0, NULL, NULL);
*mstart = WideCharToMultiByte(cp, 0, wcharStr2Convert, (int)*mstart, NULL, 0, NULL, NULL);
*mend = WideCharToMultiByte(cp, 0, wcharStr2Convert, (int)*mend, NULL, 0, NULL, NULL);
if (*mstart >= len || *mend >= len)
{
*mstart = 0;

2
PowerEditor/src/MISC/Common/Common.h

@ -97,7 +97,7 @@ public:
const wchar_t * char2wchar(const char *mbStr, size_t codepage, int lenMbcs =-1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL);
const wchar_t * char2wchar(const char *mbcs2Convert, size_t codepage, intptr_t* mstart, intptr_t* mend);
const char * wchar2char(const wchar_t *wcStr, size_t codepage, int lenIn = -1, int* pLenOut = NULL);
const char * wchar2char(const wchar_t *wcStr, size_t codepage, long* mstart, long* mend);
const char * wchar2char(const wchar_t *wcStr, size_t codepage, intptr_t* mstart, intptr_t* mend);
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn = -1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL)
{

4
PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp

@ -4065,8 +4065,8 @@ void Finder::add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline)
wsprintf(lnb, TEXT("%d"), static_cast<int>(fi._lineNumber));
str += lnb;
str += TEXT(": ");
mi._start += static_cast<int32_t>(str.length());
mi._end += static_cast<int32_t>(str.length());
mi._start += str.length();
mi._end += str.length();
str += foundline;
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();

2
PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp

@ -2330,7 +2330,7 @@ void ScintillaEditView::addGenericText(const TCHAR * text2Append) const
execute(SCI_ADDTEXT, strlen(text2AppendA), reinterpret_cast<LPARAM>(text2AppendA));
}
void ScintillaEditView::addGenericText(const TCHAR * text2Append, long* mstart, long* mend) const
void ScintillaEditView::addGenericText(const TCHAR * text2Append, intptr_t* mstart, intptr_t* mend) const
{
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
size_t cp = execute(SCI_GETCODEPAGE);

2
PowerEditor/src/ScintillaComponent/ScintillaEditView.h

@ -248,7 +248,7 @@ public:
intptr_t searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
void appandGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append) const;
void addGenericText(const TCHAR * text2Append, long* mstart, long* mend) const;
void addGenericText(const TCHAR * text2Append, intptr_t* mstart, intptr_t* mend) const;
intptr_t replaceTarget(const TCHAR * str2replace, intptr_t fromTargetPos = -1, intptr_t toTargetPos = -1) const;
intptr_t replaceTargetRegExMode(const TCHAR * re, intptr_t fromTargetPos = -1, intptr_t toTargetPos = -1) const;
void showAutoComletion(size_t lenEntered, const TCHAR * list);

6
scintilla/include/Scintilla.h

@ -1279,12 +1279,12 @@ struct SCNotification {
};
struct SearchResultMarking {
long _start;
long _end;
intptr_t _start;
intptr_t _end;
};
struct SearchResultMarkings {
long _length;
intptr_t _length;
SearchResultMarking *_markings;
};

6
scintilla/lexers/LexSearchResult.cxx

@ -104,13 +104,16 @@ static void ColouriseSearchResultDoc(Sci_PositionU startPos, Sci_Position length
unsigned int linePos = 0;
size_t startLine = startPos;
const char *addrMarkingsStruct = (styler.pprops)->Get("@MarkingsStruct");
const char* addrMarkingsStruct = (styler.pprops)->Get("@MarkingsStruct");
if (!addrMarkingsStruct || !addrMarkingsStruct[0])
return;
SearchResultMarkings* pMarkings = NULL;
sscanf(addrMarkingsStruct, "%p", (void**)&pMarkings);
if (!pMarkings || !pMarkings->_markings)
return;
for (size_t i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
@ -122,6 +125,7 @@ static void ColouriseSearchResultDoc(Sci_PositionU startPos, Sci_Position length
while (!AtEOL(styler, i)) i++;
}
}
if (linePos > 0) { // Last line does not have ending characters
ColouriseSearchResultLine(pMarkings, lineBuffer, startLine, startPos + length - 1, styler, styler.GetLine(startLine));
}

Loading…
Cancel
Save