]> git.scottworley.com Git - uniqt/blobdiff - uniqt.c
Prompt output: Line-buffered
[uniqt] / uniqt.c
diff --git a/uniqt.c b/uniqt.c
index 2b7d229ac94e152d0644877404ec8426c3b5390c..a42a0013cc3c1ca62c806db604bd59e06921de7e 100644 (file)
--- a/uniqt.c
+++ b/uniqt.c
@@ -1,4 +1,4 @@
-#define _POSIX_C_SOURCE 199309L
+#define _POSIX_C_SOURCE 200809L
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -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; }