php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #20460 Additional fscanf argument
Submitted: 2002-11-17 00:53 UTC Modified: 2002-11-27 14:28 UTC
From: paul79 at optonline dot net Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.2.3 OS: FreeBSD 4.7
Private report: No CVE-ID: None
 [2002-11-17 00:53 UTC] paul79 at optonline dot net
Not sure if this was already considered, but I didn't see it documented anywhere and thought it would be nice to have.  It doesn't state in the documentation about the  maximum length of the string being  read can be, nor do I know what it currenly is.  I think it's 1024.  I have a line in a file that's 1630 characters long.  When a run the program with fscanf, it obvisouly doesn't read the whole line.

For instance:

list($v1, $v2) = fscanf($pt, "%[^|]|%[^\n]\n");

The "\n" is never reached and the program breaks.

There is a work around, which would be to substitute the fscanf with something like:

split("\|", fgets($pt, 8026));

So, I guess what I'm getting at is, is it at all possible to:

a) add a length the read to fscanf
or
b) update the documentation to show this limitation


Thanks For Listening,
Paul

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-27 13:16 UTC] pollita@php.net
php4/ext/standard/file.h:
#define SCAN_MAX_FSCANF_BUFSIZE 512


I'll see if we can increase this or make it optional...


 [2002-11-27 14:28 UTC] derick@php.net
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.

From PHP 4.3.0 and higher this will work with any line length. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Sep 08 01:01:28 2024 UTC