Bug 81359 - after fopen(, "a+") ftell() gives 0 not EOF
Summary: after fopen(, "a+") ftell() gives 0 not EOF
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: man-pages   
(Show other bugs)
Version: 8.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Eido Inoue
QA Contact: Ben Levenson
Depends On:
TreeView+ depends on / blocked
Reported: 2003-01-08 15:01 UTC by Joe Orton
Modified: 2007-03-27 03:59 UTC (History)
1 user (show)

Fixed In Version: 1.60-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-08-28 20:31:44 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
repro case for ftell bug (386 bytes, patch)
2003-01-08 15:02 UTC, Joe Orton
no flags Details | Diff

Description Joe Orton 2003-01-08 15:01:51 UTC
Description of problem:
Bug report courtesy of PHP CVS: for a non-zero-length file opened with fopen(,
"a+"), ftell(fp) gives 0 not the EOF location.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. gcc ftell.c
2. ./a.out
3. echo $?
Actual results:

Expected results:

Additional info:

Comment 1 Joe Orton 2003-01-08 15:02:54 UTC
Created attachment 89212 [details]
repro case for ftell bug

Comment 2 Jakub Jelinek 2003-01-20 18:20:14 UTC
See info libc on fopen:
          Open or create file for both reading and appending.  If the
          file exists, its initial contents are unchanged.  Otherwise,
          a new file is created.  The initial file position for reading
          is at the beginning of the file, but output is always
          appended to the end of the file.

Comment 3 Joe Orton 2003-01-21 09:33:09 UTC
This is a deliberate change in behaviour since glibc 2.2, then?

The fopen man page says "The stream is positioned at the end of the file", so at
least this is a documentation bug.

Comment 4 Jakub Jelinek 2003-01-21 09:51:31 UTC
Yes, it was deliberate change:
2002-08-26  Ulrich Drepper  <drepper@redhat.com>

        * libio/Makefile (tests): Add bug-fopena+.
        * libio/bug-fopena+.c: New file.
        * libio/fileops.c (_IO_file_open): Only set file pointer to end of the
        file for _IO_IS_APPENDING if file isn't opened for reading, too.

This is documented in libc.info, manual pages are hopelessly outdated.

Comment 5 Eido Inoue 2003-08-28 20:31:44 UTC
fixed in 1.60-1

Note You need to log in before you can comment on or make changes to this bug.