document sticky EOF
[unix-history] / usr / src / lib / libc / stdio / gets.c
index 3093317..bc1971b 100644 (file)
@@ -1,4 +1,7 @@
-/* @(#)gets.c  4.1 (Berkeley) %G% */
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gets.c     5.2 (Berkeley) %G%";
+#endif LIBC_SCCS and not lint
+
 #include       <stdio.h>
 
 char *
 #include       <stdio.h>
 
 char *
@@ -9,9 +12,9 @@ char *s;
        register char *cs;
 
        cs = s;
        register char *cs;
 
        cs = s;
-       while ((c = getchar()) != '\n' && c >= 0)
+       while ((c = getchar()) != '\n' && c != EOF)
                *cs++ = c;
                *cs++ = c;
-       if (c<0 && cs==s)
+       if (c == EOF && cs==s)
                return(NULL);
        *cs++ = '\0';
        return(s);
                return(NULL);
        *cs++ = '\0';
        return(s);