cvs: php4 /ext/standard basic_functions.c formatted_print.c

From: Date: Sun, 20 May 2001 00:23:49 +0000
Subject: cvs: php4 /ext/standard basic_functions.c formatted_print.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5861@lists.php.net to get a copy of this message
derick Sat May 19 17:23:49 2001 EDT Modified files: /php4/ext/standard basic_functions.c formatted_print.c Log: - Reversed 'fix' for #9698 - Fix for bug #9698/#10681 (patch by kettler@gmx.net) @- Added the 'u' modifier to printf/sprintf which prints unsigned longs. @ (Derick) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.341 php4/ext/standard/basic_functions.c:1.342 --- php4/ext/standard/basic_functions.c:1.341 Sat May 19 15:21:40 2001 +++ php4/ext/standard/basic_functions.c Sat May 19 17:23:49 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.341 2001/05/19 22:21:40 sniper Exp $ */ +/* $Id: basic_functions.c,v 1.342 2001/05/20 00:23:49 derick Exp $ */ #include "php.h" #include "php_main.h" @@ -960,7 +960,6 @@ PHP_FUNCTION(ip2long) { zval **str; - char tmp_buff[16]; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { WRONG_PARAM_COUNT; @@ -968,9 +967,7 @@ convert_to_string_ex(str); - sprintf(tmp_buff, "%u", ntohl(inet_addr(Z_STRVAL_PP(str)))); - - RETURN_STRING(tmp_buff,1); + RETURN_LONG(ntohl(inet_addr(Z_STRVAL_PP(str)))); } /* }}} */ Index: php4/ext/standard/formatted_print.c diff -u php4/ext/standard/formatted_print.c:1.31 php4/ext/standard/formatted_print.c:1.32 --- php4/ext/standard/formatted_print.c:1.31 Wed Apr 25 14:05:59 2001 +++ php4/ext/standard/formatted_print.c Sat May 19 17:23:49 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.31 2001/04/25 21:05:59 rasmus Exp $ */ +/* $Id: formatted_print.c,v 1.32 2001/05/20 00:23:49 derick Exp $ */ #include <math.h> /* modf() */ #include "php.h" @@ -232,7 +232,34 @@ neg, 0); } +inline static void +php_sprintf_appenduint(char **buffer, int *pos, int *size, int number, + int width, char padding, int alignment) +{ + char numbuf[NUM_BUF_SIZE]; + register unsigned int magn, nmagn, i = NUM_BUF_SIZE - 1; + + PRINTF_DEBUG(("sprintf: appenduint(%x, %x, %x, %d, %d, '%c', %d)\n", + *buffer, pos, size, number, width, padding, alignment)); + magn = (unsigned int) number; + /* Can't right-pad 0's on integers */ + if (alignment == 0 && padding == '0') padding = ' '; + + numbuf[i] = '\0'; + + do { + nmagn = magn / 10; + + numbuf[--i] = (magn - (nmagn * 10)) + '0'; + magn = nmagn; + } + while (magn > 0 && i > 0); + PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", number, &numbuf[i], i)); + php_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0, + padding, alignment, (NUM_BUF_SIZE - 1) - i, 0, 0); +} + inline static void php_sprintf_appenddouble(char **buffer, int *pos, int *size, double number, @@ -524,6 +551,13 @@ case 'd': convert_to_long_ex(args[argnum]); php_sprintf_appendint(&result, &outpos, &size, + (*args[argnum])->value.lval, + width, padding, alignment); + break; + + case 'u': + convert_to_long_ex(args[argnum]); + php_sprintf_appenduint(&result, &outpos, &size, (*args[argnum])->value.lval, width, padding, alignment); break;

« previous php.cvs (#5861) next »