aboutsummaryrefslogtreecommitdiff
path: root/libio/fmemopen.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-31 05:20:53 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-31 05:20:53 +0000
commitde153e7f50baa4ea7fac013f3b77b3a4fe314664 (patch)
tree50fb80d978c873cb63952226707a8683ba31e929 /libio/fmemopen.c
parent02fb3d179ddd3c88f4d4f31d4b27948b48bced2b (diff)
downloadglibc-de153e7f50baa4ea7fac013f3b77b3a4fe314664.tar
glibc-de153e7f50baa4ea7fac013f3b77b3a4fe314664.tar.gz
glibc-de153e7f50baa4ea7fac013f3b77b3a4fe314664.tar.bz2
glibc-de153e7f50baa4ea7fac013f3b77b3a4fe314664.zip
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/fmemopen.c')
-rw-r--r--libio/fmemopen.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c
index 92df2e4424..99670b5c58 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;