aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-20 15:08:38 +0100
committerlemon <lsof@mailbox.org>2025-12-20 15:08:38 +0100
commit96779975f3b8c73e6e1f1e5a07c8c2e386f353ae (patch)
tree0d0c3322c18e1978300e178f11af392ca905fe76
parentabab47e6fc33ae4a3a54c1f7c27a63a2df3c0676 (diff)
c: support CRLF newlines
-rw-r--r--c/lex.c14
1 files changed, 11 insertions, 3 deletions
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);
}