]> the.earth.li Git - onak.git/commitdiff
cscvs to tla changeset 93
authorJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:53 +0000 (23:47 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:53 +0000 (23:47 +0000)
Author: noodles
Date: 2003/09/28 20:33:34
Fix stupid bug where we always read at least one byte from stdin, even if we
wanted none.

onak.c

diff --git a/onak.c b/onak.c
index bba213b57b703c9cabed79165bde3631716f8134..903c8f0f7c16b56e1168e1e1a1f302be1f24265f 100644 (file)
--- a/onak.c
+++ b/onak.c
@@ -7,7 +7,7 @@
  * 
  * Copyright 2002 Project Purple
  *
- * $Id: onak.c,v 1.14 2003/06/07 13:37:33 noodles Exp $
+ * $Id: onak.c,v 1.15 2003/09/28 20:33:34 noodles Exp $
  */
 
 #include <stdio.h>
 
 int stdin_getchar(void *ctx, size_t count, unsigned char *c)
 {
-       int ic;
+       int ic = 0;
 
-       do {
+       while ((count > 0) && (ic != EOF)) {
                ic = getchar();
                *c = ic;
                c++;
-       } while ((ic != EOF) && (--count > 0));
+               count--;
+       }
+
        return (ic == EOF);
 }