diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-02-17 15:15:51 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-02-17 15:15:51 +0000 |
commit | 0a61487785ff1f13ce3bb683cd59e520bbb0086f (patch) | |
tree | 11b0c5e1e0cbf6272621ebef0638553ecea8151f /libio | |
parent | 3858abff55a4088377ceaeeccf5ff06d6129b331 (diff) | |
download | glibc-0a61487785ff1f13ce3bb683cd59e520bbb0086f.zip glibc-0a61487785ff1f13ce3bb683cd59e520bbb0086f.tar.gz glibc-0a61487785ff1f13ce3bb683cd59e520bbb0086f.tar.bz2 |
Update.
1998-02-17 15:10 Ulrich Drepper <drepper@cygnus.com>
* elf/dl-load.c (open_path): Use __xstat instead of stat.
* localedata/tst-locale.sh: Comment out first test for now.
1998-02-14 14:58 H.J. Lu <hjl@gnu.org>
* sysdeps/generic/_G_config.h (_G_HAVE_IO_GETLINE_INFO): Defined
as 1.
* sysdeps/unix/sysv/linux/_G_config.h (_G_HAVE_IO_GETLINE_INFO):
Likewise.
* libio/iogetline.c (_IO_getline_info): Renamed from
_IO_getline.
(_IO_getline): Just call _IO_getline_info.
* libio/libioP.h (_IO_getline_info): New declaration.
* libc.map (_IO_getline_info, __write): Added.
1998-02-17 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sunrpc/rpc_cout.c (inline_struct): Change typo of plus to
const char* to shut up gcc.
1998-02-17 11:37 Ulrich Drepper <drepper@cygnus.com>
* eld/dl-open.c (_dl_open): Assign correct value to new->l_global.
Patch forwarded by Cristian Gafton <gafton@redhat.com>.
* math/math.h: Define M_* constants always as `double' and add new
macros M_*l which are of type `long double'.
* sysdeps/libm-ieee754/s_cacoshl.c: Use M_*l constants now.
* sysdeps/libm-ieee754/s_cacosl.c: Likewise.
* sysdeps/libm-ieee754/s_casinhl.c: Likewise.
* sysdeps/libm-ieee754/s_catanhl.c: Likewise.
* sysdeps/libm-ieee754/s_catanl.c: Likewise.
* sysdeps/libm-ieee754/s_clog10l.c: Likewise.
* sysdeps/libm-ieee754/s_clogl.c: Likewise.
* math/libm-tst.c: Likewise.
* sysdeps/i386/fpu/bits/mathinline.h (__M_SQRT2): Don't use _Mdbl,
define as long double unconditionally.
1998-02-17 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* manual/arith.texi (Old-style number conversion): Correct some
typos.
1998-02-16 16:28 H.J. Lu <hjl@gnu.org>
* time/Makefile (tz-cflags, CFLAGS-tzfile.c, CFLAGS-tzset.c):
Restore.
* timezone/Makefile (CFLAGS-tzfile.c, CFLAGS-tzset.c): Deleted.
Diffstat (limited to 'libio')
-rw-r--r-- | libio/iogetline.c | 81 | ||||
-rw-r--r-- | libio/libioP.h | 4 |
2 files changed, 62 insertions, 23 deletions
diff --git a/libio/iogetline.c b/libio/iogetline.c index bd1a743..328e20e 100644 --- a/libio/iogetline.c +++ b/libio/iogetline.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -26,6 +26,19 @@ #include "libioP.h" #include <string.h> +#if defined _LIBC || !_G_HAVE_IO_GETLINE_INFO + +_IO_size_t +_IO_getline (fp, buf, n, delim, extract_delim) + _IO_FILE *fp; + char *buf; + _IO_size_t n; + int delim; + int extract_delim; +{ + return _IO_getline_info (fp, buf, n, delim, extract_delim, (int *) 0); +} + /* Algorithm based on that used by Berkeley pre-4.4 fgets implementation. Read chars into buf (of size n), until delim is seen. @@ -35,44 +48,68 @@ If extract_delim > 0, insert delim in output. */ _IO_size_t -_IO_getline (fp, buf, n, delim, extract_delim) +_IO_getline_info (fp, buf, n, delim, extract_delim, eof) _IO_FILE *fp; char *buf; _IO_size_t n; int delim; int extract_delim; + int *eof; { char *ptr = buf; + if (eof != NULL) + *eof = 0; do { _IO_ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr; - char *t; if (len <= 0) - if (__underflow (fp) == EOF) - break; - else - len = fp->_IO_read_end - fp->_IO_read_ptr; - if ((_IO_size_t) len >= n) - len = n; - t = (char *) memchr ((void *) fp->_IO_read_ptr, delim, len); - if (t != NULL) { - _IO_size_t old_len = ptr-buf; - len = t - fp->_IO_read_ptr; - if (extract_delim >= 0) + int c = __uflow (fp); + if (c == EOF) { - ++t; + if (eof) *eof = c; + break; + } + if (c == delim) + { + if (extract_delim > 0) + *ptr++ = c; + else if (extract_delim < 0) + _IO_sputbackc (fp, c); + return ptr - buf; if (extract_delim > 0) ++len; } - memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); - fp->_IO_read_ptr = t; - return old_len + len; + *ptr++ = c; + n--; } - memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); - fp->_IO_read_ptr += len; - ptr += len; - n -= len; + else + { + char *t; + if ((_IO_size_t) len >= n) + len = n; + t = (char *) memchr ((void *) fp->_IO_read_ptr, delim, len); + if (t != NULL) + { + _IO_size_t old_len = ptr-buf; + len = t - fp->_IO_read_ptr; + if (extract_delim >= 0) + { + ++t; + if (extract_delim > 0) + ++len; + } + memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); + fp->_IO_read_ptr = t; + return old_len + len; + } + memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); + fp->_IO_read_ptr += len; + ptr += len; + n -= len; + } } while (n != 0); return ptr - buf; } + +#endif /* Defined _LIBC || !_G_HAVE_IO_GETLINE_INFO */ diff --git a/libio/libioP.h b/libio/libioP.h index 568bbe8..785bfee 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -428,6 +428,8 @@ extern int _IO_vsnprintf __P ((char *string, _IO_size_t maxlen, extern _IO_size_t _IO_getline __P ((_IO_FILE *,char *, _IO_size_t, int, int)); +extern _IO_size_t _IO_getline_info __P ((_IO_FILE *,char *, _IO_size_t, + int, int, int *)); extern _IO_ssize_t _IO_getdelim __P ((char **, _IO_size_t *, int, _IO_FILE *)); extern double _IO_strtod __P ((const char *, char **)); extern char *_IO_dtoa __P ((double __d, int __mode, int __ndigits, |