cvs: /php3/functions formatted_print.c

From: Date: Tue, 03 Aug 1999 19:52:37 +0000
Subject: cvs: /php3/functions formatted_print.c
Groups: php.dev 
Request: Send a blank email to php-dev+get-9482@lists.php.net to get a copy of this message
rasmus Tue Aug 3 15:52:37 1999 EDT Modified files: /php3/functions formatted_print.c Log: Fix for bug #1952 Also disable right-padding with 0's in %-06d for example to be compatible with the ANSI C behaviour Index: php3/functions/formatted_print.c diff -u php3/functions/formatted_print.c:1.48 php3/functions/formatted_print.c:1.49 --- php3/functions/formatted_print.c:1.48 Sun Jun 27 21:21:59 1999 +++ php3/functions/formatted_print.c Tue Aug 3 15:52:37 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.48 1999/06/28 01:21:59 sas Exp $ */ +/* $Id: formatted_print.c,v 1.49 1999/08/03 19:52:37 rasmus Exp $ */ #ifdef THREAD_SAFE #include "tls.h" @@ -50,9 +50,9 @@ #define MAX_FLOAT_DIGITS 38 #define MAX_FLOAT_PRECISION 40 -#if 0 +#if 1 /* trick to control varargs functions through cpp */ -# define PRINTF_DEBUG(arg) php3_printf arg +# define PRINTF_DEBUG(arg) printf arg #else # define PRINTF_DEBUG(arg) #endif @@ -167,7 +167,7 @@ inline static void _php3_sprintf_appendstring(char **buffer, int *pos, int *size, char *add, int min_width, int max_width, char padding, - int alignment, int len) + int alignment, int len, int sign) { register int npad = min_width - MIN(len,(max_width?max_width:len)); @@ -187,7 +187,9 @@ PRINTF_DEBUG(("sprintf ereallocing buffer to %d bytes\n", *size)); *buffer = erealloc(*buffer, *size); } + printf("bogus\n"); if (alignment == ALIGN_RIGHT) { + if (sign && padding=='0') { (*buffer)[(*pos)++] = '-'; add++; } while (npad-- > 0) { (*buffer)[(*pos)++] = padding; } @@ -219,6 +221,9 @@ magn = (unsigned int) number; } + /* Can't right-pad 0's on integers */ + if(alignment==0 && padding=='0') padding=' '; + numbuf[i] = '\0'; do { @@ -234,7 +239,7 @@ PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", number, &numbuf[i], i)); _php3_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0, - padding, alignment, (NUM_BUF_SIZE - 1) - i); + padding, alignment, (NUM_BUF_SIZE - 1) - i, neg); } @@ -295,7 +300,7 @@ width += (precision + 1); } _php3_sprintf_appendstring(buffer, pos, size, numbuf, width, 0, padding, - alignment, i); + alignment, i, sign); } @@ -332,7 +337,7 @@ numbuf[--i] = '-'; } _php3_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0, - padding, alignment, (NUM_BUF_SIZE - 1) - i); + padding, alignment, (NUM_BUF_SIZE - 1) - i, neg); } @@ -486,7 +491,7 @@ args[currarg]->value.str.val, width, precision, padding, alignment, - args[currarg]->value.str.len); + args[currarg]->value.str.len,0); break; case 'd':

« previous php.dev (#9482) next »