]> Devi Nivas Git - cs3210-lab1.git/commitdiff
change gets to return \n, to distinguish 0-byte read from empty line
authorrsc <rsc>
Wed, 8 Aug 2007 08:04:20 +0000 (08:04 +0000)
committerrsc <rsc>
Wed, 8 Aug 2007 08:04:20 +0000 (08:04 +0000)
ulib.c

diff --git a/ulib.c b/ulib.c
index 5c8e6f3316f7ecf6c21715a732a7562a27c487e7..decab69dbda5d2bd6edf89aed805f015b49f857c 100644 (file)
--- a/ulib.c
+++ b/ulib.c
@@ -67,9 +67,9 @@ gets(char *buf, int max)
     cc = read(0, &c, 1);
     if(cc < 1)
       break;
+    buf[i++] = c;
     if(c == '\n' || c == '\r')
       break;
-    buf[i++] = c;
   }
   buf[i] = '\0';
   return buf;