OSDN Git Service
(root)
/
android-x86
/
external-musl-libc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f81279f
)
fmemopen: fix eof handling, hopefully right this time
author
Rich Felker
<dalias@aerifal.cx>
Sun, 4 Sep 2011 20:06:38 +0000
(16:06 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Sun, 4 Sep 2011 20:06:38 +0000
(16:06 -0400)
src/stdio/fmemopen.c
patch
|
blob
|
history
diff --git
a/src/stdio/fmemopen.c
b/src/stdio/fmemopen.c
index
ddb2433
..
e2adfb2
100644
(file)
--- a/
src/stdio/fmemopen.c
+++ b/
src/stdio/fmemopen.c
@@
-24,8
+24,10
@@
static size_t mread(FILE *f, unsigned char *buf, size_t len)
{
struct cookie *c = f->cookie;
size_t rem = c->size - c->pos;
- if (!len) return 0;
- if (len > rem) len = rem;
+ if (len > rem) {
+ len = rem;
+ f->flags |= F_EOF;
+ }
memcpy(buf, c->buf+c->pos, len);
c->pos += len;
rem -= len;
@@
-34,7
+36,6
@@
static size_t mread(FILE *f, unsigned char *buf, size_t len)
f->rend = f->buf + rem;
memcpy(f->rpos, c->buf+c->pos, rem);
c->pos += rem;
- if (!len) f->flags |= F_EOF;
return len;
}