date and time created 80/12/21 16:51:04 by wnj
authorBill Joy <wnj@ucbvax.Berkeley.EDU>
Mon, 22 Dec 1980 08:51:04 +0000 (00:51 -0800)
committerBill Joy <wnj@ucbvax.Berkeley.EDU>
Mon, 22 Dec 1980 08:51:04 +0000 (00:51 -0800)
SCCS-vsn: lib/libc/stdio/ungetc.c 4.1

usr/src/lib/libc/stdio/ungetc.c [new file with mode: 0644]

diff --git a/usr/src/lib/libc/stdio/ungetc.c b/usr/src/lib/libc/stdio/ungetc.c
new file mode 100644 (file)
index 0000000..04445cc
--- /dev/null
@@ -0,0 +1,17 @@
+/* @(#)ungetc.c        4.1 (Berkeley) %G% */
+#include <stdio.h>
+
+ungetc(c, iop)
+register FILE *iop;
+{
+       if (c == EOF)
+               return(-1);
+       if ((iop->_flag&_IOREAD)==0 || iop->_ptr <= iop->_base)
+               if (iop->_ptr == iop->_base && iop->_cnt==0)
+                       *iop->_ptr++;
+               else
+                       return(-1);
+       iop->_cnt++;
+       *--iop->_ptr = c;
+       return(0);
+}