mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
This should fix line counting issues with the lexer
This commit is contained in:
parent
7a81848d88
commit
37ff28a3b5
1 changed files with 15 additions and 4 deletions
19
lex.c
19
lex.c
|
@ -77,14 +77,25 @@ static inline void lex_clear(lex_file *file) {
|
|||
* it's own internal state for this.
|
||||
*/
|
||||
static int lex_inget(lex_file *file) {
|
||||
char get;
|
||||
file->length --;
|
||||
if (file->last > 0)
|
||||
return file->peek[--file->last];
|
||||
return fgetc(file->file);
|
||||
|
||||
if (file->last > 0) {
|
||||
if ((get = file->peek[--file->last]) == '\n')
|
||||
file->line ++;
|
||||
return get;
|
||||
}
|
||||
if ((get = fgetc(file->file)) == '\n')
|
||||
file->line++;
|
||||
|
||||
return get;
|
||||
}
|
||||
static void lex_unget(int ch, lex_file *file) {
|
||||
if (file->last < sizeof(file->peek))
|
||||
if (file->last < sizeof(file->peek)) {
|
||||
if (ch == '\n')
|
||||
file->line --;
|
||||
file->peek[file->last++] = ch;
|
||||
}
|
||||
file->length ++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue