]> diplodocus.org Git - nmh/commitdiff
Fixed mhical(1) exit status to reflect return status of icalparse().
authorDavid Levine <levinedl@acm.org>
Sun, 20 Sep 2020 15:20:36 +0000 (11:20 -0400)
committerDavid Levine <levinedl@acm.org>
Sun, 20 Sep 2020 15:20:36 +0000 (11:20 -0400)
Also, removed parser_status as a global:  just use the return status
of icalparse().  And had to change test-mhical to reflect new exit
status from mhical with empty input.

Thanks to Ralph for pointing out that test-mhical previously had an
unnecessary test of the mhical exit status.

h/icalendar.h
sbr/icalparse.y
test/mhical/test-mhical
uip/mhical.c

index 1f76921e9b4814265dc36c0eee6072d4b1cc1868..917339e75bfe2409a1110f7efebdd04f3c8a142f 100644 (file)
@@ -88,7 +88,6 @@ extern int icaldebug;
 int icalparse (void);
 extern vevent vevents;
 int icallex (void);
 int icalparse (void);
 extern vevent vevents;
 int icallex (void);
-extern int parser_status;
 
 /* And this is for the icalendar scanner. */
 extern YYSTYPE icallval;
 
 /* And this is for the icalendar scanner. */
 extern YYSTYPE icallval;
index 0213fa90a3f91583e01b9f3a90397c705bc8d012..bc05139236bdbef23a99fd4cab0551485b3060d3 100644 (file)
@@ -355,8 +355,7 @@ icalerror (const char *error)
         } else {
             inform ("%s", error);
         }
         } else {
             inform ("%s", error);
         }
-        parser_status = -1;
-        return -1;
+        return 1;
     }
 
     return 0;  /* The return value isn't used anyway. */
     }
 
     return 0;  /* The return value isn't used anyway. */
index 768135203f4a99642beefd4a38e3081ff009a7e4..7b75789a03d4f3e6a45a3218649b6bf2ef9a2b72 100755 (executable)
@@ -950,7 +950,7 @@ start_test "invalid line folding"
 
 cat >"$expected" <<'EOF'
 Summary: test
 
 cat >"$expected" <<'EOF'
 Summary: test
-Description: this file does not end with a newline
+Description: test of invalid line folding
 At: Sun, 14 May 2017 13:00 +0000
 To: Sun, 14 May 2017 14:00
 EOF
 At: Sun, 14 May 2017 13:00 +0000
 To: Sun, 14 May 2017 14:00
 EOF
@@ -969,8 +969,8 @@ DTSTAMP:20170514T122300Z
 DTSTART:20170514T130000Z
 DTEND:20170514T140000Z
 SUMMARY:test
 DTSTART:20170514T130000Z
 DTEND:20170514T140000Z
 SUMMARY:test
-DESCRIPTION:this file does not end with a newline
-and this line is not folded,
+DESCRIPTION:test of invalid line folding
+where this line is not folded,
 END:VEVENT
 END:VCALENDAR" | TZ=UTC mhical >"$actual" 2>"$actual_err"
 set -e
 END:VEVENT
 END:VCALENDAR" | TZ=UTC mhical >"$actual" 2>"$actual_err"
 set -e
@@ -980,7 +980,7 @@ check "$expected_err" "$actual_err"
 
 # check null input
 start_test "null input"
 
 # check null input
 start_test "null input"
-check_exit '-eq 0' mhical </dev/null
+check_exit '-eq 1' mhical </dev/null
 
 
 # check timezone boundary at transition from daylight saving time, -2SU
 
 
 # check timezone boundary at transition from daylight saving time, -2SU
index 078ad37ec66d11c8bad3d27a6807b689ab6584cd..d859744541435579f61ec26f94cb902d74157380 100644 (file)
@@ -68,7 +68,6 @@ DEFINE_SWITCH_ARRAY(MHICAL, switches);
 #undef X
 
 vevent vevents = { NULL, NULL, NULL};
 #undef X
 
 vevent vevents = { NULL, NULL, NULL};
-int parser_status = 0;
 
 int
 main (int argc, char *argv[])
 
 int
 main (int argc, char *argv[])
@@ -88,6 +87,7 @@ main (int argc, char *argv[])
     vevent *v, *nextvevent;
     char *form = "mhical.24hour", *format = NULL;
     char **argp, **arguments, *cp;
     vevent *v, *nextvevent;
     char *form = "mhical.24hour", *format = NULL;
     char **argp, **arguments, *cp;
+    int parser_status = 0;
 
     icaldebug = 0;  /* Global provided by bison (with name-prefix "ical"). */
 
 
     icaldebug = 0;  /* Global provided by bison (with name-prefix "ical"). */
 
@@ -207,7 +207,7 @@ main (int argc, char *argv[])
 
     vevents.last = &vevents;
     /* vevents is accessed by parser as global. */
 
     vevents.last = &vevents;
     /* vevents is accessed by parser as global. */
-    icalparse ();
+    parser_status += icalparse();
 
     for (v = &vevents; v; v = nextvevent) {
         if (! unfold  &&  v != &vevents  &&  v->contentlines  &&
 
     for (v = &vevents; v; v = nextvevent) {
         if (! unfold  &&  v != &vevents  &&  v->contentlines  &&