Bug 54577 - fscanf() != EOF for empty file
Summary: fscanf() != EOF for empty file
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 7.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Aaron Brown
Depends On:
TreeView+ depends on / blocked
Reported: 2001-10-12 20:22 UTC by Need Real Name
Modified: 2016-11-24 15:06 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2001-10-19 17:25:52 UTC

Attachments (Terms of Use)
source code that demonstrates EOF problem in fscanf (936 bytes, text/plain)
2001-10-19 17:25 UTC, Need Real Name
no flags Details

Description Need Real Name 2001-10-12 20:22:40 UTC
Description of Problem:
fscanf does not return EOF if attempt to read fro 0 length file

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

How Reproducible:

Steps to Reproduce:
1. open file for writing, then close file
2. open file for read (filehandle != NULL)
3. fscanf(filehandle) returns 0 not EOF as expected

Actual Results:
returns 0

Expected Results:
expect EOF

Additional Information:
on linux6.2 fscanf returns EOF
feof(filehandle) is also wrong!
I'm new to Linux but have experience in C

Comment 1 Jakub Jelinek 2001-10-15 09:19:30 UTC
Can you come up with a testcase?
It depends on what arguments fscanf gets.

Comment 2 Need Real Name 2001-10-19 17:25:46 UTC
Created attachment 34422 [details]
source code that demonstrates EOF problem in fscanf

Comment 3 Jakub Jelinek 2001-10-19 20:28:04 UTC
What glibc do you use?
Under glibc-2.2.4-19 (which is the same source as 2.2.4-18.7.0,
latest 7.0 errata), I get:
fscanf result is -1, EOF value is -1

Comment 4 Need Real Name 2001-10-19 21:29:09 UTC
I performed the standard 7.0 installation.

rpm shows glibc 2.1.92

Comment 5 Need Real Name 2001-10-23 21:53:14 UTC
glibc-2.2.4-19 fixes the problem! Thanks.

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