aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-05 21:32:53 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-05 21:32:53 +0100
commitf7e07dcfdb461b8fb997d0711e4d2cf373cfb249 (patch)
treebef18c9b88f943d525c39365712513031c8d8580
parentMade scheme code work again. (diff)
downloadcalp-f7e07dcfdb461b8fb997d0711e4d2cf373cfb249.tar.gz
calp-f7e07dcfdb461b8fb997d0711e4d2cf373cfb249.tar.xz
Add support for NL without preceeding CR.
-rw-r--r--parse.c10
1 files 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); }