ID:               19970
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Closed
 Bug Type:         Filesystem function related
 Operating System: FreeBSD 4.7-STABLE
 PHP Version:      4.2.2
 New Comment:

This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

It now works for me.
Let me know if it is still borked. :-)


Previous Comments:
------------------------------------------------------------------------

[2002-10-18 06:59:23] [EMAIL PROTECTED]

Yes, cynic, you're right, it's a bug.

$fd = fopen(__FILE__, 'r');
while (!feof($fd)) 
{
  $s = fgets($fd);
  if($s === false)
    echo "There was an error! And feof() is ",var_dump(feof($fd));
  // echo $s;
}
fclose($fd);

Prints:

There was an error! And feof() is bool(true)

------------------------------------------------------------------------

[2002-10-18 04:55:18] [EMAIL PROTECTED]

michael: i meant bool(true) of course, sorry for the confusion.

wez: still no banana

roman@freepuppy ~/tmp 1027:0 > php -v
PHP 4.3.0-dev (cli), Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies
roman@freepuppy ~/tmp 1028:1 > cat feof1.php 
<?php
$fd = fopen(__FILE__, 'r');
while (!feof($fd)) fgets($fd, 4096) || var_dump(feof($fd));
fclose($fd);
roman@freepuppy ~/tmp 1029:0 > php feof1.php
bool(true)
roman@freepuppy ~/tmp 1030:0 > 

fgets() gets to read past EOF, but it shouldn't. looks like feof() is
broken.

roman@freepuppy ~/tmp 1031:0 > fc -lf |grep "cvs -q up" 
 1016  10/18/2002 11:35  cvs -q up
roman@freepuppy ~/tmp 1032:0 > date
Fri Oct 18 11:48:31 CEST 2002

roman@freepuppy ~/tmp 1033:0 > cat ~/install/php4/config.nice.cli      
 
#! /bin/sh
#
# Created by configure

'./configure' \
'--enable-cli' \
'--enable-inline-optimization' \
'--enable-ftp' \
'--enable-shmop' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-sockets' \
'--enable-tokenizer' \
'--disable-session' \
'--disable-shared' \
'--with-openssl' \
'--with-zlib' \
'--with-bz2' \
'--with-curl' \
'--with-gettext' \
'--with-iconv' \
'--with-mcrypt=/usr/local' \
'--with-mhash=/usr/local' \
'--with-ncurses' \
'--with-readline' \
'--with-pear' \
'--with-config-file-path=/usr/local/etc' \
'--with-mysql=/usr/local' \
"$@"

I ./configure --disable-all --enable-cli with the same result.



------------------------------------------------------------------------

[2002-10-18 03:49:52] [EMAIL PROTECTED]

cynic - can you try HEAD or a snapshot from the last day or so?
I fixed an eof related issue recently.

------------------------------------------------------------------------

[2002-10-18 03:45:31] [EMAIL PROTECTED]

I get bool(true) with 4.2.3 and 4.3.0-dev (from yesterday), both
mod_php, Linux 2.4.19.

Maybe it's a documentation problem:

the manual only says about the return value of fgets():

  If an error occurs, returns FALSE.

Nothing is said about the return value on EOF (only "People used to the
'C' semantics of fgets()  should note the difference in how EOF is
returned."), so I guess fgets() is free to return whatever it likes on
EOF. Was this different in previous versions of PHP?

------------------------------------------------------------------------

[2002-10-18 01:57:06] [EMAIL PROTECTED]

am I the only one who thinks that this should not output anything?

<?php
$fd = fopen(__FILE__, 'r');
while (!feof($fd)) fgets($fd, 4096) || var_dump(feof($fd));
fclose($fd);

I get bool(false) from 4.4.0-dev (cli) and 4.2.2 mod_php.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=19970&edit=1

Reply via email to