diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-10-31 05:20:53 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-10-31 05:20:53 +0000 |
commit | de153e7f50baa4ea7fac013f3b77b3a4fe314664 (patch) | |
tree | 50fb80d978c873cb63952226707a8683ba31e929 /libio | |
parent | 02fb3d179ddd3c88f4d4f31d4b27948b48bced2b (diff) | |
download | glibc-de153e7f50baa4ea7fac013f3b77b3a4fe314664.zip glibc-de153e7f50baa4ea7fac013f3b77b3a4fe314664.tar.gz glibc-de153e7f50baa4ea7fac013f3b77b3a4fe314664.tar.bz2 |
Update.
* stdio-common/Makefile (tests): Add tst-fmemopen.
* stdio-common/tst-fmemopen.c: New file.
Test case by Ben Collins <bcollins@debian.org>.
* libio/iofopncook.c (_IO_cookie_seek): Correct test for error.
* libio/fmemopen.c (fmemopen_read): Return 0 at end of buffer.
(fmemopen_write): Set errno at end of buffer.
Diffstat (limited to 'libio')
-rw-r--r-- | libio/fmemopen.c | 10 | ||||
-rw-r--r-- | libio/iofopncook.c | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c index 92df2e4..99670b5 100644 --- a/libio/fmemopen.c +++ b/libio/fmemopen.c @@ -69,6 +69,7 @@ * so I don't need the stream to add null characters on its own.) */ +#include <errno.h> #include <libio.h> #include <stdio.h> #include <stdlib.h> @@ -96,7 +97,7 @@ fmemopen_read (void *cookie, char *b, size_t s) if (c->pos + s > c->size) { if (c->pos == c->size) - return -1; + return 0; s = c->size - c->pos; } @@ -123,7 +124,10 @@ fmemopen_write (void *cookie, const char *b, size_t s) if (c->pos + s + addnullc > c->size) { if (c->pos + addnullc == c->size) - return -1; + { + __set_errno (ENOSPC); + return -1; + } s = c->size - c->pos - addnullc; } @@ -142,7 +146,7 @@ fmemopen_write (void *cookie, const char *b, size_t s) int -fmemopen_seek (void *cookie, _IO_off64_t * p, int w) +fmemopen_seek (void *cookie, _IO_off64_t *p, int w) { _IO_off64_t np; fmemopen_cookie_t *c; diff --git a/libio/iofopncook.c b/libio/iofopncook.c index c016cfb..52e025b 100644 --- a/libio/iofopncook.c +++ b/libio/iofopncook.c @@ -76,7 +76,8 @@ _IO_cookie_seek (fp, offset, dir) return ((cfile->__io_functions.seek == NULL || (cfile->__io_functions.seek (cfile->__cookie, &offset, dir) - == (_IO_off64_t) -1)) + == -1) + || offset == (_IO_off64_t) -1) ? _IO_pos_BAD : offset); } |