From f7e07dcfdb461b8fb997d0711e4d2cf373cfb249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 5 Feb 2019 21:32:53 +0100 Subject: Add support for NL without preceeding CR. --- parse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/parse.c b/parse.c index ca0e68c2..30d7bb79 100644 --- a/parse.c +++ b/parse.c @@ -42,11 +42,17 @@ int parse_file(char* fname, FILE* f, vcalendar* cal) { * end. The following character should always be \n. * However, if the first character on the next line is a * whitespace then the two lines should be concatenated. + * + * NOTE + * The above is true according to the standard. But I have + * found files with only NL. The code below ends line on the + * first of NL or CR, and then ensures that the program thinks + * it got the expected CRNL. */ - if (c == '\r') { + if (c == '\r' || c == '\n') { char s[2]; - s[0] = fgetc(f); + s[0] = (c == '\n' ? '\n' : fgetc(f)); s[1] = fgetc(f); if (s[0] != '\n') { ERR_F("%s, %i", "expected newline after CR", line); } -- cgit v1.2.3