diff options
Diffstat (limited to 'src/calendar.c')
-rw-r--r-- | src/calendar.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/calendar.c b/src/calendar.c index 06d80d7..4eabc12 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -60,10 +60,9 @@ static void sub_set_pos(struct state_s *s, struct pos_s p) s->last_col = p.col; } -static bool sub_eat_spaces(struct state_s *s) +static void sub_eat_spaces(struct state_s *s) { int c; - bool seen = false; while (true) { c = getc(s->f); @@ -81,10 +80,22 @@ static bool sub_eat_spaces(struct state_s *s) s->col++; - seen = true; } +} + +static void sub_eat_comment(struct state_s *s) +{ + int c; - return seen; + while (true) { + c = getc(s->f); + + if (c == '\n' || c == EOF) + break; + } + + s->col = 1; + s->line++; } static struct entry_interval_s sub_get_interval(struct state_s *s) @@ -224,6 +235,7 @@ static time_t sub_get_date(struct state_s *s) .tm_mday = 1, .tm_isdst = -1, }; + bool seen = false; sub_set_pos(s, sub_get_pos(s)); @@ -258,11 +270,16 @@ static time_t sub_get_date(struct state_s *s) /* no int found */ if (r == 0) { - ERRP("expected date"); + if (seen) + ERRP("invalid date"); + else + ERRP("expected date"); s->err_flag = true; return rt; } + seen = true; + /* range err interval */ if (l < 0) { ERRP("invalid date"); @@ -828,6 +845,11 @@ struct calendar_s calendar_parse(FILE *f) if (c == EOF) break; + if (c == '#') { + sub_eat_comment(&s); + continue; + } + if (c == '.') { s.col++; cmd = sub_get_cmd(&s); |