Bug #68481 [Opn->Csd]: feof true on php://temp one byte early

From: Date: Sat, 24 Jan 2015 18:47:34 +0000
Subject: Bug #68481 [Opn->Csd]: feof true on php://temp one byte early
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190180@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68481&edit=1

 ID:                 68481
 User updated by:    tim_siebels_aurich at yahoo dot de
 Reported by:        tim_siebels_aurich at yahoo dot de
 Summary:            feof true on php://temp one byte early
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Streams related
 Operating System:   Tested on Ubuntu
 PHP Version:        5.6.3
 Block user comment: N
 Private report:     N

 New Comment:

Love it :)


Previous Comments:
------------------------------------------------------------------------
[2015-01-24 12:47:15] php at mcq8 dot be

Can you test again in 5.6.5 or 5.5.21?
It should now behave like you expected it to be.

------------------------------------------------------------------------
[2015-01-06 14:09:33] tim_siebels_aurich at yahoo dot de

I am complaining that feof returns TRUE one byte early in php://temp.
When you read the description of the bug I explain how C handles it, and how I would expect it to
be.

------------------------------------------------------------------------
[2015-01-06 06:11:57] yvan dot burrie at hotmail dot com

Wait!!! This is not a bug! PHP imitates C++ feof() function from the STDIO library.

Read this: http://stackoverflow.com/questions/5431941/while-feof-file-is-always-wrong

------------------------------------------------------------------------
[2015-01-03 12:48:18] yvan dot burrie at hotmail dot com

<?php

// yep, it's a bug!!!

$f = tmpfile();

fwrite($f, 'crap' ); // 4 bytes

rewind($f);

$i=1;
while( !feof($f) )
{
fread($f,1);
echo "$i\n";
$i++;
}

/*
outputs:

1
2
3
4
5

why the hell 5 bytes? should normally output 4 bytes:

1
2
3
4

*/

?>

------------------------------------------------------------------------
[2014-12-15 17:27:23] php at mcq8 dot be

I recently changed it for memory https://github.com/php/php-src/pull/936.
It would be better if all the streams behave the same way.

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


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

    https://bugs.php.net/bug.php?id=68481


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


Thread (9 messages)

« previous php.bugs (#190180) next »