# HG changeset patch # User Bruno Haible # Date 1177835902 0 # Node ID 10d7922803f541bd8fe9e7cdf0d81a950d998f24 # Parent 3d1951b8600f44d65792d61841b2e7954c22e9c3 freading has an undefined value after repositioning a read-write stream. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-04-29 Bruno Haible + + * lib/freading.h: Improve comments. + * lib/fwriting.h: Likewise. + * tests/test-freading.c (main): Don't check freading immediately after + repositioning. Needed for glibc. + 2007-04-29 Bruno Haible * lib/freading.c (freading): Trivial simplification. diff --git a/lib/freading.h b/lib/freading.h --- a/lib/freading.h +++ b/lib/freading.h @@ -24,10 +24,12 @@ writing and there is no current read operation (such as fputc). freading and fwriting will never both be true. If STREAM supports - both reads and writes, then both freading and fwriting might be - false when the stream is first opened, after repositioning (such as - fseek, fsetpos, or rewind), after read encounters EOF, or after - fflush, depending on the underlying implementation. + both reads and writes, then: + - both freading and fwriting might be false when the stream is first + opened, after read encounters EOF, or after fflush, + - freading might be false or true and fwriting might be false + after repositioning (such as fseek, fsetpos, or rewind), + depending on the underlying implementation. STREAM must not be wide-character oriented. */ diff --git a/lib/fwriting.h b/lib/fwriting.h --- a/lib/fwriting.h +++ b/lib/fwriting.h @@ -25,10 +25,12 @@ as fputc). freading and fwriting will never both be true. If STREAM supports - both reads and writes, then both freading and fwriting might be - false when the stream is first opened, after repositioning (such as - fseek, fsetpos, or rewind), after read encounters EOF, or after - fflush, depending on the underlying implementation. + both reads and writes, then: + - both freading and fwriting might be false when the stream is first + opened, after read encounters EOF, or after fflush, + - freading might be false or true and fwriting might be false + after repositioning (such as fseek, fsetpos, or rewind), + depending on the underlying implementation. STREAM must not be wide-character oriented. */ diff --git a/tests/test-freading.c b/tests/test-freading.c --- a/tests/test-freading.c +++ b/tests/test-freading.c @@ -97,7 +97,9 @@ ASSERT (!freading (fp)); if (fseek (fp, 0, SEEK_END)) goto skip; - ASSERT (!freading (fp)); + /* freading (fp) is undefined here, because on some implementations (e.g. + glibc) fseek causes a buffer to be read. + fwriting (fp) is undefined as well. */ if (fclose (fp)) goto skip; @@ -135,7 +137,9 @@ ASSERT (!freading (fp)); if (fseek (fp, 0, SEEK_END)) goto skip; - ASSERT (!freading (fp)); + /* freading (fp) is undefined here, because on some implementations (e.g. + glibc) fseek causes a buffer to be read. + fwriting (fp) is undefined as well. */ if (fclose (fp)) goto skip; diff --git a/tests/test-fwriting.c b/tests/test-fwriting.c --- a/tests/test-fwriting.c +++ b/tests/test-fwriting.c @@ -97,7 +97,9 @@ ASSERT (fwriting (fp)); if (fseek (fp, 0, SEEK_END)) goto skip; - /* fwriting (fp) is undefined here, but freading (fp) is false. */ + /* freading (fp) is undefined here, because on some implementations (e.g. + glibc) fseek causes a buffer to be read. + fwriting (fp) is undefined as well. */ if (fclose (fp)) goto skip; @@ -135,7 +137,9 @@ ASSERT (fwriting (fp)); if (fseek (fp, 0, SEEK_END)) goto skip; - /* fwriting (fp) is undefined here, but freading (fp) is false. */ + /* freading (fp) is undefined here, because on some implementations (e.g. + glibc) fseek causes a buffer to be read. + fwriting (fp) is undefined as well. */ if (fclose (fp)) goto skip;