cvs: php4 /main snprintf.c

From: Date: Wed, 21 Aug 2002 01:11:50 +0000
Subject: cvs: php4 /main snprintf.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-13513@lists.php.net to get a copy of this message
helly Tue Aug 20 21:11:50 2002 EDT Modified files: /php4/main snprintf.c Log: make snprintf and f,g,G converions of snprintf/spprintf C99 complient Index: php4/main/snprintf.c diff -u php4/main/snprintf.c:1.16 php4/main/snprintf.c:1.17 --- php4/main/snprintf.c:1.16 Sat Jun 22 20:34:47 2002 +++ php4/main/snprintf.c Tue Aug 20 21:11:50 2002 @@ -390,8 +390,10 @@ *p2++ = decpt % 10 + '0'; } else { if (decpt <= 0) { - if (*p1 != '0') + if (*p1 != '0') { + *p2++ = '0'; *p2++ = '.'; + } while (decpt < 0) { decpt++; *p2++ = '0'; @@ -444,14 +446,14 @@ * * NOTE: Evaluation of the c argument should not have any side-effects */ -#define INS_CHAR( c, sp, bep, cc ) \ - { \ - if ( sp < bep ) \ - { \ - *sp++ = c ; \ - cc++ ; \ - } \ - } +#define INS_CHAR(c, sp, bep, cc) \ + { \ + if (sp < bep) \ + { \ + *sp++ = c; \ + } \ + cc++; \ + } #define NUM( c ) ( c - '0' ) @@ -885,14 +887,19 @@ * Notice that if no length is given, we initialize buf_end to the * highest possible address. */ - od.buf_end = len ? &buf[len] : (char *) ~0; - od.nextb = buf; + if (len == 0) { + od.buf_end = (char *) ~0; + od.nextb = (char *) ~0; + } else { + od.buf_end = &buf[len-1]; + od.nextb = buf; + } /* * Do the conversion */ cc = format_converter(&od, format, ap); - if (len == 0 || od.nextb <= od.buf_end) + if (len != 0 && od.nextb <= od.buf_end) *(od.nextb) = '\0'; if (ccp) *ccp = cc; @@ -905,7 +912,7 @@ va_list ap; va_start(ap, format); - strx_printv(&cc, buf, (len - 1), format, ap); + strx_printv(&cc, buf, len, format, ap); va_end(ap); return (cc); } @@ -915,7 +922,7 @@ { int cc; - strx_printv(&cc, buf, (len - 1), format, ap); + strx_printv(&cc, buf, len, format, ap); return (cc); }

« previous php.cvs (#13513) next »