Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Fixed: backslash characters in savegames skips string chars #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions quakespasm/Quake/pr_edict.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,23 +742,21 @@ static string_t ED_NewString (const char *string)
int i, l;
string_t num;

l = strlen(string) + 1;
num = PR_AllocString (l, &new_p);
l = strlen (string) + 1;
new = Hunk_Alloc (l);
new_p = new;

for (i = 0; i < l; i++)
for (i = 0 ; i < l ; ++i)
{
if (string[i] == '\\' && i < l-1)
if (i < l - 1 && string[i] == '\\' && string[i + 1] == 'n')
{
i++;
if (string[i] == 'n')
*new_p++ = '\n';
else
*new_p++ = '\\';
// converts both characters into a single newline character
++i;
*new_p++ = '\n';
}
else
*new_p++ = string[i];
}

return num;
}

Expand Down