php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22922 sprintf formatted string
Submitted: 2003-03-27 05:27 UTC Modified: 2003-03-27 05:50 UTC
From: y dot leconte dot akis at nerim dot fr Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.1 OS: Linux
Private report: No CVE-ID: None
 [2003-03-27 05:27 UTC] y dot leconte dot akis at nerim dot fr
Hello.

I find a problem in the sprintf function when i try to format a string.

example:

<?
$out=sprintf("%4.4s","123456789");
echo strlen($out)." - $out<BR>";
?>

result: 9 - 123456789 instead of 4 - 1234

Formats %xs and %.ys work but not format like %x.ys where x and y are numbers.

The problem seems to come from the php_sprintf_appendstring
function located in the ext/standard/formatted_print.c file.

Putting in comment the following lines:

    /* if (max_width && min_width) { 
        expprec = max_width = 0;
    } */

seems to resolve the problem. But i dont know the possible impacts of this modification on others zend functions.
 
Best regards

Yves

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-27 05:49 UTC] moriyoshi@php.net
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

Actually dupe of bug #22224
 [2003-03-27 05:50 UTC] moriyoshi@php.net
Non, bug #22227

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 06:01:29 2024 UTC