vfprintf.c (13545) | vfprintf.c (14727) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 292 unchanged lines hidden (view full) --- 301 int expsize; /* character count for expstr */ 302 int ndig; /* actual number of digits returned by cvt */ 303 char expstr[7]; /* buffer for exponent string */ 304#endif 305 u_long ulval; /* integer arguments %[diouxX] */ 306 u_quad_t uqval; /* %q integers */ 307 int base; /* base for [diouxX] conversion */ 308 int dprec; /* a copy of prec if [diouxX], 0 otherwise */ | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 292 unchanged lines hidden (view full) --- 301 int expsize; /* character count for expstr */ 302 int ndig; /* actual number of digits returned by cvt */ 303 char expstr[7]; /* buffer for exponent string */ 304#endif 305 u_long ulval; /* integer arguments %[diouxX] */ 306 u_quad_t uqval; /* %q integers */ 307 int base; /* base for [diouxX] conversion */ 308 int dprec; /* a copy of prec if [diouxX], 0 otherwise */ |
309 int fieldsz; /* field size expanded by sign, etc */ 310 int realsz; /* field size expanded by dprec */ | 309 int realsz; /* field size expanded by dprec, sign, etc */ |
311 int size; /* size of converted field or string */ 312 char *xdigs; /* digits for [xX] conversion */ 313#define NIOV 8 314 struct __suio uio; /* output information: summary */ 315 struct __siov iov[NIOV];/* ... and individual io vectors */ 316 char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ 317 char ox[2]; /* space for 0x hex-prefix */ 318 --- 384 unchanged lines hidden (view full) --- 703 * first be prefixed by any sign or other prefix; otherwise, 704 * it should be blank padded before the prefix is emitted. 705 * After any left-hand padding and prefixing, emit zeroes 706 * required by a decimal [diouxX] precision, then print the 707 * string proper, then emit zeroes required by any leftover 708 * floating precision; finally, if LADJUST, pad with blanks. 709 * 710 * Compute actual size, so we know how much to pad. | 310 int size; /* size of converted field or string */ 311 char *xdigs; /* digits for [xX] conversion */ 312#define NIOV 8 313 struct __suio uio; /* output information: summary */ 314 struct __siov iov[NIOV];/* ... and individual io vectors */ 315 char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ 316 char ox[2]; /* space for 0x hex-prefix */ 317 --- 384 unchanged lines hidden (view full) --- 702 * first be prefixed by any sign or other prefix; otherwise, 703 * it should be blank padded before the prefix is emitted. 704 * After any left-hand padding and prefixing, emit zeroes 705 * required by a decimal [diouxX] precision, then print the 706 * string proper, then emit zeroes required by any leftover 707 * floating precision; finally, if LADJUST, pad with blanks. 708 * 709 * Compute actual size, so we know how much to pad. |
711 * fieldsz excludes decimal prec; realsz includes it. | 710 * size excludes decimal prec; realsz includes it. |
712 */ | 711 */ |
713 fieldsz = size; | 712 realsz = dprec > size ? dprec : size; |
714 if (sign) | 713 if (sign) |
715 fieldsz++; | 714 realsz++; |
716 else if (flags & HEXPREFIX) | 715 else if (flags & HEXPREFIX) |
717 fieldsz += 2; 718 realsz = dprec > fieldsz ? dprec : fieldsz; | 716 realsz += 2; |
719 720 /* right-adjusting blank padding */ 721 if ((flags & (LADJUST|ZEROPAD)) == 0) 722 PAD(width - realsz, blanks); 723 724 /* prefix */ 725 if (sign) { 726 PRINT(&sign, 1); 727 } else if (flags & HEXPREFIX) { 728 ox[0] = '0'; 729 ox[1] = ch; 730 PRINT(ox, 2); 731 } 732 733 /* right-adjusting zero padding */ 734 if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) 735 PAD(width - realsz, zeroes); 736 737 /* leading zeroes from decimal precision */ | 717 718 /* right-adjusting blank padding */ 719 if ((flags & (LADJUST|ZEROPAD)) == 0) 720 PAD(width - realsz, blanks); 721 722 /* prefix */ 723 if (sign) { 724 PRINT(&sign, 1); 725 } else if (flags & HEXPREFIX) { 726 ox[0] = '0'; 727 ox[1] = ch; 728 PRINT(ox, 2); 729 } 730 731 /* right-adjusting zero padding */ 732 if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) 733 PAD(width - realsz, zeroes); 734 735 /* leading zeroes from decimal precision */ |
738 PAD(dprec - fieldsz, zeroes); | 736 PAD(dprec - size, zeroes); |
739 740 /* the string or number proper */ 741#ifdef FLOATING_POINT 742 if ((flags & FPT) == 0) { 743 PRINT(cp, size); 744 } else { /* glue together f_p fragments */ 745 if (ch >= 'f') { /* 'f' or 'g' */ 746 if (_double == 0) { --- 141 unchanged lines hidden --- | 737 738 /* the string or number proper */ 739#ifdef FLOATING_POINT 740 if ((flags & FPT) == 0) { 741 PRINT(cp, size); 742 } else { /* glue together f_p fragments */ 743 if (ch >= 'f') { /* 'f' or 'g' */ 744 if (_double == 0) { --- 141 unchanged lines hidden --- |