This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/12527] Off by one bug with ftell() with fmemopen()


http://sourceware.org/bugzilla/show_bug.cgi?id=12527

Per Inge Mathisen <per.mathisen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

--- Comment #4 from Per Inge Mathisen <per.mathisen at gmail dot com> 2011-03-03 21:27:53 UTC ---
The glibc documentation says: "As you can see, â+â requests a stream that can
do both input and output. The ISO standard says that when using such a stream,
you must call fflush (see Stream Buffering) or a file positioning function such
as fseek (see File Positioning) when switching from reading to writing or vice
versa. Otherwise, internal buffers might not be emptied properly. The GNU C
library does not have this limitation; you can do arbitrary reading and writing
operations on a stream in whatever order." (12.3 Opening Streams)

So either the documentation or the code is in error here.

(http://www.gnu.org/s/libc/manual/html_node/Opening-Streams.html#Opening-Streams)

About ftell(), it also says: "each time a character is read or written, the
file position is incremented" (11.1.2 File Position), which makes a lot of
sense. Otherwise you have to implement your own code layer above streams just
to count bytes in many cases. Thankfully this does seem to be working fine in
glibc.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]