Fix Find in Files crash
This commit is contained in:
parent
6d311e102e
commit
993506af0a
|
@ -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)
|
if (nullptr == wcharStr2Convert)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -462,8 +462,8 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, si
|
||||||
|
|
||||||
if (*mstart < lstrlenW(wcharStr2Convert) && *mend < lstrlenW(wcharStr2Convert))
|
if (*mstart < lstrlenW(wcharStr2Convert) && *mend < lstrlenW(wcharStr2Convert))
|
||||||
{
|
{
|
||||||
*mstart = WideCharToMultiByte(cp, 0, wcharStr2Convert, *mstart, NULL, 0, NULL, NULL);
|
*mstart = WideCharToMultiByte(cp, 0, wcharStr2Convert, (int)*mstart, NULL, 0, NULL, NULL);
|
||||||
*mend = WideCharToMultiByte(cp, 0, wcharStr2Convert, *mend, NULL, 0, NULL, NULL);
|
*mend = WideCharToMultiByte(cp, 0, wcharStr2Convert, (int)*mend, NULL, 0, NULL, NULL);
|
||||||
if (*mstart >= len || *mend >= len)
|
if (*mstart >= len || *mend >= len)
|
||||||
{
|
{
|
||||||
*mstart = 0;
|
*mstart = 0;
|
||||||
|
|
|
@ -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 *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 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, 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)
|
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn = -1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4065,8 +4065,8 @@ void Finder::add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline)
|
||||||
wsprintf(lnb, TEXT("%d"), static_cast<int>(fi._lineNumber));
|
wsprintf(lnb, TEXT("%d"), static_cast<int>(fi._lineNumber));
|
||||||
str += lnb;
|
str += lnb;
|
||||||
str += TEXT(": ");
|
str += TEXT(": ");
|
||||||
mi._start += static_cast<int32_t>(str.length());
|
mi._start += str.length();
|
||||||
mi._end += static_cast<int32_t>(str.length());
|
mi._end += str.length();
|
||||||
str += foundline;
|
str += foundline;
|
||||||
|
|
||||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||||
|
|
|
@ -2330,7 +2330,7 @@ void ScintillaEditView::addGenericText(const TCHAR * text2Append) const
|
||||||
execute(SCI_ADDTEXT, strlen(text2AppendA), reinterpret_cast<LPARAM>(text2AppendA));
|
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();
|
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||||
size_t cp = execute(SCI_GETCODEPAGE);
|
size_t cp = execute(SCI_GETCODEPAGE);
|
||||||
|
|
|
@ -248,7 +248,7 @@ public:
|
||||||
intptr_t searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
|
intptr_t searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
|
||||||
void appandGenericText(const TCHAR * text2Append) const;
|
void appandGenericText(const TCHAR * text2Append) const;
|
||||||
void addGenericText(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 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;
|
intptr_t replaceTargetRegExMode(const TCHAR * re, intptr_t fromTargetPos = -1, intptr_t toTargetPos = -1) const;
|
||||||
void showAutoComletion(size_t lenEntered, const TCHAR * list);
|
void showAutoComletion(size_t lenEntered, const TCHAR * list);
|
||||||
|
|
|
@ -1279,12 +1279,12 @@ struct SCNotification {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SearchResultMarking {
|
struct SearchResultMarking {
|
||||||
long _start;
|
intptr_t _start;
|
||||||
long _end;
|
intptr_t _end;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SearchResultMarkings {
|
struct SearchResultMarkings {
|
||||||
long _length;
|
intptr_t _length;
|
||||||
SearchResultMarking *_markings;
|
SearchResultMarking *_markings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -104,13 +104,16 @@ static void ColouriseSearchResultDoc(Sci_PositionU startPos, Sci_Position length
|
||||||
unsigned int linePos = 0;
|
unsigned int linePos = 0;
|
||||||
size_t startLine = startPos;
|
size_t startLine = startPos;
|
||||||
|
|
||||||
const char *addrMarkingsStruct = (styler.pprops)->Get("@MarkingsStruct");
|
const char* addrMarkingsStruct = (styler.pprops)->Get("@MarkingsStruct");
|
||||||
if (!addrMarkingsStruct || !addrMarkingsStruct[0])
|
if (!addrMarkingsStruct || !addrMarkingsStruct[0])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SearchResultMarkings* pMarkings = NULL;
|
SearchResultMarkings* pMarkings = NULL;
|
||||||
sscanf(addrMarkingsStruct, "%p", (void**)&pMarkings);
|
sscanf(addrMarkingsStruct, "%p", (void**)&pMarkings);
|
||||||
|
|
||||||
|
if (!pMarkings || !pMarkings->_markings)
|
||||||
|
return;
|
||||||
|
|
||||||
for (size_t i = startPos; i < startPos + length; i++) {
|
for (size_t i = startPos; i < startPos + length; i++) {
|
||||||
lineBuffer[linePos++] = styler[i];
|
lineBuffer[linePos++] = styler[i];
|
||||||
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
|
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++;
|
while (!AtEOL(styler, i)) i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linePos > 0) { // Last line does not have ending characters
|
if (linePos > 0) { // Last line does not have ending characters
|
||||||
ColouriseSearchResultLine(pMarkings, lineBuffer, startLine, startPos + length - 1, styler, styler.GetLine(startLine));
|
ColouriseSearchResultLine(pMarkings, lineBuffer, startLine, startPos + length - 1, styler, styler.GetLine(startLine));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue