]> git.pond.sub.org Git - empserver/commitdiff
Fix read_schedule() not to fclose(stdin)
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 29 Oct 2011 12:51:37 +0000 (14:51 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 29 Dec 2011 10:47:04 +0000 (11:47 +0100)
Did that since the initial commit 71320ed6, v4.3.10.

src/lib/common/rdsched.c

index 4065a42348418337ac523a60c970c5279018dfa8..62a52200d3d1a9b513c9cde7d77877c446fef52f 100644 (file)
@@ -27,7 +27,7 @@
  *  rdsched.c: Read update schedule
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2007-2010
+ *     Markus Armbruster, 2007-2011
  */
 
 #define _XOPEN_SOURCE 500
@@ -74,10 +74,8 @@ read_schedule(char *fname, time_t sched[], int n, time_t t0, time_t anchor)
                     fname, strerror(errno));
            return -1;
        }
-    } else {
+    } else
        fp = stdin;
-       fname = "<stdin>";
-    }
 
     ret = lno = 0;
     sched[0] = 0;
@@ -86,13 +84,15 @@ read_schedule(char *fname, time_t sched[], int n, time_t t0, time_t anchor)
        endp = strchr(buf, '#');
        if (endp)
            *endp = 0;
-       if (parse_schedule_line(buf, sched, n, t0, &anchor, fname, lno)) {
+       if (parse_schedule_line(buf, sched, n, t0, &anchor,
+                               fname ? fname : "<stdin>", lno)) {
            ret = -1;
            break;
        }
     }
 
-    fclose(fp);
+    if (fname)
+       fclose(fp);
     return ret;
 }