- merge whitespaces before comparing Dehacked texts

With introduction of localization support, several strings are no longer identical to the original messages
Double spaces were removed, and letter case was changed
The latter is already handled, extra whitespaces are now deleted to deal with the former

https://forum.zdoom.org/viewtopic.php?t=69236
This commit is contained in:
alexey.lysiuk 2020-07-12 11:07:49 +03:00
parent 6e79209931
commit fcb6e1b18c
1 changed files with 9 additions and 18 deletions

View File

@ -2191,22 +2191,18 @@ static int PatchText (int oldSize)
} }
newSize = atoi (temp); newSize = atoi (temp);
oldStr = new char[oldSize + 1]; FString oldStrData, newStrData;
newStr = new char[newSize + 1]; oldStr = oldStrData.LockNewBuffer(oldSize + 1);
newStr = newStrData.LockNewBuffer(newSize + 1);
if (!oldStr || !newStr)
{
Printf ("Out of memory.\n");
goto donewithtext;
}
good = ReadChars (&oldStr, oldSize); good = ReadChars (&oldStr, oldSize);
good += ReadChars (&newStr, newSize); good += ReadChars (&newStr, newSize);
oldStrData.UnlockBuffer();
newStrData.UnlockBuffer();
if (!good) if (!good)
{ {
delete[] newStr;
delete[] oldStr;
Printf ("Unexpected end-of-file.\n"); Printf ("Unexpected end-of-file.\n");
return 0; return 0;
} }
@ -2271,11 +2267,11 @@ static int PatchText (int oldSize)
const char *str; const char *str;
do do
{ {
oldStrData.MergeChars(' ');
str = EnglishStrings.MatchString(oldStr); str = EnglishStrings.MatchString(oldStr);
if (str != NULL) if (str != NULL)
{ {
FString newname = newStr; TableElement te = { LumpFileNum, { newStrData, newStrData, newStrData, newStrData } };
TableElement te = { LumpFileNum, { newname, newname, newname, newname } };
DehStrings.Insert(str, te); DehStrings.Insert(str, te);
EnglishStrings.Remove(str); // remove entry so that it won't get found again by the next iteration or by another replacement later EnglishStrings.Remove(str); // remove entry so that it won't get found again by the next iteration or by another replacement later
good = true; good = true;
@ -2289,11 +2285,6 @@ static int PatchText (int oldSize)
} }
donewithtext: donewithtext:
if (newStr)
delete[] newStr;
if (oldStr)
delete[] oldStr;
// Fetch next identifier for main loop // Fetch next identifier for main loop
while ((result = GetLine ()) == 1) while ((result = GetLine ()) == 1)
; ;