ID: 35495
User updated by: dsp at tdcspace dot dk
Reported By: dsp at tdcspace dot dk
Status: Bogus
Bug Type: Filesystem function related
Operating System: linux/win
PHP Version: 5CVS, 4CVS (2005-11-30) (snap)
Assigned To: wez
New Comment:
Taken from the PHP manual
--------------------------------
feof -- Tests for end-of-file on a file pointer
Description
bool feof ( resource handle )
Returns TRUE if the file pointer is at EOF or an error occurs
(including socket timeout); otherwise returns FALSE.
--------------------------------
Read a file with only 4 chars "0123". The chars correspond to what
ftell() reports (0 at open) and 4 after reading 4 with fgets(5).
File-pointer is then 4 - aka the next read position which is beyond
last char and thus EOF. This must be proof enough of inconsistency.
Either the manual or the feof() need to be corrected - i prefer
feof().
Still php is great - and i help to make it better !
Previous Comments:
------------------------------------------------------------------------
[2005-12-01 01:07:05] [EMAIL PROTECTED]
I get the same result with this C code:
#include <stdlib.h>
#include <stdio.h>
int main() {
FILE *fd;
fd = fopen("/tmp/xxx", "r");
while (!feof(fd)) {
char buf[100];
fgets(buf, 100, fd); // remove that and you'll get endless
cycle
printf("read\n");
}
fclose(fd);
return 0;
}
(it reads once and stops just after that)
Doesn't look like a bug to me.
PHP behaves in the same way as the underlying OS.
------------------------------------------------------------------------
[2005-11-30 23:43:40] [EMAIL PROTECTED]
Wez, sounds like something isn't working quite well in the streams
world?
------------------------------------------------------------------------
[2005-11-30 22:46:26] dsp at tdcspace dot dk
what i don't understand is that the win/linux lower filesystem layer
maintains a filepointer of which it should be easy to detect/report a
EOF condition. The PHP handle as a file descriptor resource should
among things maintain this.
But i don't maintain php and thus don't know the reasons.
------------------------------------------------------------------------
[2005-11-30 22:40:21] dsp at tdcspace dot dk
nope - 5.1.2.2 cvs - same story - feof() still ignores a zero file
------------------------------------------------------------------------
[2005-11-30 18:42:43] [EMAIL PROTECTED]
No, try the 5.1 snapshot.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/35495
--
Edit this bug report at http://bugs.php.net/?id=35495&edit=1