-/*
- * icalparse.y -- icalendar (RFC 5545) parser
+/* icalparse.y -- icalendar (RFC 5545) parser
*
* This code is Copyright (c) 2014, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
#include "h/utils.h"
static char *append (contentline *, const char *, const size_t);
-static void new_input_line (contentline **);
+static void new_content_line (contentline **);
static void new_vevent (vevent *);
static void free_param_names (param_list *);
static void free_param_values (value_list *);
/* contentline = name *(";" param ) ":" value CRLF */
contentline
: ICAL_NAME {
- new_input_line (&vevents.last->contentlines);
+ new_content_line (&vevents.last->contentlines);
append (vevents.last->contentlines->last, $1, strlen ($1));
vevents.last->contentlines->last->name = $1;
} ICAL_COLON {
}
}
| ICAL_NAME {
- new_input_line (&vevents.last->contentlines);
+ new_content_line (&vevents.last->contentlines);
append (vevents.last->contentlines->last, $1, strlen ($1));
vevents.last->contentlines->last->name = $1;
} param_list ICAL_COLON {
contentline *new_node;
NEW0(new_node);
- new_node->name = strdup (name);
+ new_node->name = mh_xstrdup (name);
new_node->next = node->next;
node->next = new_node;
while (len >= cline->input_line_size) {
cline->input_line_size = cline->input_line_size == 0
- ? (BUFSIZ>=8192 ? BUFSIZ : 8192)
+ ? NMH_BUFSIZ
: 2 * cline->input_line_size;
cline->input_line =
mh_xrealloc (cline->input_line, cline->input_line_size);
}
static void
-new_input_line (contentline **cline) {
+new_content_line (contentline **cline) {
contentline *new_node;
NEW0(new_node);
}
free (i->value);
free (i->input_line);
+ charstring_free (i->unexpected);
next = i->next;
free (i);
}
static int
icalerror (const char *error) {
+ contentline *c;
+ charstring_t context = NULL;
+
+ /* Find last chunk of unexpected text. */
+ for (c = vevents.last->contentlines; c; c = c->next) {
+ if (c->unexpected) {
+ context = c->unexpected;
+ }
+ }
+
if (! strcmp ("syntax error, unexpected $end, expecting ICAL_NAME",
error)) {
/* Empty input: produce no output. */
} else {
- adios (NULL, "%s", error);
+ if (context) {
+ inform ("%s after \"%s\"", error, charstring_buffer (context));
+ } else {
+ inform ("%s", error);
+ }
+ parser_status = -1;
+ return -1;
}
return 0; /* The return value isn't used anyway. */