From:             nikhil dot gupta at in dot ibm dot com
Operating system: Linux, Win32-xp
PHP version:      4CVS-2007-08-07 (CVS)
PHP Bug Type:     Filesystem function related
Bug description:  feof() fails to detect the eof flag for a file with a newline 
only.

Description:
------------
feof() is failing to detect the end of file for a file containing a blank
file ("\n" character only).
This behaviour is seen on php5 and php6 both.

Reproduce code:
---------------
<?php

$fp = fopen("file2.tmp", "w");
$csv_string = "\n";
fwrite($fp, $csv_string);
fclose($fp);

$fp = fopen("file2.tmp", "r");
var_dump( ftell($fp) );
var_dump( fgetcsv($fp) );
var_dump( ftell($fp) );
var_dump( feof($fp) );
var_dump( fseek($fp, 0, SEEK_END) );
var_dump( ftell($fp) );
var_dump( feof($fp) );
fclose($fp);
?>


Expected result:
----------------
int(0)
array(1) {
  [0]=>
  string(0) ""
}
int(1)
bool(true)
int(0)
int(1)
bool(true)

Actual result:
--------------
int(0)
array(1) {
  [0]=>
  string(0) ""
}
int(1)
bool(false)
int(0)
int(1)
bool(false)

-- 
Edit bug report at http://bugs.php.net/?id=42228&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42228&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42228&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42228&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42228&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42228&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42228&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42228&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42228&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42228&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42228&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42228&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42228&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42228&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42228&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42228&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42228&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42228&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42228&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42228&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42228&r=mysqlcfg

Reply via email to