Bug #61532 [Opn]: Apostrophe modifier in *printf is broken
| From: | johannes@php.net | Date: | Thu, 12 Apr 2012 10:09:19 +0000 |
| Subject: | Bug #61532 [Opn]: Apostrophe modifier in *printf is broken | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-169472@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61532&edit=1
ID: 61532
Updated by: johannes@php.net
Reported by: iblue at gmx dot net
Summary: Apostrophe modifier in *printf is broken
Status: Open
Type: Bug
Package: Strings related
Operating System: GNU/Linux
PHP Version: 5.4.0
Block user comment: N
Private report: N
New Comment:
The current behaviour seems to be in line with what libc does, both on Linux and Solaris (and gcc
and suncc):
$ cat test.c
#include <stdio.h>
void main() {
printf("%'.09i\n", 123);
}
$ gcc -otest test.c
$ ./test
000000123
Previous Comments:
------------------------------------------------------------------------
[2012-03-27 21:28:09] iblue at gmx dot net
Description:
------------
When I use the apostrophe (') modifier to select a padding character in printf,
it behaves buggy, when the padding length itself is prefixed by zeroes.
Test script:
---------------
<?php
echo sprintf("%'.9s\n", "foo");
echo sprintf("%'.09s\n", "foo");
Expected result:
----------------
......foo
......foo
Actual result:
--------------
......foo
000000foo
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61532&edit=1