mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-17 16:32:37 +00:00
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:
parent
13fedad011
commit
a6a1fb15e7
1 changed files with 11 additions and 1 deletions
|
@ -697,9 +697,19 @@ void History_Init (void)
|
||||||
{
|
{
|
||||||
c = fgetc(hf);
|
c = fgetc(hf);
|
||||||
key_lines[edit_line][i++] = c;
|
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;
|
key_lines[edit_line][i - 1] = 0;
|
||||||
edit_line = (edit_line + 1) & (CMDLINES - 1);
|
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);
|
} while (c != EOF && edit_line < CMDLINES);
|
||||||
fclose(hf);
|
fclose(hf);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue