From: Glenn Burkhardt Date: Tue, 30 Sep 2003 19:55:12 +0000 (+0000) Subject: restored use of PUTDF() macro; was broken in versions 1.10-1.12; X-Git-Tag: RELEASE_1_2~66 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=076b15369a863a489181015d3d9a39db38c6856d;p=mmh restored use of PUTDF() macro; was broken in versions 1.10-1.12; replacement implementation filled on right instead of on left. --- diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 4365e35..c9b882d 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -88,6 +88,25 @@ match (char *str, char *sub) /* * macros to format data */ +#define PUTDF(cp, num, wid, fill)\ + if (cp + wid < ep) {\ + if ((i = (num)) < 0)\ + i = -(num);\ + if ((c = (wid)) < 0)\ + c = -c;\ + sp = cp + c;\ + do {\ + *--sp = (i % 10) + '0';\ + i /= 10;\ + } while (i > 0 && sp > cp);\ + if (i > 0)\ + *sp = '?';\ + else if ((num) < 0 && sp > cp)\ + *--sp = '-';\ + while (sp > cp)\ + *--sp = fill;\ + cp += c;\ + } #ifdef LOCALE #define PUTSF(cp, str, wid, fill) {\ @@ -310,12 +329,7 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) if (n >= 0) cp += n; break; case FT_NUMF: - n = snprintf(cp, ep - cp, "%d", value); - if (n >= 0) { - cp += n; - } else n = 0; - c = abs(fmt->f_width) - n; - for (; (c > 0) && (cp < ep); c--) *cp++ = fmt->f_fill; + PUTDF (cp, value, fmt->f_width, fmt->f_fill); break; case FT_CHAR: