X-Git-Url: http://git.scottworley.com/uniqt/blobdiff_plain/63eb64b5b01920499f9ea1a1d16a59eda6f716e3..be6fd520dc5a19a0d08a308cb2152f2d2a14f71f:/uniqt.c diff --git a/uniqt.c b/uniqt.c index 2b7d229..a42a001 100644 --- a/uniqt.c +++ b/uniqt.c @@ -1,4 +1,4 @@ -#define _POSIX_C_SOURCE 199309L +#define _POSIX_C_SOURCE 200809L #include #include @@ -44,6 +44,8 @@ static char *read_line() { int newline = getchar(); if (newline != EOF && newline != (int)'\n') die("Expected newline"); + if (scanf_ret == 0 && newline == (int)'\n') + return strdup("\n"); return line; } @@ -52,6 +54,8 @@ static void write_line(time_range_t *range, char *line) { return; if (printf("%ld %ld %s\n", range->start, range->end, line) < 0) die("Couldn't write"); + if (fflush(stdout) == EOF) + die_err("Couldn't flush"); } static int same(char *a, char *b) { return a && b && strcmp(a, b) == 0; }