]> diplodocus.org Git - nmh/blobdiff - sbr/icalendar.l
test/inc/test-eom-align: Fix tests; they've never worked.
[nmh] / sbr / icalendar.l
index 016c6ebdfc3ce05a9e514809a765f979e001bbec..11006e79cbb7d41f876c907a6c6f350b3e755f82 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * icalendar.l -- icalendar (RFC 5545) scanner
+/* icalendar.l -- icalendar (RFC 5545) scanner
  *
  * This code is Copyright (c) 2014, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -14,7 +13,7 @@
 #include "sbr/icalparse.h"
 
 static char *unfold (char *, size_t *);
-static void destroy_icallex ();
+static void destroy_icallex(void);
 %}
 
 /*
@@ -258,14 +257,26 @@ folded-value         {VALUE-CHAR}*({fold}{VALUE-CHAR}*)+
 
 . {
     /* By default, flex will just pass unmatched text.  Catch it instead. */
-    advise (NULL, "unexpected input: |%s|\n", icaltext);
+    inform("unexpected input: |%s|\n", icaltext);
 }
 
+<INITIAL>
 <<EOF>> {
+    /* See next rule for when start state is not INITIAL. */
     destroy_icallex ();
     yyterminate ();
 }
 
+<<EOF>> {
+    /* Missing a final newline after a token.  The input does not conform
+       to RFC 5545 ยง 3.1, which requires that each contentline end with a
+       CRLF.  (Assume that the token is at the end of a contentline.)  Be
+       liberal in what we accept by faking a newline here, and setting the
+       start state to terminate on the next call. */
+    BEGIN (INITIAL);
+    return ICAL_CRLF;
+}
+
 %%
 
 static char *
@@ -301,7 +312,7 @@ unfold (char *text, size_t *leng) {
  * with something other than flex.
  */
 static void
-destroy_icallex () {
+destroy_icallex(void) {
 #if defined FLEX_SCANNER  &&  defined YY_FLEX_SUBMINOR_VERSION
     /* Hack:  rely on fact that the the YY_FLEX_SUBMINOR_VERSION
        #define was added to flex (flex.skl v. 2.163) after