Hello folks,
In all functions using spprintf(), the output corresponding to the
format conversion specifier "%p" depends on the value of the
*previously* converted argument (if any), not just the pointer
corresponding to the specifier.
1) If the previously-converted argument was a non-zero integer, the
hexadecimal string value will be correctly prefixed with "0x".
2) If there was no previously-converted argument, or if it was zero or a
non-integer, the "0x" hexadecimal prefix will be missing.
The attached patch fixes this problem, as also reported in bug #28012
http://bugs.php.net/bug.php?id=28012
It's clearly the most minor of minor bugs but the output of %p has
puzzled me for a while and I decided today to track it down. Hope this
helps!
Thanks,
Eric Lambart
Index: spprintf.c
===================================================================
RCS file: /repository/php-src/main/spprintf.c,v
retrieving revision 1.23
diff -u -r1.23 spprintf.c
--- spprintf.c 8 Mar 2004 23:11:44 -0000 1.23
+++ spprintf.c 15 Apr 2004 20:41:46 -0000
@@ -646,7 +646,7 @@
ui_num = (u_wide_int)((size_t) va_arg(ap, char *));
s = ap_php_conv_p2(ui_num, 4, 'x',
&num_buf[NUM_BUF_SIZE], &s_len);
- if (i_num != 0) {
+ if (ui_num != 0) {
*--s = 'x';
*--s = '0';
s_len += 2;
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php