OSDN Git Service

* libc/stdio/Makefile.am (lib_a_SOURCES): Added getw.c and putw.c.
authoraoliva <aoliva>
Wed, 8 Mar 2000 03:42:25 +0000 (03:42 +0000)
committeraoliva <aoliva>
Wed, 8 Mar 2000 03:42:25 +0000 (03:42 +0000)
(CHEWOUT_FILES): Added getw.def and putw.def.
* libc/stdio/Makefile.in: Rebuilt.
* libc/stdio/stdio.tex: Include getw.def and putw.def.
* libc/stdio/getw.c: New file.
* libc/stdio/putw.c: New file.

newlib/ChangeLog
newlib/libc/stdio/Makefile.am
newlib/libc/stdio/Makefile.in
newlib/libc/stdio/getw.c [new file with mode: 0644]
newlib/libc/stdio/putw.c [new file with mode: 0644]
newlib/libc/stdio/stdio.tex

index 2e39d2b..656fcbb 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar  8 00:38:35 2000  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
+
+       * libc/stdio/Makefile.am (lib_a_SOURCES): Added getw.c and putw.c.
+       (CHEWOUT_FILES): Added getw.def and putw.def.
+       * libc/stdio/Makefile.in: Rebuilt.
+       * libc/stdio/stdio.tex: Include getw.def and putw.def.
+       * libc/stdio/getw.c: New file.
+       * libc/stdio/putw.c: New file.
+
 Fri Feb 25 14:50:50 2000  Jeff Johnston <jjohnstn@cygnus.com>
 
        * libc/stdio/flags.c (__sflags): Added check that mode[1]
index 234da49..8461d4a 100644 (file)
@@ -36,6 +36,7 @@ lib_a_SOURCES = \
        getc.c                          \
        getchar.c                       \
        gets.c                          \
+       getw.c                          \
        iprintf.c                       \
        makebuf.c                       \
        mktemp.c                        \
@@ -44,6 +45,7 @@ lib_a_SOURCES = \
        putc.c                          \
        putchar.c                       \
        puts.c                          \
+       putw.c                          \
        refill.c                        \
        remove.c                        \
        rename.c                        \
@@ -97,12 +99,14 @@ CHEWOUT_FILES = \
        getc.def                \
        getchar.def             \
        gets.def                \
+       getw.def                \
        iprintf.def             \
        mktemp.def              \
        perror.def              \
        putc.def                \
        putchar.def             \
        puts.def                \
+       putw.def                \
        remove.def              \
        rename.def              \
        rewind.def              \
index ff2a838..2f487a1 100644 (file)
@@ -118,6 +118,7 @@ lib_a_SOURCES = \
        getc.c                          \
        getchar.c                       \
        gets.c                          \
+       getw.c                          \
        iprintf.c                       \
        makebuf.c                       \
        mktemp.c                        \
@@ -126,6 +127,7 @@ lib_a_SOURCES = \
        putc.c                          \
        putchar.c                       \
        puts.c                          \
+       putw.c                          \
        refill.c                        \
        remove.c                        \
        rename.c                        \
@@ -177,12 +179,14 @@ CHEWOUT_FILES = \
        getc.def                \
        getchar.def             \
        gets.def                \
+       getw.def                \
        iprintf.def             \
        mktemp.def              \
        perror.def              \
        putc.def                \
        putchar.def             \
        puts.def                \
+       putw.def                \
        remove.def              \
        rename.def              \
        rewind.def              \
@@ -216,8 +220,8 @@ lib_a_DEPENDENCIES =  vfiprintf.o
 lib_a_OBJECTS =  clearerr.o fclose.o fdopen.o feof.o ferror.o fflush.o \
 fgetc.o fgetpos.o fgets.o fileno.o findfp.o fiprintf.o flags.o fopen.o \
 fprintf.o fputc.o fputs.o fread.o freopen.o fscanf.o fseek.o fsetpos.o \
-ftell.o fvwrite.o fwalk.o fwrite.o getc.o getchar.o gets.o iprintf.o \
-makebuf.o mktemp.o perror.o printf.o putc.o putchar.o puts.o refill.o \
+ftell.o fvwrite.o fwalk.o fwrite.o getc.o getchar.o gets.o getw.o iprintf.o \
+makebuf.o mktemp.o perror.o printf.o putc.o putchar.o puts.o putw.o refill.o \
 remove.o rename.o rewind.o rget.o scanf.o setbuf.o setvbuf.o siprintf.o \
 snprintf.o sprintf.o sscanf.o stdio.o tmpfile.o tmpnam.o ungetc.o \
 vfprintf.o vfscanf.o vprintf.o vsnprintf.o vsprintf.o wbuf.o wsetup.o
diff --git a/newlib/libc/stdio/getw.c b/newlib/libc/stdio/getw.c
new file mode 100644 (file)
index 0000000..b6fd873
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+FUNCTION
+<<getw>>---read a word (int)
+
+INDEX
+       getw
+
+ANSI_SYNOPSIS
+       #include <stdio.h>
+       int getw(FILE *<[fp]>);
+
+TRAD_SYNOPSIS
+       #include <stdio.h>
+       int getw(<[fp]>)
+       FILE *<[fp]>;
+
+DESCRIPTION
+<<getw>> is a function, defined in <<stdio.h>>.  You can use <<getw>>
+to get the next word from the file or stream identified by <[fp]>.  As
+a side effect, <<getw>> advances the file's current position
+indicator.
+
+RETURNS The next word (read as an <<int>>), unless there is no more
+data, or the host system reports a read error; in either of these
+situations, <<getw>> returns <<EOF>>.  Since <<EOF>> is a valid
+<<int>>, you must use <<ferror>> or <<feof>> to distinguish these
+situations.
+
+PORTABILITY
+<<getw>> is a remnant of K&R C, it is not part of any ISO C Standard.
+<<fread>> should be used instead.  In fact, this implementation of
+<<getw>> is based upon <<fread>>.
+
+Supporting OS subroutines required: <<fread>>.  */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "%W% (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+
+int
+getw (fp)
+     register FILE *fp;
+{
+  int result;
+  if (fread((char*)&result, sizeof(result), 1, fp) != 1)
+    return EOF;
+  return result;
+}
diff --git a/newlib/libc/stdio/putw.c b/newlib/libc/stdio/putw.c
new file mode 100644 (file)
index 0000000..4bcefaf
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+FUNCTION
+<<putw>>---write a word (int)
+
+INDEX
+       putw
+
+ANSI_SYNOPSIS
+       #include <stdio.h>
+       int putw(int <[w]>, FILE *<[fp]>);
+
+TRAD_SYNOPSIS
+       #include <stdio.h>
+       int putw(<w>, <[fp]>)
+       int <w>;
+       FILE *<[fp]>;
+
+DESCRIPTION
+<<putw>> is a function, defined in <<stdio.h>>.  You can use <<putw>>
+to write a word to the file or stream identified by <[fp]>.  As a side
+effect, <<putw>> advances the file's current position indicator.
+
+RETURNS The written word, unless the host system reports a write
+error, in which case <<putw>> returns <<EOF>>.  Since <<EOF>> is a
+valid <<int>>, you must use <<ferror>> or <<feof>> to distinguish
+these situations when writing the integer equal to <<EOF>>.
+
+PORTABILITY
+<<putw>> is a remnant of K&R C, it is not part of any ISO C Standard.
+<<fwrite>> should be used instead.  In fact, this implementation of
+<<putw>> is based upon <<fwrite>>.
+
+Supporting OS subroutines required: <<fwrite>>.  */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "%W% (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+
+int
+putw (w, fp)
+     int w;
+     register FILE *fp;
+{
+  if (fwrite((const char*)&w, sizeof(w), 1, fp) != 1)
+    return EOF;
+  return w;
+}
index 466e1f0..725b2f3 100644 (file)
@@ -46,12 +46,14 @@ structure.
 * getc::        Get a character from a file or stream (macro)
 * getchar::     Get a character from standard input (macro)
 * gets::        Get character string from standard input (obsolete)
+* getw::        Get a word (int) from a file or stream
 * iprintf::     Write formatted output (integer only)
 * mktemp::      Generate unused file name
 * perror::      Print an error message on standard error
 * putc::        Write a character on a stream or file (macro)
 * putchar::     Write a character on standard output (macro)
 * puts::        Write a character string on standard output
+* putw::        Write a word (int) to a file or stream
 * remove::      Delete a file's name
 * rename::      Rename a file
 * rewind::      Reinitialize a file or stream
@@ -131,6 +133,9 @@ structure.
 @page 
 @include stdio/gets.def
 
+@page 
+@include stdio/getw.def 
+
 @page
 @include stdio/iprintf.def 
 
@@ -149,6 +154,9 @@ structure.
 @page
 @include stdio/puts.def
 
+@page 
+@include stdio/putw.def 
+
 @page
 @include stdio/remove.def