4.4BSD snapshot (revision 8.1)
[unix-history] / usr / src / lib / libc / stdio / getw.c
index c9cd9d0..1ddad51 100644 (file)
@@ -1,20 +1,23 @@
-#ifndef lint
-static char sccsid[] = "@(#)getw.c     5.1 (Berkeley) %G%";
-#endif not lint
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getw.c     5.3 (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
 
 #include <stdio.h>
 
 
 #include <stdio.h>
 
-getw(iop)
-register FILE *iop;
+getw(fp)
+       FILE *fp;
 {
 {
-       register i;
-       register char *p;
-       int w;
+       int x;
 
 
-       p = (char *)&w;
-       for (i=sizeof(int); --i>=0;)
-               *p++ = getc(iop);
-       if (feof(iop))
-               return(EOF);
-       return(w);
+       return (fread((void *)&x, sizeof(x), 1, fp) == 1 ? x : EOF);
 }
 }