diff options
author | Roland McGrath <roland@gnu.org> | 1995-12-05 03:35:55 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-12-05 03:35:55 +0000 |
commit | 77a58cad3fa0a286bd2581187a2463a762d711ba (patch) | |
tree | 50756d67e82e3edbe49f722662b0bed8c0cd19cc /libio | |
parent | Mon Dec 4 12:10:28 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> (diff) | |
download | glibc-77a58cad3fa0a286bd2581187a2463a762d711ba.tar.gz glibc-77a58cad3fa0a286bd2581187a2463a762d711ba.tar.bz2 glibc-77a58cad3fa0a286bd2581187a2463a762d711ba.zip |
Tue Dec 5 02:27:32 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* libio/Makefile [routines]: Remove iofscanf, add iopopen, pclose.
* libio/iofscanf.c: Remove file.
* libio/iogetdelim.c (_IO_getdelim): Correct stupid bug at string
termination.
* libio/iopopen.c: New file from GNU libio.
* libio/memstream.c: Fixed bug in fclose handling. Instead of
providing a close callback we need a finish callback.
* libio/pclose.c: New file. Derived from popen.c in GNU libio.
* posix/gnu/types.h: Fixed typo.
* stdio-common/errnobug.c: fputs returns EOF in error case. Do
not test for != 0.
* stdio-common/printf-parse.h (parse_one_spec): Do not force
padding with ' ' if precision is given. Fix by HJ Lu.
* stdio-common/printf_fp.c: Fix comment.
* stdio-common/tfformat.c, stdio-common/tiformat.c,
stdio-common/tstdiomisc.c: New files from GNU libio test suite.
* stdio-common/tstgetln.c: Provide ssize_t type when testing
libio.
* stdio-common/vfprintf.c (outchar): Use PUTC instead of putc.
(vfprintf): Cleasr args_type array before using it.
When printing 0 as an integer with precision 0 nothing must be
written for the number.
Based on patch by HJ Lu.
* stdio-common/vfscanf.c: Remove fixed input buffer. Now we
have a dynamically extended buffer.
* stdlib/strtod.c: Merge with version in Linux libc. This fixes
some bugs with handling of very small numbers and has different
solution for formaer patches.
* sysdeps/i386/i586/add_n.S, sysdeps/i386/i586/sub_n.S: Rename
macros r1 and r2 to t1, and t2 resp. This is necessary because
glibc headers also define r1.
Tue Dec 5 02:27:32 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu>
* libio/Makefile [routines]: Remove iofscanf, add iopopen, pclose.
* libio/iofscanf.c: Remove file.
* libio/iogetdelim.c (_IO_getdelim): Correct stupid bug at string
termination.
* libio/iopopen.c: New file from GNU libio.
* libio/memstream.c: Fixed bug in fclose handling. Instead of
providing a close callback we need a finish callback.
* libio/pclose.c: New file. Derived from popen.c in GNU libio.
* posix/gnu/types.h: Fixed typo.
* stdio-common/errnobug.c: fputs returns EOF in error case. Do
not test for != 0.
* stdio-common/printf-parse.h (parse_one_spec): Do not force
padding with ' ' if precision is given. Fix by HJ Lu.
* stdio-common/printf_fp.c: Fix comment.
* stdio-common/tfformat.c, stdio-common/tiformat.c,
stdio-common/tstdiomisc.c: New files from GNU libio test suite.
* stdio-common/tstgetln.c: Provide ssize_t type when testing
libio.
* stdio-common/vfprintf.c (outchar): Use PUTC instead of putc.
(vfprintf): Cleasr args_type array before using it.
When printing 0 as an integer with precision 0 nothing must be
written for the number.
Based on patch by HJ Lu.
* stdio-common/vfscanf.c: Remove fixed input buffer. Now we
have a dynamically extended buffer.
* stdlib/strtod.c: Merge with version in Linux libc. This fixes
some bugs with handling of very small numbers and has different
solution for formaer patches.
* sysdeps/i386/i586/add_n.S, sysdeps/i386/i586/sub_n.S: Rename
macros r1 and r2 to t1, and t2 resp. This is necessary because
glibc headers also define r1.
Diffstat (limited to 'libio')
-rw-r--r-- | libio/Makefile | 8 | ||||
-rw-r--r-- | libio/iofscanf.c | 50 | ||||
-rw-r--r-- | libio/iogetdelim.c | 6 | ||||
-rw-r--r-- | libio/memstream.c | 35 |
4 files changed, 26 insertions, 73 deletions
diff --git a/libio/Makefile b/libio/Makefile index 8d09a5ecce..02426a79c2 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -25,14 +25,14 @@ headers := stdio.h libio.h routines := \ filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ - iofopncook iofprintf iofputs iofread iofscanf iofsetpos ioftell \ - iofwrite iogetdelim iogetline iogets iopadn ioprims ioputs \ + iofopncook iofprintf iofputs iofread iofsetpos ioftell \ + iofwrite iogetdelim iogetline iogets iopadn iopopen ioprims ioputs \ ioseekoff ioseekpos iosetbuffer iosetvbuf iosprintf ioungetc \ iovsprintf iovsscanf \ \ clearerr feof ferror fgetc fileno fputc freopen fseek getc getchar \ - memstream putc putchar rewind setbuf setlinebuf vasprintf vdprintf \ - vscanf vsnprintf \ + memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \ + vdprintf vscanf vsnprintf \ \ libc_fatal diff --git a/libio/iofscanf.c b/libio/iofscanf.c deleted file mode 100644 index 512d5e515e..0000000000 --- a/libio/iofscanf.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright (C) 1993, 1995 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#include "libioP.h" - -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -int -_IO_fscanf -#ifdef __STDC__ - (_IO_FILE *fp, const char* format, ...) -#else -(fp, format, va_alist) _IO_FILE *fp; char *format; va_dcl -#endif -{ - int ret; - va_list args; - CHECK_FILE (fp, EOF); - _IO_va_start (args, format); - ret = _IO_vfscanf (fp, format, args, NULL); - va_end (args); - return ret; -} - -weak_alias (_IO_fscanf, fscanf) diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c index a6894a5ae6..ecb360b1f5 100644 --- a/libio/iogetdelim.c +++ b/libio/iogetdelim.c @@ -79,11 +79,11 @@ _IO_getdelim (lineptr, n, delimiter, fp) t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len); if (t != NULL) len = (t - fp->_IO_read_ptr) + 1; - /* make enough space for len+1 (for final NUL) bytes. */ + /* Make enough space for len+1 (for final NUL) bytes. */ needed = cur_len + len + 1; if (needed > *n) { - if (t == NULL && needed < 2 * *n) + if (needed < 2 * *n) needed = 2 * *n; /* Be generous. */ *n = needed; *lineptr = (char *) realloc (*lineptr, needed); @@ -97,7 +97,7 @@ _IO_getdelim (lineptr, n, delimiter, fp) break; len = fp->_IO_read_end - fp->_IO_read_ptr; } - lineptr[cur_len] = '\0'; + (*lineptr)[cur_len] = '\0'; return cur_len; } diff --git a/libio/memstream.c b/libio/memstream.c index b1cefb0959..71519a5190 100644 --- a/libio/memstream.c +++ b/libio/memstream.c @@ -30,13 +30,13 @@ struct _IO_FILE_memstream static int _IO_mem_sync __P ((_IO_FILE* fp)); -static int _IO_mem_close __P ((_IO_FILE* fp)); +static void _IO_mem_finish __P ((_IO_FILE* fp)); static const struct _IO_jump_t _IO_mem_jumps = { JUMP_INIT_DUMMY, - JUMP_INIT (finish, _IO_str_finish), + JUMP_INIT (finish, _IO_mem_finish), JUMP_INIT (overflow, _IO_str_overflow), JUMP_INIT (underflow, _IO_str_underflow), JUMP_INIT (uflow, _IO_default_uflow), @@ -51,7 +51,7 @@ static const struct _IO_jump_t _IO_mem_jumps = JUMP_INIT (read, _IO_default_read), JUMP_INIT (write, _IO_default_write), JUMP_INIT (seek, _IO_default_seek), - JUMP_INIT (close, _IO_mem_close), + JUMP_INIT (close, _IO_default_close), JUMP_INIT (stat, _IO_default_stat) }; @@ -79,6 +79,9 @@ open_memstream (bufloc, sizeloc) fp->_sf._s._allocate_buffer = (_IO_alloc_type) malloc; fp->_sf._s._free_buffer = (_IO_free_type) free; + fp->bufloc = bufloc; + fp->sizeloc = sizeloc; + return &fp->_sf._f; } @@ -102,28 +105,28 @@ _IO_mem_sync (fp) else *fp->_IO_write_ptr = '\0'; - *mp->bufloc = fp->_IO_buf_base; - *mp->sizeloc = _IO_blen (fp); + *mp->bufloc = fp->_IO_write_base; + *mp->sizeloc = fp->_IO_write_ptr - fp->_IO_write_base; return 0; } -static int _IO_mem_close (fp) +static void +_IO_mem_finish (fp) _IO_FILE* fp; { struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp; - int res; - res = _IO_default_close (fp); - if (res < 0) - return res; + *mp->bufloc = (char *) realloc (fp->_IO_write_base, + fp->_IO_write_ptr - fp->_IO_write_base + 1); + if (*mp->bufloc != NULL) + { + (*mp->bufloc)[fp->_IO_write_ptr - fp->_IO_write_base] = '\0'; + *mp->sizeloc = fp->_IO_write_ptr - fp->_IO_write_base; + } - *mp->bufloc = (char *) realloc (fp->_IO_buf_base, _IO_blen (fp) + 1); - if (*mp->bufloc == NULL) - return -1; - (*mp->bufloc)[_IO_blen (fp)] = '\0'; - *mp->sizeloc = _IO_blen (fp); + fp->_IO_buf_base = NULL; - return 0; + _IO_default_finish (fp); } |