diff options
| author | 2025-12-20 15:08:38 +0100 | |
|---|---|---|
| committer | 2025-12-20 15:08:38 +0100 | |
| commit | 96779975f3b8c73e6e1f1e5a07c8c2e386f353ae (patch) | |
| tree | 0d0c3322c18e1978300e178f11af392ca905fe76 /c/lex.c | |
| parent | abab47e6fc33ae4a3a54c1f7c27a63a2df3c0676 (diff) | |
c: support CRLF newlines
Diffstat (limited to 'c/lex.c')
| -rw-r--r-- | c/lex.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -23,12 +23,20 @@ fillchrbuf(struct lexer *lx) uchar c; /* skip backslash-newline* */ for (;;) { - if (p[0] == '\\' && p[1] == '\n') { - idx += 2; - p += 2; + if (p[0] == '\\') { + if (p[1] == '\n') { + idx += 2; + p += 2; + } else if (p[1] == '\r' && p[2] == '\n') { + idx += 3; + p += 3; + } else break; } else if (ccopt.trigraph && !memcmp(p, "\?\?/\n", 4)) { idx += 4; p += 4; + } else if (ccopt.trigraph && !memcmp(p, "\?\?/\r\n", 5)) { + idx += 5; + p += 5; } else break; addfileline(lx->fileid, idx); } |