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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: y dot leconte dot akis at nerim dot fr
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 17:01:58 2024 UTC