Undo action of a get() lookahead call. An attempt at undoing an EOF read has no effect. Since get() encodes logical line endings with \n and continuation line endings with \r, both could be subject to an unget(). */
| 385 | line endings with \r, both could be subject to an unget(). |
| 386 | */ |
| 387 | void unget(int cc) |
| 388 | { |
| 389 | if (cc == EOF) return; |
| 390 | if (buffered < MAX_BUF) { |
| 391 | if (cc == '\n' || cc == '\r') { |
| 392 | linenr--; |
| 393 | // column was 0 right after getting the \n |
| 394 | // hopefully there are no multiple ungets of \n |
| 395 | column = saved_col; |
| 396 | } |
| 397 | else |
| 398 | column--; |
| 399 | char_count--; |
| 400 | buffer[buffered++] = cc; |
| 401 | } |
| 402 | else { |
| 403 | fprintf(stderr, "(F): Lookahead buffer overflow (MAX=%u).\n", MAX_BUF); |
| 404 | exit(2); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | /* Either set this file's input language explicitly via a string or |
| 409 | use the filename extension to determine the language. |
no outgoing calls
no test coverage detected