keys.c (History_Init): filter out '\r' and skip over to the first non-EOL

character. This allows using a windows-generated history.txt file on unix.
based on a patch from Sander van Dijk.

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@523 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2011-12-15 21:41:48 +00:00
parent 13fedad011
commit a6a1fb15e7

View file

@ -697,9 +697,19 @@ void History_Init (void)
{
c = fgetc(hf);
key_lines[edit_line][i++] = c;
} while (c != '\n' && c != EOF && i < MAXCMDLINE);
} while (c != '\r' && c != '\n' && c != EOF && i < MAXCMDLINE);
key_lines[edit_line][i - 1] = 0;
edit_line = (edit_line + 1) & (CMDLINES - 1);
/* for people using a windows-generated history file on unix: */
if (c == '\r' || c == '\n')
{
do
c = fgetc(hf);
while (c == '\r' || c == '\n');
if (c != EOF)
ungetc(c, hf);
else c = 0; /* loop once more, otherwise last line is lost */
}
} while (c != EOF && edit_line < CMDLINES);
fclose(hf);