diff options
author | Derick Rethans <derick@php.net> | 2001-05-20 00:23:49 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2001-05-20 00:23:49 +0000 |
commit | dc43b9f574804d836ef2905b41a2ef0420f2a0f5 (patch) | |
tree | d2210b58036af2a2dff913e84c3fd6a8599f9bb3 /ext/standard/formatted_print.c | |
parent | ae3dda82856b772da28424e229b29b07b2c95da4 (diff) | |
download | php-git-dc43b9f574804d836ef2905b41a2ef0420f2a0f5.tar.gz |
- 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)
Diffstat (limited to 'ext/standard/formatted_print.c')
-rw-r--r-- | ext/standard/formatted_print.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index ec89a0b2c0..e5e5708c92 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -232,6 +232,33 @@ php_sprintf_appendint(char **buffer, int *pos, int *size, int number, 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, @@ -528,6 +555,13 @@ php_formatted_print(int ht, int *len) 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; + case 'e': case 'f': /* XXX not done */ |