support empty line at the end of the file - ics2txt - convert icalendar .ics fi… | |
git clone git://bitreich.org/ics2txt git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit d10df705caaa2ca4e3229af6d5ec76e0f0d301da | |
parent cf0323aa059bf54b2a88046d7e6e17efe16f9a2e | |
Author: Josuah Demangeon <[email protected]> | |
Date: Mon, 14 Jun 2021 08:31:43 +0200 | |
support empty line at the end of the file | |
Diffstat: | |
M ical.c | 16 +++++++++------- | |
1 file changed, 9 insertions(+), 7 deletions(-) | |
--- | |
diff --git a/ical.c b/ical.c | |
@@ -131,7 +131,6 @@ hook_block_begin(IcalParser *p, char *name) | |
return ical_error(p, "max recurion reached"); | |
if (!Xstrlcpy(p->current->name, name)) | |
return ical_error(p, "value too large"); | |
- | |
return 0; | |
} | |
@@ -143,7 +142,6 @@ hook_block_end(IcalParser *p, char *name) | |
p->current--; | |
if (p->current < p->stack) | |
return ical_error(p, "more END: than BEGIN:"); | |
- | |
return 0; | |
} | |
@@ -260,22 +258,25 @@ ical_parse(IcalParser *p, FILE *fp) | |
while (!feof(fp)) { | |
if ((contentline = realloc(contentline, 1)) == NULL) | |
- return -1; | |
+ return ical_error(p, strerror(errno)); | |
*contentline = '\0'; | |
do { | |
do { | |
p->linenum++; | |
- if (getline(&ln, &sz, fp) <= 0) | |
- return -1; | |
+ if (getline(&ln, &sz, fp) <= 0) { | |
+ if (ferror(fp)) | |
+ return ical_error(p, strerror(… | |
+ goto end; | |
+ } | |
strchomp(ln); | |
} while (*ln == '\0'); | |
if (strappend(&contentline, ln) < 0) | |
- return -1; | |
+ return ical_error(p, strerror(errno)); | |
if ((c = fgetc(fp)) == EOF) { | |
if (ferror(fp)) | |
- return -1; | |
+ return ical_error(p, strerror(errno)); | |
goto done; | |
} | |
} while (c == ' '); | |
@@ -285,6 +286,7 @@ done: | |
if ((err = ical_parse_contentline(p, contentline)) != 0) | |
break; | |
} | |
+end: | |
free(contentline); | |
free(ln); | |
return err; |