mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-13 22:34:16 +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: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@523 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
c28e767afb
commit
94117294f7
1 changed files with 11 additions and 1 deletions
12
Quake/keys.c
12
Quake/keys.c
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue