Fix #684, I hope. Redid the case-insensitive Replace All algorithm to replace from a Right side into a Left side, also avoiding use of wx 1.x compatibility functions and doing proper case-insensitive compares rather than searching a lowercased string for a lowercased substring.

Originally committed to SVN as r2204.
This commit is contained in:
Niels Martin Hansen 2008-06-15 17:56:05 +00:00
parent b9d8f72838
commit 59a5e8f3b3

View file

@ -480,14 +480,22 @@ void SearchReplaceEngine::ReplaceAll() {
// Normal replace
else {
if (!Search.matchCase) {
wxString Left, Right;
int pos;
while(Text->Lower().Contains(LookFor.Lower())) {
pos = Text->Lower().Find(LookFor.Lower());
Left = pos ? Text->Left(pos) : _T("");
Right = Text->Mid(pos+LookFor.Len());
*Text = Left + ReplaceWith + Right;
count++;
wxString Left, Right = *Text;
int pos = 0;
while (pos <= (int)(Right.Len() - LookFor.Len())) {
if (Right.Mid(pos, LookFor.Len()).CmpNoCase(LookFor) == 0) {
Left.Append(Right.Mid(0,pos)).Append(ReplaceWith);
Right = Right.Mid(pos+LookFor.Len());
count++;
replaced = true;
pos = 0;
}
else {
pos++;
}
}
if (replaced) {
*Text = Left;
}
}
else {
@ -502,7 +510,6 @@ void SearchReplaceEngine::ReplaceAll() {
if (replaced) {
AssDialogue *cur = grid->GetDialogue(i);
cur->UpdateData();
//cur->ParseASSTags();
}
}