From:             jochen at keutel dot de
Operating system: Solaris 8
PHP version:      4.3.7
PHP Bug Type:     Filesystem function related
Bug description:  feof() problems if 2 files are open

Description:
------------
If I open 2 files with fopen and parse them with fgets then feof doesn't
work correctly. Example:

file1: (2 lines)
line 1
line 2

file2: (4 lines)
line 1
line 2
line 3
line 4

The code provided should return only 2 lines of file1 and should stop
than. but it returns 3 lines of file1.

If I remove the code handling file2 from the code
(http://keutel.de/test_feof2.txt) then all works fine.

Reproduce code:
---------------
see http://keutel.de/test_feof1.txt :

$handle1 = fopen ("file1", "r");
$handle2 = fopen ("file2", "r");
while (TRUE) {
    if (feof($handle1) && feof($handle2)) {
      echo "both over\n";
      break;
    }
    if (feof($handle1) || feof($handle2)) {
      echo "one is over\n";
      break;
    }
    $buffer1 = fgets($handle1, 4096);
    $buffer2 = fgets($handle2, 4096);
    echo "file1: ".$buffer1;
    echo "file2: ".$buffer2;
}

Expected result:
----------------
file1: line 1
file2: line 1
file1: line 2
file2: line 2
one is over


Actual result:
--------------
file1: line 1
file2: line 1
file1: line 2
file2: line 2
file1: file2: line 3
one is over


-- 
Edit bug report at http://bugs.php.net/?id=28926&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28926&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28926&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28926&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28926&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28926&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28926&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28926&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28926&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28926&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28926&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28926&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28926&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28926&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28926&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28926&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28926&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28926&r=float

Reply via email to