Date: Sat, 04 Nov 1995 02:03:54 +0900 From: KATO Takenori <kato@eclogite.eps.nagoya-u.ac.jp> To: freebsd-bugs@freefall.freebsd.org, bde@zeta.org.au Subject: Re: bin/809: printf goroup bug [`.' optional precision] Message-ID: <199511031703.CAA08762@marble.eps.nagoya-u.ac.jp> In-Reply-To: Your message of "Fri, 3 Nov 1995 01:10:02 -0800" References: <199511030910.BAA00216@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
I've made a fix for vfprintf bug. Please take a look. > printf("%.3d\n", -1); > printf("%.3d\n", 1); > printf("%+.3d\n", -1); > printf("%+.3d\n", 1); > printf("% .3d\n", -1); > printf("% .3d\n", 1); > printf("%#.3x\n", 1); gives the following result: -001 001 -001 +001 -001 001 0x001 ---------- BEGIN ---------- *** vfprintf.c.old Sat Nov 4 00:29:15 1995 --- vfprintf.c Sat Nov 4 00:32:44 1995 *************** *** 695,706 **** * Compute actual size, so we know how much to pad. * fieldsz excludes decimal prec; realsz includes it. */ ! fieldsz = size; if (sign) ! fieldsz++; else if (flags & HEXPREFIX) ! fieldsz += 2; ! realsz = dprec > fieldsz ? dprec : fieldsz; /* right-adjusting blank padding */ if ((flags & (LADJUST|ZEROPAD)) == 0) --- 695,705 ---- * Compute actual size, so we know how much to pad. * fieldsz excludes decimal prec; realsz includes it. */ ! realsz = dprec > size ? dprec : size; if (sign) ! realsz++; else if (flags & HEXPREFIX) ! realsz += 2; /* right-adjusting blank padding */ if ((flags & (LADJUST|ZEROPAD)) == 0) *************** *** 720,726 **** PAD(width - realsz, zeroes); /* leading zeroes from decimal precision */ ! PAD(dprec - fieldsz, zeroes); /* the string or number proper */ #ifdef FLOATING_POINT --- 719,725 ---- PAD(width - realsz, zeroes); /* leading zeroes from decimal precision */ ! PAD(dprec - size, zeroes); /* the string or number proper */ #ifdef FLOATING_POINT ---------- END ---------- ---- KATO Takenori Dept. Earth Planet. Sci. Nagoya Univ. Nagoya 464-01 JAPAN Voice: +81-52-789-2529 E-mail: kato@eclogite.eps.nagoya-u.ac.jp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511031703.CAA08762>