Scan libraries: fix long strings handling

This commit is contained in:
Abs62 2011-09-30 14:04:53 +04:00
parent dafed89b90
commit fa7247100a

View file

@ -69,7 +69,7 @@ void ConvertToMatchedWordA(TEverythingParams *TP)
} }
} }
TP->MatchedWordW[TP->WordLen] = 0; TP->MatchedWordW[TP->WordLen] = 0;
BufSize = sizeof(TP->MatchedWordA) - TP->BeginPos - 1; BufSize = sizeof(TP->MatchedWordA) - TP->BeginPos;
if( BufSize > 0) if( BufSize > 0)
TP->WordLen = WideCharToMultiByte(CP_UTF8, 0, TP->MatchedWordW + BeginPos, TP->WordLen - BeginPos + 1, TP->MatchedWordA + TP->BeginPos, BufSize, NULL, NULL); TP->WordLen = WideCharToMultiByte(CP_UTF8, 0, TP->MatchedWordW + BeginPos, TP->WordLen - BeginPos + 1, TP->MatchedWordA + TP->BeginPos, BufSize, NULL, NULL);
else TP->WordLen = 0; else TP->WordLen = 0;
@ -238,6 +238,7 @@ static void IsInsidePointA(const HDC DC, int X, int Y, LPCSTR Str, int Count)
if (((Rect.left <= Rect.right) && (CurParams->Pt.x >= Rect.left) && (CurParams->Pt.x <= Rect.right)) || if (((Rect.left <= Rect.right) && (CurParams->Pt.x >= Rect.left) && (CurParams->Pt.x <= Rect.right)) ||
((Rect.left > Rect.right) && (CurParams->Pt.x <= Rect.left) && (CurParams->Pt.x >= Rect.right))) { ((Rect.left > Rect.right) && (CurParams->Pt.x <= Rect.left) && (CurParams->Pt.x >= Rect.right))) {
int BegPos; int BegPos;
int Shift = 0;
//if (PtInRect(&Rect, CurParams->Pt)) { //if (PtInRect(&Rect, CurParams->Pt)) {
CurParams->Active = !PtInRect(&Rect, CurParams->Pt); CurParams->Active = !PtInRect(&Rect, CurParams->Pt);
@ -249,14 +250,24 @@ static void IsInsidePointA(const HDC DC, int X, int Y, LPCSTR Str, int Count)
BegPos--; BegPos--;
if (BegPos < Count - 1) if (BegPos < Count - 1)
BegPos++; BegPos++;
if( Count > 255 ) {
Shift = BegPos - 127;
if( Shift <= 0 )
Shift = 0;
else {
if( Shift > Count - 255 )
Shift = Count - 255;
}
BegPos -= Shift;
Count -= Shift;
if( Count > 255 )
Count = 255;
}
if (BegPos>255) BegPos=255; if (BegPos>255) BegPos=255;
CurParams->BeginPos = BegPos; CurParams->BeginPos = BegPos;
if (Count > 255)
CurParams->WordLen = 255;
else
CurParams->WordLen = Count; CurParams->WordLen = Count;
CurParams->Unicode = FALSE; CurParams->Unicode = FALSE;
CopyMemory(CurParams->MatchedWordA, Str, CurParams->WordLen); CopyMemory(CurParams->MatchedWordA, Str + Shift, CurParams->WordLen);
} }
} }
} }
@ -300,6 +311,7 @@ static void IsInsidePointW(const HDC DC, int X, int Y, LPCWSTR Str, int Count)
if (((Rect.left <= Rect.right) && (CurParams->Pt.x >= Rect.left) && (CurParams->Pt.x <= Rect.right)) || if (((Rect.left <= Rect.right) && (CurParams->Pt.x >= Rect.left) && (CurParams->Pt.x <= Rect.right)) ||
((Rect.left > Rect.right) && (CurParams->Pt.x <= Rect.left) && (CurParams->Pt.x >= Rect.right))) { ((Rect.left > Rect.right) && (CurParams->Pt.x <= Rect.left) && (CurParams->Pt.x >= Rect.right))) {
int BegPos; int BegPos;
int Shift = 0;
//if (PtInRect(&Rect, CurParams->Pt)) { //if (PtInRect(&Rect, CurParams->Pt)) {
CurParams->Active = !PtInRect(&Rect, CurParams->Pt); CurParams->Active = !PtInRect(&Rect, CurParams->Pt);
@ -311,14 +323,24 @@ static void IsInsidePointW(const HDC DC, int X, int Y, LPCWSTR Str, int Count)
BegPos--; BegPos--;
if (BegPos < Count - 1) if (BegPos < Count - 1)
BegPos++; BegPos++;
if( Count > 255 ) {
Shift = BegPos - 127;
if( Shift <= 0 )
Shift = 0;
else {
if( Shift > Count - 255 )
Shift = Count - 255;
}
BegPos -= Shift;
Count -= Shift;
if( Count > 255 )
Count = 255;
}
if (BegPos>255) BegPos=255; if (BegPos>255) BegPos=255;
CurParams->BeginPos = BegPos; CurParams->BeginPos = BegPos;
if (Count > 255)
CurParams->WordLen = 255;
else
CurParams->WordLen = Count; CurParams->WordLen = Count;
CurParams->Unicode = TRUE; CurParams->Unicode = TRUE;
CopyMemory(CurParams->MatchedWordW, Str, CurParams->WordLen * sizeof(wchar_t)); CopyMemory(CurParams->MatchedWordW, Str + Shift, CurParams->WordLen * sizeof(wchar_t));
} }
} }
} }