From: Rich Felker Date: Mon, 18 Jun 2012 01:24:58 +0000 (-0400) Subject: change stdio_ext __freading/__fwriting semantics slightly X-Git-Tag: v0.9.2~31 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=deb90c79e5c498fbb48de1423df034447f330e38;p=oweals%2Fmusl.git change stdio_ext __freading/__fwriting semantics slightly the old behavior was to only consider a stream to be "reading" or "writing" if it had buffered, unread/unwritten data. this reportedly differs from the traditional behavior of these functions, which is essentially to return true as much as possible without creating the possibility that both __freading and __fwriting could return true. gnulib expects __fwriting to return true as soon as a file is opened write-only, and possibly expects other cases that depend on the traditional behavior. and since these functions exist mostly for gnulib (does anything else use them??), they should match the expected behavior to avoid even more ugly hacks and workarounds... --- diff --git a/src/stdio/ext.c b/src/stdio/ext.c index 6b8ce91c..1fd95490 100644 --- a/src/stdio/ext.c +++ b/src/stdio/ext.c @@ -14,12 +14,12 @@ int __fsetlocking(FILE *f, int type) int __fwriting(FILE *f) { - return f->wend && f->wpos > f->wbase; + return (f->flags & F_NORD) || f->wend; } int __freading(FILE *f) { - return f->rend > f->rpos; + return (f->flags & F_NOWR) || f->rend; } int __freadable(FILE *f)