From 96779975f3b8c73e6e1f1e5a07c8c2e386f353ae Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 20 Dec 2025 15:08:38 +0100 Subject: c: support CRLF newlines --- c/lex.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'c/lex.c') diff --git a/c/lex.c b/c/lex.c index 99db463..5c627f1 100644 --- a/c/lex.c +++ b/c/lex.c @@ -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); } -- cgit v1.2.3