ID:               22286
 Updated by:       [EMAIL PROTECTED]
 Reported By:      moptop69 at ntlworld dot com
-Status:           Feedback
+Status:           Closed
 Bug Type:         Filesystem function related
 Operating System: Win2k Pro Sp3
 PHP Version:      4.3.1
 New Comment:

fixed in latest stable snapshot -> closed.



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

[2003-02-19 09:31:11] noptop69 at ntlworld dot com

seems to work ok now

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

[2003-02-18 22:55:45] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip


And if that doesn't work either, provide a complete but short example
script and data. (Do NOT add anything over 20 lines in the report,
provide an url to them instead)


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

[2003-02-18 21:19:50] moptop69 at ntlworld dot com

okay, i've recently come accross a problem on Win2k, after a hardrive
crash, i installed the latest PHP release (4.3.0) and tried to run a
script that mainly consists of parsing a Python 'pickled' output file
into a MySql table format.

Mostly its a continuous fread from start to finish, but in certain
areas, i have to check the next byte in the file using this code:

function gtnxt(&$my2ndFnFile, &$i)
{
//  fseek($my2ndFnFile, $i);
  $data=fread($my2ndFnFile,1);
  fseek($my2ndFnFile, $i);
  $d0=ord($data[0]);
  return $d0;
}

and read the byte again after ive checked its byte value with:

function gt_8(&$my2ndFnFile, &$i)
{
//  fseek($my2ndFnFile, $i);
  $data=fread($my2ndFnFile,1);
  $i+=1;
  $d0=ord($data[0]);
  return $d0;
}

the first variable in both functions is the file handle (opened with
"rb" options), and the second, $i, is the file pointer, i keep track of
it exactly, since its a very exact requirement to parse these files.

the problem i got is this, gtnxt() is returning the correct byte value
of the byte @ $i, however, gt_8()is not, it is returning 00 (in every
case of it I could see).

I added debug lines into the code so that each time gtnxt() was called
followed by a gt_8() the file pointer and the value were commented into
the resultant html, so i could see why things were not going
correctly.

Once I saw the issue was that the first read of the byte was correct
but the second read was incorrect, I suspected the possibility of the
fseek in gtnxt() not working correctly, and added in 2 new fseek lines
(commented out in the above code) which actually worked slightly
better, allowing the script to parse quite readily, but still showing
the same problem further on in the script (about 1000 bytes onward).

I uploaded the script as was to the site server, and it ran fine
(apache on redhat 7.1 running PHP4.1.2) so i knew the script worked
fine.

I upgraded to 4.3.1 just in case (it had come out a day later) but I
expected no changes due to the explanantion of the 4.3.1 revision and
was correct, the same issue arose.

I downgraded PHP to 4.2.3 running ISAPI with the same results.  I
beleive I was running ISAPI under 4.2.1 before the crash when i knew
the script worked ok.

Finally I decided to try running the CGI instead of ISAPI and all
worked fine.  I upgraded back to 4.3.1 running CGI and everything
worked fine again.

The conclusion i came to is that ISAPI has a problem with either
fseek() or fread() but I cannot tell which.

One other change that I have not been able to test, is that the
'pickled' file i am parsing has increased in size by 250% from 270k to
about 680k which may also be a factor.



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


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

Reply via email to