On Mon, Nov 25, 2013 at 7:38 AM, Anatol Belski <[email protected]> wrote:
> On Mon, November 25, 2013 07:09, Nikita Popov wrote:
> > On Sun, Nov 24, 2013 at 10:10 PM, Anatol Belski <[email protected]> wrote:
> >
> >
> >> Commit: d8c7d69543c8cc0609facb2d35e636cb59c38385
> >> Author: Anatol Belski <[email protected]> Sun, 24 Nov 2013 22:10:57
> >> +0100
> >> Parents: 08bbd2b5101006eabc932a6076417336ebcaf889
> >> Branches: str_size_and_int64
> >>
> >>
> >> Link:
> >>
> http://git.php.net/?p=php-src.git;a=commitdiff;h=d8c7d69543c8cc0609facb2
> >> d35e636cb59c38385
> >>
> >> Log:
> >> printf int format fixes
> >>
> >> Changed paths:
> >> M Zend/zend_API.c
> >> M Zend/zend_builtin_functions.c
> >> M Zend/zend_exceptions.c
> >> M Zend/zend_execute.c
> >> M Zend/zend_operators.c
> >>
> >>
> >>
> >> Diff:
> >> diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 869f1a5..912f0e3
> >> 100644
> >> --- a/Zend/zend_API.c
> >> +++ b/Zend/zend_API.c
> >> @@ -1580,7 +1580,7 @@ ZEND_API int array_set_zval_key(HashTable *ht,
> >> zval *key, zval *value) /* {{{ */
> >> result = zend_symtable_update(ht, "", 1, &value, sizeof(zval *), NULL);
> >> break; case IS_RESOURCE: - zend_error(E_STRICT,
> >> "Resource ID#%ld used as
> >> offset, casting to integer (%ld)", Z_LVAL_P(key), Z_LVAL_P(key)); +
> >> zend_error(E_STRICT, "Resource ID#" ZEND_INT_FMT " used as offset,
> >> casting to integer (" ZEND_INT_FMT ")", Z_LVAL_P(key), Z_LVAL_P(key));
> >> /* break missing intentionally */
> >>
> >>
> >
> > Replacing "%ld" with "ZEND_INT_FMT" everywhere seems a bit awkward.
> > Why
> > not add modifiers for this directly to our printf functions?
> >
> > Nikita
> >
>
> Hi Nikita,
>
> actually I thought about something like that. You mean to replace %ld with
> appropriate ZEND_INT_FMT? What held me on is that sometimes on needs
> exactly %ld.
>
> Regards
>
No, I mean adding a modifier for %d. Not sure what it should be called as
%zd is already taken for size_t and %Zd is already taken by %Z zval
printing. Could do %pd (p for PHP ^^).
The modifier handling for vssprintfs can be found at
http://lxr.php.net/xref/PHP_TRUNK/main/spprintf.c#311
and below that the
modifier needs to be implemented for %u, %d/%i, %o and %x/%X. Same applies
to http://lxr.php.net/xref/PHP_TRUNK/main/snprintf.c#704
for
snprintf/slprintf. It would likely be also handy to have some easy way of
printing string with length.
(Note: This won't cover all cases, you'd still have to use something like
ZEND_FMT_INT when dealing with the libc printf functions. But it should
cover most of our code.)
Nikita