aboutsummaryrefslogtreecommitdiffhomepage
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/io.c b/io.c
index c6e94d1..dcfbd08 100644
--- a/io.c
+++ b/io.c
@@ -57,6 +57,24 @@ BOOL infile_eof(InFile* f) {
char infile_peek_char(InFile* f) {
char c = f->buf[f->pos];
+
+ // Skip a pair of backslash and new-line.
+ if (c == '\\') {
+ char c2 = f->buf[f->pos + 1];
+ // C23: 5.1.1.2
+ // A source file that is not empty shall end in a new-line character,
+ // which shall not be immediately preceded by a backslash character
+ // before any such splicing takes place.
+ if (c2 == '\0') {
+ fatal_error("%s:%d: <new-line> expected, but got <eof>", f->loc.filename, f->loc.line);
+ }
+ // TODO: crlf
+ if (c2 == '\r' || c2 == '\n') {
+ f->pos += 2;
+ return infile_peek_char(f);
+ }
+ }
+
// Normalize new-line.
// TODO: crlf
if (c == '\r')