This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug stdio/16680] New: ftell does not give the correct output for append mode files after a rewind
- From: "siddhesh at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 10 Mar 2014 11:46:16 +0000
- Subject: [Bug stdio/16680] New: ftell does not give the correct output for append mode files after a rewind
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16680
Bug ID: 16680
Summary: ftell does not give the correct output for append mode
files after a rewind
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: stdio
Assignee: siddhesh at redhat dot com
Reporter: siddhesh at redhat dot com
ftell continues to (incorrectly) return the end of the file as the current
position for files opened in any of the append modes when the file stream is
rewound, instead of returning the offset as 0.
To reproduce:
#include <stdio.h>
#include <string.h>
const char *data = "qwertyuioplkjhgfdsazxcvbnm";
int
main ()
{
FILE *stream = fopen("/tmp/foo.out", "a");
long pos = ftell(stream); // pos is zero as expected
fwrite(data, 1, strlen (data) + 1, stream);
pos = ftell(stream); // pos is the length of the written string
printf ("ftell: %ld\n", pos);
rewind(stream);
pos = ftell(stream); // FAILURE happens here, pos is not zero
printf ("ftell: %ld\n", pos);
}
--
You are receiving this mail because:
You are on the CC list for the bug.