History

Fix tokenization of TOK_DOTS

We really need to use PEEKC during tokenization so as to skip line continuations automatically.

Michael Matz committed 10 years ago

Commit 8fc5a6a1 parent f85db992 files · +14 −3Browse files

Unified · Split

2 files
  1. tccpp.c +9 −3
  2. tests/tcctest.c +5 −0
tccpp.c+9−3
@@ -2553,9 +2553,15 @@ maybe_newline: · 2552 unmodified lines
25532553 } else if ((isidnum_table['.' - CH_EOF] & IS_ID) != 0) { /* asm mode */
25542554 *--p = c = '.';
25552555 goto parse_ident_fast;
2556− } else if (c == '.' && p[1] == '.') {
2557− p += 2;
2558− tok = TOK_DOTS;
2556+ } else if (c == '.') {
2557+ PEEKC(c, p);
2558+ if (c == '.') {
2559+ p++;
2560+ tok = TOK_DOTS;
2561+ } else {
2562+ *--p = '.'; /* may underflow into file->unget[] */
2563+ tok = '.';
2564+ }
25592565 } else {
25602566 tok = '.';
25612567 }
tests/tcctest.c+5−0
@@ -114,6 +114,11 @@ void num(int n); · 113 unmodified lines
114114 void forward_ref(void);
115115 int isid(int c);
116116
117+/* Line joining happens before tokenization, so the following
118+ must be parsed as ellipsis. */
119+void funny_line_continuation (int, ..\
120+. );
121+
117122 #define A 2
118123 #define N 1234 + A
119124 #define pf printf

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t