Bug->Doc #61532 [Opn]: Apostrophe modifier in *printf is broken
| From: | johannes@php.net | Date: | Thu, 12 Apr 2012 10:13:52 +0000 |
| Subject: | Bug->Doc #61532 [Opn]: Apostrophe modifier in *printf is broken | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8245@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
+Type: Documentation Problem
Package: Strings related
Operating System: GNU/Linux
PHP Version: 5.4.0
Block user comment: N
Private report: N
New Comment:
It should be documented that 0 as padding specifier overwrites a manually set one.
Previous Comments:
------------------------------------------------------------------------
[2012-04-12 10:09:19] johannes@php.net
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
------------------------------------------------------------------------
[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