iliaa Tue Jan 13 18:31:46 2004 EDT
Added files: (Branch: PHP_4_3)
/php-src/ext/standard/tests/strings bug26878.phpt
Modified files:
/php-src NEWS
/php-src/ext/standard formatted_print.c
Log:
MFH: Fixed bug #26878 (problem with multiple references to the same variable
with different types).
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.523 php-src/NEWS:1.1247.2.524
--- php-src/NEWS:1.1247.2.523 Tue Jan 13 14:00:17 2004
+++ php-src/NEWS Tue Jan 13 18:31:44 2004
@@ -1,5 +1,10 @@
PHP 4 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+?? Jan 2004, Version 4.3.5
+- Fixed bug #26878 (problem with multiple references to the same variable
+ with different types). (Ilia)
+- Fixed bug #26896 (ext/ftp does not work as shared extension). (Jani)
+
12 Jan 2004, Version 4.3.5RC1
- Synchronized bundled GD library with GD 2.0.17
- Upgraded PCRE library to version 4.5. (Andrei)
@@ -10,7 +15,6 @@
- Added a warning when creating temp stream fails with ftp_(n)list(). (Sara)
- Fixed header handler in NSAPI SAPI module (header->replace was ignored,
send_default_content_type now sends value from php.ini). (Uwe Schindler)
-- Fixed bug #26896 (ext/ftp does not work as shared extension). (Jani)
- Fixed bug #26864 (pg_(update|delete) ignore PGSQL_DML_EXEC option). (Ilia)
- Fixed bug #26847 (memory leak in mail() when to/subject contain only spaces).
(Ilia)
Index: php-src/ext/standard/formatted_print.c
diff -u php-src/ext/standard/formatted_print.c:1.59.2.5
php-src/ext/standard/formatted_print.c:1.59.2.6
--- php-src/ext/standard/formatted_print.c:1.59.2.5 Fri May 30 09:50:09 2003
+++ php-src/ext/standard/formatted_print.c Tue Jan 13 18:31:45 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: formatted_print.c,v 1.59.2.5 2003/05/30 13:50:09 moriyoshi Exp $ */
+/* $Id: formatted_print.c,v 1.59.2.6 2004/01/13 23:31:45 iliaa Exp $ */
#include <math.h> /* modf() */
#include "php.h"
@@ -499,7 +499,8 @@
currarg = 1;
while (inpos<Z_STRLEN_PP(args[0])) {
- int expprec = 0;
+ int expprec = 0, multiuse = 0;
+ zval *tmp;
PRINTF_DEBUG(("sprintf: format[%d]='%c'\n", inpos, format[inpos]));
PRINTF_DEBUG(("sprintf: outpos=%d\n", outpos));
@@ -537,7 +538,8 @@
php_error_docref(NULL TSRMLS_CC,
E_WARNING, "Zero is not a valid argument number");
return NULL;
}
-
+
+ multiuse = 1;
inpos++; /* skip the '$' */
} else {
argnum = currarg++;
@@ -608,29 +610,37 @@
}
PRINTF_DEBUG(("sprintf: format character='%c'\n",
format[inpos]));
/* now we expect to find a type specifier */
+ if (multiuse) {
+ MAKE_STD_ZVAL(tmp);
+ *tmp = **(args[argnum]);
+ zval_copy_ctor(tmp);
+ } else {
+ tmp = *(args[argnum]);
+ }
+
switch (format[inpos]) {
case 's':
- convert_to_string_ex(args[argnum]);
+ convert_to_string(tmp);
php_sprintf_appendstring(&result, &outpos,
&size,
-
Z_STRVAL_PP(args[argnum]),
+
Z_STRVAL_P(tmp),
width, precision, padding,
alignment,
-
Z_STRLEN_PP(args[argnum]),
+
Z_STRLEN_P(tmp),
0, expprec);
break;
case 'd':
- convert_to_long_ex(args[argnum]);
+ convert_to_long(tmp);
php_sprintf_appendint(&result, &outpos, &size,
-
Z_LVAL_PP(args[argnum]),
+
Z_LVAL_P(tmp),
width, padding, alignment,
always_sign);
break;
case 'u':
- convert_to_long_ex(args[argnum]);
+ convert_to_long(tmp);
php_sprintf_appenduint(&result, &outpos, &size,
-
Z_LVAL_PP(args[argnum]),
+
Z_LVAL_P(tmp),
width, padding, alignment,
always_sign);
break;
@@ -638,9 +648,9 @@
case 'e':
case 'f':
/* XXX not done */
- convert_to_double_ex(args[argnum]);
+ convert_to_double(tmp);
php_sprintf_appenddouble(&result, &outpos,
&size,
-
Z_DVAL_PP(args[argnum]),
+
Z_DVAL_P(tmp),
width, padding, alignment,
precision, adjusting,
format[inpos], always_sign
@@ -648,39 +658,39 @@
break;
case 'c':
- convert_to_long_ex(args[argnum]);
+ convert_to_long(tmp);
php_sprintf_appendchar(&result, &outpos, &size,
- (char)
Z_LVAL_PP(args[argnum]) TSRMLS_CC);
+ (char)
Z_LVAL_P(tmp) TSRMLS_CC);
break;
case 'o':
- convert_to_long_ex(args[argnum]);
+ convert_to_long(tmp);
php_sprintf_append2n(&result, &outpos, &size,
-
Z_LVAL_PP(args[argnum]),
+
Z_LVAL_P(tmp),
width, padding, alignment, 3,
hexchars, expprec);
break;
case 'x':
- convert_to_long_ex(args[argnum]);
+ convert_to_long(tmp);
php_sprintf_append2n(&result, &outpos, &size,
-
Z_LVAL_PP(args[argnum]),
+
Z_LVAL_P(tmp),
width, padding, alignment, 4,
hexchars, expprec);
break;
case 'X':
- convert_to_long_ex(args[argnum]);
+ convert_to_long(tmp);
php_sprintf_append2n(&result, &outpos, &size,
-
Z_LVAL_PP(args[argnum]),
+
Z_LVAL_P(tmp),
width, padding, alignment, 4,
HEXCHARS, expprec);
break;
case 'b':
- convert_to_long_ex(args[argnum]);
+ convert_to_long(tmp);
php_sprintf_append2n(&result, &outpos, &size,
-
Z_LVAL_PP(args[argnum]),
+
Z_LVAL_P(tmp),
width, padding, alignment, 1,
hexchars, expprec);
break;
@@ -692,6 +702,9 @@
default:
break;
}
+ if (multiuse) {
+ zval_ptr_dtor(&tmp);
+ }
inpos++;
}
}
Index: php-src/ext/standard/tests/strings/bug26878.phpt
+++ php-src/ext/standard/tests/strings/bug26878.phpt
--TEST--
Bug #26878 (problem with multiple references to the same variable with different types)
--FILE--
<?php
printf('Int: %1$d and as string: %1$s', 'some string');
echo "\n";
?>
--EXPECT--
Int: 0 and as string: some string
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
