Lines Matching +full:10 +full:g +full:- +full:support
4 * Changed in a backwards-incompatible way to separate HAVE_SNPRINTF
10 * C99-compliant implementations.
38 * 2008-01-20 Holger Weiss <holger@jhweiss.de> for C99-snprintf 1.1:
43 * 2008-01-06 Holger Weiss <holger@jhweiss.de> for C99-snprintf 1.0:
49 * projects. The additions include: support the "e", "E", "g", "G", and
51 * still unsupported "a" and "A" specifiers); support the "hh", "ll", "j",
52 * "t", and "z" length modifiers; support the "#" flag and the (non-C99)
69 * 2007-07-23 Holger Weiss <holger@jhweiss.de> for Mutt 1.5.13:
76 * 1998-03-05 Michael Elkins <me@mutt.org> for Mutt 0.90.8:
82 * 1998-01-27 Thomas Roessler <roessler@does-not-exist.org> for Mutt 0.89i:
87 * 1997-10-22 Brandon Long <blong@fiction.net> for Mutt 0.87.1:
89 * Ok, added some minimal floating point support, which means this probably
90 * requires libm on most operating systems. Don't yet support the exponent
91 * (e,E) and sigfig (g,G). Also, fmtint() was pretty badly broken, it just
94 * over from the original. Also, there is now a builtin-test, run with:
95 * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm && ./snprintf
97 * 2996-09-15 Brandon Long <blong@fiction.net> for Mutt 0.43:
108 * - Add wide character support.
109 * - Add support for "%a" and "%A" conversions.
110 * - Create test routines which predefine the expected results. Our test cases
111 * usually expose bugs in system implementations rather than in ours :-)
313 #define VA_SHIFT(ap, value, type) /* No-op for ANSI C. */
338 #define VA_END_COPY(ap) /* No-op. */
360 /* Support for unsigned long long int. We may also need ULLONG_MAX. */
384 /* Support for uintmax_t. We also need UINTMAX_MAX. */
401 /* Support for long double. */
410 /* Support for long long int. */
419 /* Support for intmax_t. */
428 /* Support for uintptr_t. */
437 /* Support for ptrdiff_t. */
474 * nul-termination ("3777777777777777777777777777777777777777777").
516 #define CHARTOINT(ch) (ch - '0')
573 int precision = -1;
582 * (Though some of these versions will write to a non-NULL buffer even
599 case '-':
631 if (width > (INT_MAX - ch) / 10) {
635 width = 10 * width + ch;
640 * taken as a `-' flag followed by a positive
645 width = -width;
660 if (precision == -1)
664 if (precision > (INT_MAX - ch) / 10) {
668 precision = 10 * precision + ch;
677 precision = -1;
751 fmtint(str, &len, size, value, 10, width,
766 base = 10;
832 case 'G':
835 case 'g':
865 * characters, in an implementation-defined
874 -1, flags);
940 precision = -1;
947 str[size - 1] = '\0';
951 return -1;
961 int noprecision = (precision == -1);
971 if ((padlen = width - strln) < 0)
974 padlen = -padlen;
978 padlen--;
980 while (*value != '\0' && (noprecision || precision-- > 0)) {
1002 int noprecision = (precision == -1);
1007 uvalue = (value >= 0) ? value : -value;
1009 sign = '-';
1042 zpadlen = precision - pos - separators;
1044 - separators /* Number of separators. */
1045 - MAX(precision, pos) /* Number of integer digits. */
1046 - ((sign != 0) ? 1 : 0) /* Will we print a sign? */
1047 - ((hexprefix != 0) ? 2 : 0); /* Will we print a prefix? */
1055 * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
1060 spadlen = -spadlen;
1067 spadlen--;
1077 zpadlen--;
1080 pos--;
1102 char econvert[4]; /* "e-12" (without nul-termination). */
1125 if (precision == -1)
1129 sign = '-';
1149 /* "%e" (or "%E") or "%g" (or "%G") conversion. */
1153 * For "%g" (and "%G") conversions, the precision
1156 * conversion will or will not be using "e-style" (like
1161 * assume that we're going to do an "e-style" conversion
1163 * "e-style", the precision must be decremented by one.
1165 precision--;
1167 * For "%g" (and "%G") conversions, trailing zeros are
1180 * Sorry, we only support 9, 19, or 38 digits (that is, the number of
1181 * digits of the 32-bit, the 64-bit, or the 128-bit UINTMAX_MAX value
1199 ufvalue = (fvalue >= 0.0) ? fvalue : -fvalue;
1217 if ((fracpart = myround(mask * (ufvalue - intpart))) >= mask) {
1226 if (estyle && intpart == 10) {
1229 * integer digit if using "e-style". So, the integer
1240 * use "e-style" for "%g" (and "%G") conversions. If we don't need
1241 * "e-style", the precision must be adjusted and the integer and
1248 * - if P > X >= -4, the conversion is with style `f' (or `F') and
1249 * precision P - (X + 1).
1251 * - otherwise, the conversion is with style `e' (or `E') and precision
1252 * P - 1." (7.19.6.1, 8)
1257 precision + 1 > exponent && exponent >= -4) {
1258 precision -= exponent;
1265 exponent = -exponent;
1266 esign = '-';
1272 * econvert buffer can hold e.g. "e+99" and "e-99". We don't
1273 * support an exponent which contains more than two digits.
1276 epos = convert(exponent, econvert, 2, 10, 0);
1289 ipos = convert(intpart, iconvert, sizeof(iconvert), 10, 0);
1291 fpos = convert(fracpart, fconvert, sizeof(fconvert), 10, 0);
1293 leadfraczeros = precision - fpos;
1303 precision -= omitcount;
1307 * Print a decimal point if either the fractional part is non-zero
1316 - ipos /* Number of integer digits. */
1317 - epos /* Number of exponent characters. */
1318 - precision /* Number of fractional digits. */
1319 - separators /* Number of group separators. */
1320 - (emitpoint ? 1 : 0) /* Will we print a decimal point? */
1321 - ((sign != 0) ? 1 : 0); /* Will we print a sign character? */
1327 * C99 says: "If the `0' and `-' flags both appear, the `0' flag is
1331 padlen = -padlen;
1339 padlen--;
1344 padlen--;
1349 ipos--;
1356 if (lc->decimal_point != NULL && *lc->decimal_point != '\0')
1357 OUTCHAR(str, *len, size, *lc->decimal_point);
1364 leadfraczeros--;
1367 fpos--;
1371 epos--;
1387 if (lc->thousands_sep != NULL)
1388 for (i = 0; lc->thousands_sep[i] != '\0'; i++)
1389 OUTCHAR(str, *len, size, lc->thousands_sep[i]);
1398 int separators = (digits - ((digits % 3 == 0) ? 1 : 0)) / 3;
1403 /* We support an arbitrary separator length (including zero). */
1404 if (lc->thousands_sep != NULL) {
1405 for (strln = 0; lc->thousands_sep[strln] != '\0'; strln++)
1416 LDOUBLE tmp = (value >= 0.0) ? value : -value;
1420 * We check for 99 > exponent > -99 in order to work around possible
1426 while (tmp < 1.0 && tmp > 0.0 && --exponent > -99)
1427 tmp *= 10;
1429 tmp /= 10;
1467 * an integer type converts e.g. 1.9 to 2 instead of 1 (which violates
1470 return (result <= value) ? result : result - 1;
1478 return ((value -= intpart) < 0.5) ? intpart : intpart + 1;
1487 result *= 10;
1488 exponent--;
1491 result /= 10;
1507 while (len-- > 0)
1527 return -1;
1603 "%-22.16e",
1607 "%-123.9e",
1611 "%-05.8e",
1614 "%-5.8e",
1629 "%-1.5e",
1650 "%-'22f",
1656 "%-22.16f",
1661 "%-123.9f",
1669 "%-05.8f",
1672 "%-5.8f",
1682 "%-1.5f",
1698 /* "%G" and "%g" formats. */
1700 "% '022g",
1701 "%+'022g",
1702 "%-'22g",
1703 "%'22g",
1705 "%.16g",
1706 "%22.16g",
1707 "%022.16g",
1708 "%-22.16g",
1709 "%#+'022.16g",
1712 "foo|%#+0123.9G|bar",
1713 "%-123.9g",
1714 "%123.9g",
1715 "%+23.9g",
1716 "%+05.8g",
1717 "%-05.8g",
1718 "%05.8g",
1719 "%+5.8g",
1720 "%-5.8g",
1721 "% 5.8g",
1722 "%5.8g",
1723 "%+4.9g",
1725 "%+#010.0g",
1726 "%#10.1g",
1727 "%10.5g",
1728 "% 10.5g",
1729 "%5.0g",
1730 "%5.g",
1731 "%#5.0g",
1732 "%#5.g",
1733 "%3.2g",
1734 "%3.1g",
1735 "%-1.5g",
1736 "%1.5g",
1737 "%01.3g",
1738 "%1.g",
1739 "%.1g",
1740 "%#.0g",
1741 "%+.0g",
1742 "% .0g",
1743 "%.0g",
1744 "%#.g",
1745 "%+.g",
1746 "% .g",
1747 "%.g",
1748 "%4g",
1749 "%g",
1750 "%G",
1755 -4.136,
1756 -134.52,
1757 -5.04030201,
1758 -3410.01234,
1759 -999999.999999,
1760 -913450.29876,
1761 -913450.2,
1762 -91345.2,
1763 -9134.2,
1764 -913.2,
1765 -91.2,
1766 -9.2,
1767 -9.9,
1807 -1.5,
1808 -1.0,
1809 -0.1,
1813 -INFINITY,
1826 "%-'123ld",
1832 "%-123.9ld",
1836 "%-0123ld",
1840 "%-10.5ld",
1844 "%-010ld",
1848 "%-4.2ld",
1852 "%-04ld",
1857 "%-1.5ld",
1876 -91340,
1881 -1,
1891 "%-'123lu",
1897 "%-123.9lu",
1901 "%-0123lu",
1906 "%-1.5lu",
1914 "%#-123.9lo",
1918 "%#-0123lo",
1923 "%#-1.5lo",
1929 "%-123.9lo",
1933 "%-0123lo",
1938 "%-1.5lo",
1946 "%#-123.9lx",
1950 "%#-0123lx",
1955 "%#-1.5lx",
1962 "%-123.9lx",
1966 "%-0123lx",
1971 "%-1.5lx",
1993 "%-123.9lld",
1997 "%-0123lld",
2002 "%-1.5lld",
2014 -91340,
2019 -1,
2025 "%-10.10s",
2033 "%-42.5s",
2035 "%.10s",
2071 * Use -DTEST_NILS in order to also test the conversion of nil values. Might
2072 * segfault on systems which don't support converting a NULL pointer with "%s"
2088 for (j = 0; j == 0 || val[j - TEST_NILS] != 0; j++) { \
2118 (void)fputs("Checking how many digits we support: ", stdout);
2120 value = pow(10, i) * digits;