50 # define _GNU_SOURCE 1
62 # if WIDE_CHAR_VERSION
63 # include "vasnwprintf.h"
77 # include <langinfo.h>
80 # if WIDE_CHAR_VERSION
81 # include "wprintf-parse.h"
92 #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
97 #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
99 # include "isnand-nolibm.h"
102 #if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL
104 # include "isnanl-nolibm.h"
108 #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
110 # include "isnand-nolibm.h"
111 # include "printf-frexp.h"
114 #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
116 # include "isnanl-nolibm.h"
117 # include "printf-frexpl.h"
123 # if WIDE_CHAR_VERSION
124 # define VASNPRINTF vasnwprintf
125 # define FCHAR_T wchar_t
126 # define DCHAR_T wchar_t
127 # define TCHAR_T wchar_t
128 # define DCHAR_IS_TCHAR 1
129 # define DIRECTIVE wchar_t_directive
130 # define DIRECTIVES wchar_t_directives
131 # define PRINTF_PARSE wprintf_parse
132 # define DCHAR_CPY wmemcpy
133 # define DCHAR_SET wmemset
135 # define VASNPRINTF vasnprintf
136 # define FCHAR_T char
137 # define DCHAR_T char
138 # define TCHAR_T char
139 # define DCHAR_IS_TCHAR 1
140 # define DIRECTIVE char_directive
141 # define DIRECTIVES char_directives
142 # define PRINTF_PARSE printf_parse
143 # define DCHAR_CPY memcpy
144 # define DCHAR_SET memset
147 #if WIDE_CHAR_VERSION
149 # define USE_SNPRINTF 1
150 # if HAVE_DECL__SNWPRINTF
155 # if defined __MINGW32__
156 # define SNPRINTF snwprintf
158 # define SNPRINTF _snwprintf
162 # define SNPRINTF swprintf
171 # if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1)
172 # define USE_SNPRINTF 1
174 # define USE_SNPRINTF 0
176 # if HAVE_DECL__SNPRINTF
179 # if defined __MINGW32__
180 # define SNPRINTF snprintf
184 # define SNPRINTF _snprintf
188 # define SNPRINTF snprintf
199 # define IF_LINT(Code) Code
201 # define IF_LINT(Code)
209 #define remainder rem
211 #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION
212 # if (HAVE_STRNLEN && !defined _AIX)
213 # define local_strnlen strnlen
215 # ifndef local_strnlen_defined
216 # define local_strnlen_defined 1
220 const char *
end = memchr (
string,
'\0', maxlen);
227 #if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
229 # define local_wcslen wcslen
235 # ifndef local_wcslen_defined
236 # define local_wcslen_defined 1
238 local_wcslen (
const wchar_t *s)
242 for (ptr = s; *ptr != (
wchar_t) 0; ptr++)
250 #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
252 # define local_wcsnlen wcsnlen
254 # ifndef local_wcsnlen_defined
255 # define local_wcsnlen_defined 1
257 local_wcsnlen (
const wchar_t *s,
size_t maxlen)
261 for (ptr = s; maxlen > 0 && *ptr != (
wchar_t) 0; ptr++, maxlen--)
269 #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
271 # ifndef decimal_point_char_defined
272 # define decimal_point_char_defined 1
274 decimal_point_char (
void)
281 # if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__))
282 point = nl_langinfo (RADIXCHAR);
285 sprintf (pointbuf,
"%#.0f", 1.0);
286 point = &pointbuf[1];
288 point = localeconv () -> decimal_point;
291 return (point[0] !=
'\0' ? point[0] :
'.');
296 #if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL
300 is_infinite_or_zero (
double x)
302 return isnand (
x) ||
x +
x ==
x;
307 #if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL
311 is_infinite_or_zerol (
long double x)
313 return isnanl (
x) ||
x +
x ==
x;
318 #if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
324 typedef unsigned int mp_limb_t;
325 # define GMP_LIMB_BITS 32
326 verify (
sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
328 typedef unsigned long long mp_twolimb_t;
329 # define GMP_TWOLIMB_BITS 64
330 verify (
sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
343 multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
350 if (src1.nlimbs <= src2.nlimbs)
369 dest->limbs = (mp_limb_t *)
malloc (1);
379 dp = (mp_limb_t *)
malloc (dlen *
sizeof (mp_limb_t));
382 for (k = len2; k > 0; )
384 for (i = 0; i < len1; i++)
386 mp_limb_t digit1 = p1[i];
387 mp_twolimb_t carry = 0;
388 for (j = 0; j < len2; j++)
390 mp_limb_t digit2 = p2[j];
391 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
393 dp[i + j] = (mp_limb_t) carry;
394 carry = carry >> GMP_LIMB_BITS;
396 dp[i + len2] = (mp_limb_t) carry;
399 while (dlen > 0 && dp[dlen - 1] == 0)
415 divide (mpn_t a, mpn_t b, mpn_t *q)
468 const mp_limb_t *a_ptr = a.limbs;
469 size_t a_len = a.nlimbs;
470 const mp_limb_t *b_ptr = b.limbs;
471 size_t b_len = b.nlimbs;
473 mp_limb_t *tmp_roomptr = NULL;
482 roomptr = (mp_limb_t *)
malloc ((a_len + 2) *
sizeof (mp_limb_t));
487 while (a_len > 0 && a_ptr[a_len - 1] == 0)
496 if (b_ptr[b_len - 1] == 0)
509 memcpy (r_ptr, a_ptr, a_len *
sizeof (mp_limb_t));
510 q_ptr = roomptr + a_len;
520 mp_limb_t den = b_ptr[0];
522 const mp_limb_t *sourceptr = a_ptr + a_len;
523 mp_limb_t *destptr = q_ptr + a_len;
528 ((mp_twolimb_t)
remainder << GMP_LIMB_BITS) | *--sourceptr;
529 *--destptr =
num / den;
542 if (q_ptr[q_len - 1] == 0)
554 mp_limb_t msd = b_ptr[b_len - 1];
557 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
558 s = __builtin_clz (msd);
560 # if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
561 if (GMP_LIMB_BITS <= DBL_MANT_BIT)
565 # define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
566 # define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1)
568 ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
569 union {
double value;
unsigned int word[NWORDS]; } m;
575 - (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) &
DBL_EXP_MASK)
615 tmp_roomptr = (mp_limb_t *)
malloc (b_len *
sizeof (mp_limb_t));
616 if (tmp_roomptr == NULL)
622 const mp_limb_t *sourceptr = b_ptr;
623 mp_limb_t *destptr = tmp_roomptr;
624 mp_twolimb_t accu = 0;
628 accu += (mp_twolimb_t) *sourceptr++ << s;
629 *destptr++ = (mp_limb_t) accu;
630 accu = accu >> GMP_LIMB_BITS;
645 memcpy (r_ptr, a_ptr, a_len *
sizeof (mp_limb_t));
650 const mp_limb_t *sourceptr = a_ptr;
651 mp_limb_t *destptr = r_ptr;
652 mp_twolimb_t accu = 0;
656 accu += (mp_twolimb_t) *sourceptr++ << s;
657 *destptr++ = (mp_limb_t) accu;
658 accu = accu >> GMP_LIMB_BITS;
660 *destptr++ = (mp_limb_t) accu;
662 q_ptr = roomptr + b_len;
663 q_len = a_len - b_len + 1;
665 size_t j = a_len - b_len;
666 mp_limb_t b_msd = b_ptr[b_len - 1];
667 mp_limb_t b_2msd = b_ptr[b_len - 2];
668 mp_twolimb_t b_msdd =
669 ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
676 if (r_ptr[j + b_len] < b_msd)
680 ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
681 | r_ptr[j + b_len - 1];
682 q_star =
num / b_msd;
688 q_star = (mp_limb_t)~(mp_limb_t)0;
696 if (r_ptr[j + b_len] > b_msd
697 || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
707 ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
709 (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
717 if (c3 - c2 > b_msdd)
727 const mp_limb_t *sourceptr = b_ptr;
728 mp_limb_t *destptr = r_ptr + j;
729 mp_twolimb_t carry = 0;
736 + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
737 + (mp_limb_t) ~(*destptr);
739 *destptr++ = ~(mp_limb_t) carry;
740 carry = carry >> GMP_LIMB_BITS;
742 cr = (mp_limb_t) carry;
746 if (cr > r_ptr[j + b_len])
752 const mp_limb_t *sourceptr = b_ptr;
753 mp_limb_t *destptr = r_ptr + j;
758 mp_limb_t source1 = *sourceptr++;
759 mp_limb_t source2 = *destptr;
760 *destptr++ = source1 + source2 + carry;
763 ? source1 >= (mp_limb_t) ~source2
764 : source1 > (mp_limb_t) ~source2);
779 if (q_ptr[q_len - 1] == 0)
786 mp_limb_t ptr = r_ptr + r_len;
787 mp_twolimb_t accu = 0;
791 accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
792 accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
793 *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
798 while (r_len > 0 && r_ptr[r_len - 1] == 0)
809 (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
810 | (i < r_len ? r_ptr[i] << 1 : 0);
811 mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
821 if (q_len > 0 && ((q_ptr[0] & 1) != 0))
826 for (i = 0; i < q_len; i++)
827 if (++(q_ptr[i]) != 0)
832 if (tmp_roomptr != NULL)
846 convert_to_decimal (mpn_t a,
size_t extra_zeroes)
848 mp_limb_t *a_ptr = a.limbs;
849 size_t a_len = a.nlimbs;
851 size_t c_len = 9 * ((
size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);
852 char *c_ptr = (
char *)
malloc (
xsum (c_len, extra_zeroes));
856 for (; extra_zeroes > 0; extra_zeroes--)
862 mp_limb_t *ptr = a_ptr + a_len;
867 ((mp_twolimb_t)
remainder << GMP_LIMB_BITS) | *--ptr;
868 *ptr =
num / 1000000000;
878 if (a_ptr[a_len - 1] == 0)
882 while (d_ptr > c_ptr && d_ptr[-1] ==
'0')
893 # if NEED_PRINTF_LONG_DOUBLE
900 decode_long_double (
long double x,
int *ep, mpn_t *mp)
908 m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
909 m.limbs = (mp_limb_t *)
malloc (m.nlimbs * sizeof (mp_limb_t));
913 y = frexpl (
x, &
exp);
914 if (!(y >= 0.0L && y < 1.0L))
923 # if (LDBL_MANT_BIT % GMP_LIMB_BITS) != 0
924 # if (LDBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2
927 y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % (GMP_LIMB_BITS / 2));
930 if (!(y >= 0.0L && y < 1.0L))
932 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
935 if (!(y >= 0.0L && y < 1.0L))
937 m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
942 y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % GMP_LIMB_BITS);
945 if (!(y >= 0.0L && y < 1.0L))
947 m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d;
951 for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
954 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
957 if (!(y >= 0.0L && y < 1.0L))
959 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
962 if (!(y >= 0.0L && y < 1.0L))
964 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
972 while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
975 *ep =
exp - LDBL_MANT_BIT;
981 # if NEED_PRINTF_DOUBLE
988 decode_double (
double x,
int *ep, mpn_t *mp)
996 m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
997 m.limbs = (mp_limb_t *)
malloc (m.nlimbs * sizeof (mp_limb_t));
1001 y = frexp (
x, &
exp);
1002 if (!(y >= 0.0 && y < 1.0))
1011 # if (DBL_MANT_BIT % GMP_LIMB_BITS) != 0
1012 # if (DBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2
1015 y *= (mp_limb_t) 1 << (DBL_MANT_BIT % (GMP_LIMB_BITS / 2));
1018 if (!(y >= 0.0 && y < 1.0))
1020 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
1023 if (!(y >= 0.0 && y < 1.0))
1025 m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
1030 y *= (mp_limb_t) 1 << (DBL_MANT_BIT % GMP_LIMB_BITS);
1033 if (!(y >= 0.0 && y < 1.0))
1035 m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d;
1039 for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
1042 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
1045 if (!(y >= 0.0 && y < 1.0))
1047 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
1050 if (!(y >= 0.0 && y < 1.0))
1052 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
1057 while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
1060 *ep =
exp - DBL_MANT_BIT;
1072 scale10_round_decimal_decoded (
int e, mpn_t m,
void *memory,
int n)
1075 size_t extra_zeroes;
1078 mp_limb_t *pow5_ptr;
1080 unsigned int s_limbs;
1081 unsigned int s_bits;
1097 extra_zeroes = (s < n ? s : n);
1106 abs_n = (n >= 0 ? n : -n);
1107 abs_s = (s >= 0 ? s : -s);
1108 pow5_ptr = (mp_limb_t *)
malloc (((
int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1
1109 + abs_s / GMP_LIMB_BITS + 1)
1110 *
sizeof (mp_limb_t));
1111 if (pow5_ptr == NULL)
1122 static mp_limb_t
const small_pow5[13 + 1] =
1124 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
1125 48828125, 244140625, 1220703125
1128 for (n13 = 0; n13 <= abs_n; n13 += 13)
1130 mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
1132 mp_twolimb_t carry = 0;
1133 for (j = 0; j < pow5_len; j++)
1135 mp_limb_t digit2 = pow5_ptr[j];
1136 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
1137 pow5_ptr[j] = (mp_limb_t) carry;
1138 carry = carry >> GMP_LIMB_BITS;
1141 pow5_ptr[pow5_len++] = (mp_limb_t) carry;
1144 s_limbs = abs_s / GMP_LIMB_BITS;
1145 s_bits = abs_s % GMP_LIMB_BITS;
1146 if (n >= 0 ? s >= 0 : s <= 0)
1151 mp_limb_t *ptr = pow5_ptr;
1152 mp_twolimb_t accu = 0;
1156 accu += (mp_twolimb_t) *ptr << s_bits;
1157 *ptr++ = (mp_limb_t) accu;
1158 accu = accu >> GMP_LIMB_BITS;
1162 *ptr = (mp_limb_t) accu;
1177 pow5_ptr[
count] = 0;
1179 pow5_len += s_limbs;
1181 pow5.limbs = pow5_ptr;
1182 pow5.nlimbs = pow5_len;
1191 z_memory =
divide (m, pow5, &z);
1196 pow5.limbs = pow5_ptr;
1197 pow5.nlimbs = pow5_len;
1205 tmp_memory =
multiply (m, pow5, &numerator);
1206 if (tmp_memory == NULL)
1214 mp_limb_t *ptr = pow5_ptr + pow5_len;
1216 for (i = 0; i < s_limbs; i++)
1218 ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
1219 denominator.limbs = ptr;
1220 denominator.nlimbs = s_limbs + 1;
1222 z_memory =
divide (numerator, denominator, &z);
1231 num_ptr = (mp_limb_t *)
malloc ((m.nlimbs + s_limbs + 1)
1232 *
sizeof (mp_limb_t));
1233 if (num_ptr == NULL)
1240 mp_limb_t *destptr = num_ptr;
1243 for (i = 0; i < s_limbs; i++)
1248 const mp_limb_t *sourceptr = m.limbs;
1249 mp_twolimb_t accu = 0;
1253 accu += (mp_twolimb_t) *sourceptr++ << s_bits;
1254 *destptr++ = (mp_limb_t) accu;
1255 accu = accu >> GMP_LIMB_BITS;
1258 *destptr++ = (mp_limb_t) accu;
1262 const mp_limb_t *sourceptr = m.limbs;
1265 *destptr++ = *sourceptr++;
1267 numerator.limbs = num_ptr;
1268 numerator.nlimbs = destptr - num_ptr;
1270 z_memory =
divide (numerator, pow5, &z);
1279 if (z_memory == NULL)
1281 digits = convert_to_decimal (z, extra_zeroes);
1286 # if NEED_PRINTF_LONG_DOUBLE
1294 scale10_round_decimal_long_double (
long double x,
int n)
1298 void *memory = decode_long_double (
x, &e, &m);
1299 return scale10_round_decimal_decoded (e, m, memory, n);
1304 # if NEED_PRINTF_DOUBLE
1312 scale10_round_decimal_double (
double x,
int n)
1316 void *memory = decode_double (
x, &e, &m);
1317 return scale10_round_decimal_decoded (e, m, memory, n);
1322 # if NEED_PRINTF_LONG_DOUBLE
1328 floorlog10l (
long double x)
1336 y = frexpl (
x, &
exp);
1337 if (!(y >= 0.0L && y < 1.0L))
1343 while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
1345 y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
1346 exp -= GMP_LIMB_BITS;
1348 if (y < (1.0L / (1 << 16)))
1350 y *= 1.0L * (1 << 16);
1353 if (y < (1.0L / (1 << 8)))
1355 y *= 1.0L * (1 << 8);
1358 if (y < (1.0L / (1 << 4)))
1360 y *= 1.0L * (1 << 4);
1363 if (y < (1.0L / (1 << 2)))
1365 y *= 1.0L * (1 << 2);
1368 if (y < (1.0L / (1 << 1)))
1370 y *= 1.0L * (1 << 1);
1374 if (!(y >= 0.5L && y < 1.0L))
1379 if (z < 0.70710678118654752444)
1381 z *= 1.4142135623730950488;
1384 if (z < 0.8408964152537145431)
1386 z *= 1.1892071150027210667;
1389 if (z < 0.91700404320467123175)
1391 z *= 1.0905077326652576592;
1394 if (z < 0.9576032806985736469)
1396 z *= 1.0442737824274138403;
1403 l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
1406 l *= 0.30102999566398119523;
1408 return (
int) l + (l < 0 ? -1 : 0);
1413 # if NEED_PRINTF_DOUBLE
1419 floorlog10 (
double x)
1427 y = frexp (
x, &
exp);
1428 if (!(y >= 0.0 && y < 1.0))
1434 while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
1436 y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
1437 exp -= GMP_LIMB_BITS;
1439 if (y < (1.0 / (1 << 16)))
1441 y *= 1.0 * (1 << 16);
1444 if (y < (1.0 / (1 << 8)))
1446 y *= 1.0 * (1 << 8);
1449 if (y < (1.0 / (1 << 4)))
1451 y *= 1.0 * (1 << 4);
1454 if (y < (1.0 / (1 << 2)))
1456 y *= 1.0 * (1 << 2);
1459 if (y < (1.0 / (1 << 1)))
1461 y *= 1.0 * (1 << 1);
1465 if (!(y >= 0.5 && y < 1.0))
1470 if (z < 0.70710678118654752444)
1472 z *= 1.4142135623730950488;
1475 if (z < 0.8408964152537145431)
1477 z *= 1.1892071150027210667;
1480 if (z < 0.91700404320467123175)
1482 z *= 1.0905077326652576592;
1485 if (z < 0.9576032806985736469)
1487 z *= 1.0442737824274138403;
1494 l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
1497 l *= 0.30102999566398119523;
1499 return (
int) l + (l < 0 ? -1 : 0);
1507 is_borderline (
const char *digits,
size_t precision)
1515 return *digits ==
'\0';
1520 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99
1525 # if WIDE_CHAR_VERSION
1526 # define MAX_ROOM_NEEDED wmax_room_needed
1528 # define MAX_ROOM_NEEDED max_room_needed
1535 arg_type type,
int flags,
size_t width,
int has_precision,
1542 case 'd':
case 'i':
case 'u':
1543 # if HAVE_LONG_LONG_INT
1544 if (
type == TYPE_LONGLONGINT ||
type == TYPE_ULONGLONGINT)
1546 (
unsigned int) (
sizeof (
unsigned long long) * CHAR_BIT
1554 (
unsigned int) (
sizeof (
unsigned long) * CHAR_BIT
1560 (
unsigned int) (
sizeof (
unsigned int) * CHAR_BIT
1567 tmp_length =
xsum (tmp_length, tmp_length);
1569 tmp_length =
xsum (tmp_length, 1);
1573 # if HAVE_LONG_LONG_INT
1574 if (
type == TYPE_LONGLONGINT ||
type == TYPE_ULONGLONGINT)
1576 (
unsigned int) (
sizeof (
unsigned long long) * CHAR_BIT
1584 (
unsigned int) (
sizeof (
unsigned long) * CHAR_BIT
1590 (
unsigned int) (
sizeof (
unsigned int) * CHAR_BIT
1597 tmp_length =
xsum (tmp_length, 1);
1601 # if HAVE_LONG_LONG_INT
1602 if (
type == TYPE_LONGLONGINT ||
type == TYPE_ULONGLONGINT)
1604 (
unsigned int) (
sizeof (
unsigned long long) * CHAR_BIT
1612 (
unsigned int) (
sizeof (
unsigned long) * CHAR_BIT
1618 (
unsigned int) (
sizeof (
unsigned int) * CHAR_BIT
1625 tmp_length =
xsum (tmp_length, 2);
1631 (
unsigned int) (LDBL_MAX_EXP
1639 (
unsigned int) (DBL_MAX_EXP
1648 case 'e':
case 'E':
case 'g':
case 'G':
1657 (
unsigned int) (LDBL_DIG
1663 (
unsigned int) (DBL_DIG
1670 tmp_length =
xsum (tmp_length, 12);
1674 # if HAVE_WINT_T && !WIDE_CHAR_VERSION
1675 if (
type == TYPE_WIDE_CHAR)
1676 tmp_length = MB_CUR_MAX;
1684 if (
type == TYPE_WIDE_STRING)
1686 # if WIDE_CHAR_VERSION
1691 const wchar_t *arg = ap->
arg[arg_index].
a.a_wide_string;
1694 tmp_length = local_wcsnlen (arg,
precision);
1696 tmp_length = local_wcslen (arg);
1713 # if WIDE_CHAR_VERSION
1731 tmp_length = strlen (arg);
1738 (
unsigned int) (
sizeof (
void *) * CHAR_BIT
1751 # if ENABLE_UNISTDIO
1757 tmp_length =
xsum (tmp_length, width);
1760 if (tmp_length < width)
1765 tmp_length =
xsum (tmp_length, 1);
1774 const FCHAR_T *format, va_list args)
1784 if (d.dir != d.direct_alloc_dir) \
1786 if (a.arg != a.direct_alloc_arg) \
1797 size_t buf_neededlength;
1811 xsum4 (7, d.max_width_length, d.max_precision_length, 6);
1813 if (buf_neededlength < 4000 /
sizeof (
TCHAR_T))
1816 buf_malloced = NULL;
1821 size_t buf_memsize =
xtimes (buf_neededlength,
sizeof (
TCHAR_T));
1823 goto out_of_memory_1;
1826 goto out_of_memory_1;
1830 if (resultbuf != NULL)
1833 allocated = *lengthp;
1847 #define ENSURE_ALLOCATION(needed) \
1848 if ((needed) > allocated) \
1850 size_t memory_size; \
1853 allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
1854 if ((needed) > allocated) \
1855 allocated = (needed); \
1856 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
1857 if (size_overflow_p (memory_size)) \
1858 goto out_of_memory; \
1859 if (result == resultbuf || result == NULL) \
1860 memory = (DCHAR_T *) malloc (memory_size); \
1862 memory = (DCHAR_T *) realloc (result, memory_size); \
1863 if (memory == NULL) \
1864 goto out_of_memory; \
1865 if (result == resultbuf && length > 0) \
1866 DCHAR_CPY (memory, result, length); \
1870 for (
cp = format, i = 0, dp = &d.dir[0]; ;
cp = dp->dir_end, i++, dp++)
1872 if (
cp != dp->dir_start)
1874 size_t n = dp->dir_start -
cp;
1875 size_t augmented_length =
xsum (length, n);
1884 length = augmented_length;
1889 result[length++] = (
unsigned char) *
cp++;
1897 if (dp->conversion ==
'%')
1899 size_t augmented_length;
1903 augmented_length =
xsum (length, 1);
1905 result[length] =
'%';
1906 length = augmented_length;
1913 if (dp->conversion ==
'n')
1915 switch (a.
arg[dp->arg_index].
type)
1929 #if HAVE_LONG_LONG_INT
1930 case TYPE_COUNT_LONGLONGINT_POINTER:
1931 *a.
arg[dp->arg_index].
a.a_count_longlongint_pointer = length;
1940 else if (dp->conversion ==
'U')
1943 int flags = dp->flags;
1951 if (dp->width_start != dp->width_end)
1953 if (dp->width_arg_index !=
ARG_NONE)
1959 arg = a.
arg[dp->width_arg_index].
a.
a_int;
1965 width = (
unsigned int) (-arg);
1972 const FCHAR_T *digitp = dp->width_start;
1975 width =
xsum (
xtimes (width, 10), *digitp++ -
'0');
1976 while (digitp != dp->width_end);
1983 if (dp->precision_start != dp->precision_end)
1985 if (dp->precision_arg_index !=
ARG_NONE)
1991 arg = a.
arg[dp->precision_arg_index].
a.
a_int;
2002 const FCHAR_T *digitp = dp->precision_start + 1;
2005 while (digitp != dp->precision_end)
2013 case TYPE_U8_STRING:
2015 const uint8_t *arg = a.
arg[dp->arg_index].
a.a_u8_string;
2026 int count = u8_strmblen (arg_end);
2031 if (!(result == resultbuf || result == NULL))
2033 if (buf_malloced != NULL)
2034 free (buf_malloced);
2051 int count = u8_strmblen (arg_end);
2056 if (!(result == resultbuf || result == NULL))
2058 if (buf_malloced != NULL)
2059 free (buf_malloced);
2071 arg_end = arg + u8_strlen (arg);
2076 if (has_width && width > characters
2079 size_t n = width - characters;
2085 # if DCHAR_IS_UINT8_T
2087 size_t n = arg_end - arg;
2094 DCHAR_T *converted = result + length;
2095 size_t converted_len = allocated - length;
2099 u8_conv_to_encoding (locale_charset (),
2100 iconveh_question_mark,
2101 arg, arg_end - arg, NULL,
2102 converted, &converted_len);
2106 U8_TO_DCHAR (arg, arg_end - arg,
2107 converted, &converted_len);
2109 if (converted == NULL)
2111 int saved_errno = errno;
2112 if (!(result == resultbuf || result == NULL))
2114 if (buf_malloced != NULL)
2115 free (buf_malloced);
2117 errno = saved_errno;
2120 if (converted != result + length)
2123 DCHAR_CPY (result + length, converted, converted_len);
2126 length += converted_len;
2130 if (has_width && width > characters
2133 size_t n = width - characters;
2141 case TYPE_U16_STRING:
2143 const uint16_t *arg = a.
arg[dp->arg_index].
a.a_u16_string;
2154 int count = u16_strmblen (arg_end);
2159 if (!(result == resultbuf || result == NULL))
2161 if (buf_malloced != NULL)
2162 free (buf_malloced);
2179 int count = u16_strmblen (arg_end);
2184 if (!(result == resultbuf || result == NULL))
2186 if (buf_malloced != NULL)
2187 free (buf_malloced);
2199 arg_end = arg + u16_strlen (arg);
2204 if (has_width && width > characters
2207 size_t n = width - characters;
2213 # if DCHAR_IS_UINT16_T
2215 size_t n = arg_end - arg;
2222 DCHAR_T *converted = result + length;
2223 size_t converted_len = allocated - length;
2227 u16_conv_to_encoding (locale_charset (),
2228 iconveh_question_mark,
2229 arg, arg_end - arg, NULL,
2230 converted, &converted_len);
2234 U16_TO_DCHAR (arg, arg_end - arg,
2235 converted, &converted_len);
2237 if (converted == NULL)
2239 int saved_errno = errno;
2240 if (!(result == resultbuf || result == NULL))
2242 if (buf_malloced != NULL)
2243 free (buf_malloced);
2245 errno = saved_errno;
2248 if (converted != result + length)
2251 DCHAR_CPY (result + length, converted, converted_len);
2254 length += converted_len;
2258 if (has_width && width > characters
2261 size_t n = width - characters;
2269 case TYPE_U32_STRING:
2271 const uint32_t *arg = a.
arg[dp->arg_index].
a.a_u32_string;
2282 int count = u32_strmblen (arg_end);
2287 if (!(result == resultbuf || result == NULL))
2289 if (buf_malloced != NULL)
2290 free (buf_malloced);
2307 int count = u32_strmblen (arg_end);
2312 if (!(result == resultbuf || result == NULL))
2314 if (buf_malloced != NULL)
2315 free (buf_malloced);
2327 arg_end = arg + u32_strlen (arg);
2332 if (has_width && width > characters
2335 size_t n = width - characters;
2341 # if DCHAR_IS_UINT32_T
2343 size_t n = arg_end - arg;
2350 DCHAR_T *converted = result + length;
2351 size_t converted_len = allocated - length;
2355 u32_conv_to_encoding (locale_charset (),
2356 iconveh_question_mark,
2357 arg, arg_end - arg, NULL,
2358 converted, &converted_len);
2362 U32_TO_DCHAR (arg, arg_end - arg,
2363 converted, &converted_len);
2365 if (converted == NULL)
2367 int saved_errno = errno;
2368 if (!(result == resultbuf || result == NULL))
2370 if (buf_malloced != NULL)
2371 free (buf_malloced);
2373 errno = saved_errno;
2376 if (converted != result + length)
2379 DCHAR_CPY (result + length, converted, converted_len);
2382 length += converted_len;
2386 if (has_width && width > characters
2389 size_t n = width - characters;
2402 #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
2403 else if (dp->conversion ==
's'
2404 #
if WIDE_CHAR_VERSION
2405 && a.
arg[dp->arg_index].
type != TYPE_WIDE_STRING
2407 && a.
arg[dp->arg_index].
type == TYPE_WIDE_STRING
2421 int flags = dp->flags;
2429 if (dp->width_start != dp->width_end)
2431 if (dp->width_arg_index !=
ARG_NONE)
2437 arg = a.
arg[dp->width_arg_index].
a.
a_int;
2443 width = (
unsigned int) (-arg);
2450 const FCHAR_T *digitp = dp->width_start;
2453 width =
xsum (
xtimes (width, 10), *digitp++ -
'0');
2454 while (digitp != dp->width_end);
2461 if (dp->precision_start != dp->precision_end)
2463 if (dp->precision_arg_index !=
ARG_NONE)
2469 arg = a.
arg[dp->precision_arg_index].
a.
a_int;
2480 const FCHAR_T *digitp = dp->precision_start + 1;
2483 while (digitp != dp->precision_end)
2489 # if WIDE_CHAR_VERSION
2493 const char *arg_end;
2510 count = mbrlen (arg_end, MB_CUR_MAX, &state);
2512 count = mblen (arg_end, MB_CUR_MAX);
2520 if (!(result == resultbuf || result == NULL))
2522 if (buf_malloced != NULL)
2523 free (buf_malloced);
2546 count = mbrlen (arg_end, MB_CUR_MAX, &state);
2548 count = mblen (arg_end, MB_CUR_MAX);
2556 if (!(result == resultbuf || result == NULL))
2558 if (buf_malloced != NULL)
2559 free (buf_malloced);
2571 arg_end = arg + strlen (arg);
2576 if (has_width && width > characters
2579 size_t n = width - characters;
2585 if (has_precision || has_width)
2594 for (remaining = characters; remaining > 0; remaining--)
2599 count = mbrtowc (&
wc, arg, arg_end - arg, &state);
2601 count = mbtowc (&
wc, arg, arg_end - arg);
2607 result[length++] =
wc;
2610 if (!(arg == arg_end))
2619 while (arg < arg_end)
2624 count = mbrtowc (&
wc, arg, arg_end - arg, &state);
2626 count = mbtowc (&
wc, arg, arg_end - arg);
2633 result[length++] =
wc;
2638 if (has_width && width > characters
2641 size_t n = width - characters;
2650 const wchar_t *arg = a.
arg[dp->arg_index].
a.a_wide_string;
2651 const wchar_t *arg_end;
2653 # if !DCHAR_IS_TCHAR
2666 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2680 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2681 count = wcrtomb (cbuf, *arg_end, &state);
2683 count = wctomb (cbuf, *arg_end);
2688 if (!(result == resultbuf || result == NULL))
2690 if (buf_malloced != NULL)
2691 free (buf_malloced);
2699 characters +=
count;
2711 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2725 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2726 count = wcrtomb (cbuf, *arg_end, &state);
2728 count = wctomb (cbuf, *arg_end);
2733 if (!(result == resultbuf || result == NULL))
2735 if (buf_malloced != NULL)
2736 free (buf_malloced);
2742 characters +=
count;
2749 arg_end = arg + local_wcslen (arg);
2755 # if !DCHAR_IS_TCHAR
2763 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2767 for (remaining = characters; remaining > 0; )
2774 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2775 count = wcrtomb (cbuf, *arg, &state);
2777 count = wctomb (cbuf, *arg);
2782 memcpy (tmpptr, cbuf,
count);
2787 if (!(arg == arg_end))
2793 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2794 iconveh_question_mark,
2800 int saved_errno = errno;
2802 if (!(result == resultbuf || result == NULL))
2804 if (buf_malloced != NULL)
2805 free (buf_malloced);
2807 errno = saved_errno;
2815 # if ENABLE_UNISTDIO
2819 w = DCHAR_MBSNLEN (result + length, characters);
2830 if (has_width && width > w
2833 size_t n = width - w;
2840 if (has_precision || has_width)
2844 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2849 for (remaining = characters; remaining > 0; )
2856 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2857 count = wcrtomb (cbuf, *arg, &state);
2859 count = wctomb (cbuf, *arg);
2864 memcpy (result + length, cbuf,
count);
2869 if (!(arg == arg_end))
2874 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2878 while (arg < arg_end)
2885 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2886 count = wcrtomb (cbuf, *arg, &state);
2888 count = wctomb (cbuf, *arg);
2893 if (!(result == resultbuf || result == NULL))
2895 if (buf_malloced != NULL)
2896 free (buf_malloced);
2902 memcpy (result + length, cbuf,
count);
2909 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
2911 length += tmpdst_len;
2914 if (has_width && width > w
2917 size_t n = width - w;
2926 #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
2927 else if ((dp->conversion ==
'a' || dp->conversion ==
'A')
2928 #
if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
2930 #
if NEED_PRINTF_DOUBLE
2933 #
if NEED_PRINTF_LONG_DOUBLE
2941 int flags = dp->flags;
2954 if (dp->width_start != dp->width_end)
2956 if (dp->width_arg_index !=
ARG_NONE)
2962 arg = a.
arg[dp->width_arg_index].
a.
a_int;
2968 width = (
unsigned int) (-arg);
2975 const FCHAR_T *digitp = dp->width_start;
2978 width =
xsum (
xtimes (width, 10), *digitp++ -
'0');
2979 while (digitp != dp->width_end);
2986 if (dp->precision_start != dp->precision_end)
2988 if (dp->precision_arg_index !=
ARG_NONE)
2994 arg = a.
arg[dp->precision_arg_index].
a.
a_int;
3005 const FCHAR_T *digitp = dp->precision_start + 1;
3008 while (digitp != dp->precision_end)
3017 (
unsigned int) ((LDBL_DIG + 1)
3023 (
unsigned int) ((DBL_DIG + 1)
3030 tmp_length =
xsum (tmp_length, 12);
3032 if (tmp_length < width)
3035 tmp_length =
xsum (tmp_length, 1);
3037 if (tmp_length <=
sizeof (tmpbuf) /
sizeof (
DCHAR_T))
3056 # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE
3061 if (dp->conversion ==
'A')
3063 *p++ =
'N'; *p++ =
'A'; *p++ =
'N';
3067 *p++ =
'n'; *p++ =
'a'; *p++ =
'n';
3073 DECL_LONG_DOUBLE_ROUNDING
3075 BEGIN_LONG_DOUBLE_ROUNDING ();
3090 if (arg > 0.0L && arg + arg == arg)
3092 if (dp->conversion ==
'A')
3094 *p++ =
'I'; *p++ =
'N'; *p++ =
'F';
3098 *p++ =
'i'; *p++ =
'n'; *p++ =
'f';
3104 long double mantissa;
3107 mantissa = printf_frexpl (arg, &exponent);
3115 &&
precision < (
unsigned int) ((LDBL_DIG + 1) * 0.831) + 1)
3118 long double tail = mantissa;
3123 int digit = (
int) tail;
3127 if (digit & 1 ? tail >= 0.5L : tail > 0.5L)
3142 *p++ = dp->conversion -
'A' +
'X';
3147 digit = (
int) mantissa;
3153 *p++ = decimal_point_char ();
3156 while (mantissa > 0.0L)
3159 digit = (
int) mantissa;
3164 : dp->conversion - 10);
3175 *p++ = dp->conversion -
'A' +
'P';
3176 # if WIDE_CHAR_VERSION
3178 static const wchar_t decimal_format[] =
3179 {
'%',
'+',
'd',
'\0' };
3180 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3187 sprintf ((
char *) p,
"%+d", exponent);
3195 sprintf (expbuf,
"%+d", exponent);
3196 for (ep = expbuf; (*p = *ep) !=
'\0'; ep++)
3202 END_LONG_DOUBLE_ROUNDING ();
3210 # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
3215 if (dp->conversion ==
'A')
3217 *p++ =
'N'; *p++ =
'A'; *p++ =
'N';
3221 *p++ =
'n'; *p++ =
'a'; *p++ =
'n';
3241 if (arg > 0.0 && arg + arg == arg)
3243 if (dp->conversion ==
'A')
3245 *p++ =
'I'; *p++ =
'N'; *p++ =
'F';
3249 *p++ =
'i'; *p++ =
'n'; *p++ =
'f';
3258 mantissa = printf_frexp (arg, &exponent);
3266 &&
precision < (
unsigned int) ((DBL_DIG + 1) * 0.831) + 1)
3269 double tail = mantissa;
3274 int digit = (
int) tail;
3278 if (digit & 1 ? tail >= 0.5 : tail > 0.5)
3293 *p++ = dp->conversion -
'A' +
'X';
3298 digit = (
int) mantissa;
3304 *p++ = decimal_point_char ();
3307 while (mantissa > 0.0)
3310 digit = (
int) mantissa;
3315 : dp->conversion - 10);
3326 *p++ = dp->conversion -
'A' +
'P';
3327 # if WIDE_CHAR_VERSION
3329 static const wchar_t decimal_format[] =
3330 {
'%',
'+',
'd',
'\0' };
3331 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3338 sprintf ((
char *) p,
"%+d", exponent);
3346 sprintf (expbuf,
"%+d", exponent);
3347 for (ep = expbuf; (*p = *ep) !=
'\0'; ep++)
3359 if (has_width && p - tmp < width)
3361 size_t pad = width - (p - tmp);
3367 for (; pad > 0; pad--)
3370 else if ((flags &
FLAG_ZERO) && pad_ptr != NULL)
3377 for (; pad > 0; pad--)
3387 for (; pad > 0; pad--)
3395 size_t count = p - tmp;
3397 if (
count >= tmp_length)
3403 if (
count >= allocated - length)
3411 memcpy (result + length, tmp,
count *
sizeof (
DCHAR_T));
3418 #if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
3419 else if ((dp->conversion ==
'f' || dp->conversion ==
'F'
3420 || dp->conversion ==
'e' || dp->conversion ==
'E'
3421 || dp->conversion ==
'g' || dp->conversion ==
'G'
3422 || dp->conversion ==
'a' || dp->conversion ==
'A')
3424 #
if NEED_PRINTF_DOUBLE
3426 # elif NEED_PRINTF_INFINITE_DOUBLE
3431 && is_infinite_or_zero (a.
arg[dp->arg_index].
a.
a_double))
3433 #
if NEED_PRINTF_LONG_DOUBLE
3435 # elif NEED_PRINTF_INFINITE_LONG_DOUBLE
3445 # if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE)
3448 int flags = dp->flags;
3461 if (dp->width_start != dp->width_end)
3463 if (dp->width_arg_index !=
ARG_NONE)
3469 arg = a.
arg[dp->width_arg_index].
a.
a_int;
3475 width = (
unsigned int) (-arg);
3482 const FCHAR_T *digitp = dp->width_start;
3485 width =
xsum (
xtimes (width, 10), *digitp++ -
'0');
3486 while (digitp != dp->width_end);
3493 if (dp->precision_start != dp->precision_end)
3495 if (dp->precision_arg_index !=
ARG_NONE)
3501 arg = a.
arg[dp->precision_arg_index].
a.
a_int;
3512 const FCHAR_T *digitp = dp->precision_start + 1;
3515 while (digitp != dp->precision_end)
3526 if (!(dp->conversion ==
'a' || dp->conversion ==
'A'))
3530 # if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
3532 # elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE
3534 # elif NEED_PRINTF_LONG_DOUBLE
3535 tmp_length = LDBL_DIG + 1;
3536 # elif NEED_PRINTF_DOUBLE
3537 tmp_length = DBL_DIG + 1;
3543 # if NEED_PRINTF_LONG_DOUBLE
3544 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
3547 if (dp->conversion ==
'f' || dp->conversion ==
'F')
3550 if (!(isnanl (arg) || arg + arg == arg))
3553 int exponent = floorlog10l (arg < 0 ? -arg : arg);
3554 if (exponent >= 0 && tmp_length < exponent +
precision)
3559 # if NEED_PRINTF_DOUBLE
3560 # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
3563 if (dp->conversion ==
'f' || dp->conversion ==
'F')
3566 if (!(isnand (arg) || arg + arg == arg))
3569 int exponent = floorlog10 (arg < 0 ? -arg : arg);
3570 if (exponent >= 0 && tmp_length < exponent +
precision)
3576 tmp_length =
xsum (tmp_length, 12);
3578 if (tmp_length < width)
3581 tmp_length =
xsum (tmp_length, 1);
3583 if (tmp_length <=
sizeof (tmpbuf) /
sizeof (
DCHAR_T))
3601 # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
3602 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
3610 if (dp->conversion >=
'A' && dp->conversion <=
'Z')
3612 *p++ =
'N'; *p++ =
'A'; *p++ =
'N';
3616 *p++ =
'n'; *p++ =
'a'; *p++ =
'n';
3622 DECL_LONG_DOUBLE_ROUNDING
3624 BEGIN_LONG_DOUBLE_ROUNDING ();
3639 if (arg > 0.0L && arg + arg == arg)
3641 if (dp->conversion >=
'A' && dp->conversion <=
'Z')
3643 *p++ =
'I'; *p++ =
'N'; *p++ =
'F';
3647 *p++ =
'i'; *p++ =
'n'; *p++ =
'f';
3652 # if NEED_PRINTF_LONG_DOUBLE
3655 if (dp->conversion ==
'f' || dp->conversion ==
'F')
3661 scale10_round_decimal_long_double (arg,
precision);
3664 END_LONG_DOUBLE_ROUNDING ();
3667 ndigits = strlen (digits);
3673 *p++ = digits[ndigits];
3681 *p++ = decimal_point_char ();
3687 *p++ = digits[ndigits];
3693 else if (dp->conversion ==
'e' || dp->conversion ==
'E')
3703 *p++ = decimal_point_char ();
3715 exponent = floorlog10l (arg);
3720 scale10_round_decimal_long_double (arg,
3724 END_LONG_DOUBLE_ROUNDING ();
3727 ndigits = strlen (digits);
3755 scale10_round_decimal_long_double (arg,
3757 if (digits2 == NULL)
3760 END_LONG_DOUBLE_ROUNDING ();
3774 *p++ = digits[--ndigits];
3777 *p++ = decimal_point_char ();
3781 *p++ = digits[ndigits];
3788 *p++ = dp->conversion;
3789 # if WIDE_CHAR_VERSION
3791 static const wchar_t decimal_format[] =
3792 {
'%',
'+',
'.',
'2',
'd',
'\0' };
3793 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3800 sprintf ((
char *) p,
"%+.2d", exponent);
3808 sprintf (expbuf,
"%+.2d", exponent);
3809 for (ep = expbuf; (*p = *ep) !=
'\0'; ep++)
3814 else if (dp->conversion ==
'g' || dp->conversion ==
'G')
3832 if ((flags &
FLAG_ALT) || ndigits > nzeroes)
3834 *p++ = decimal_point_char ();
3835 while (ndigits > nzeroes)
3851 exponent = floorlog10l (arg);
3856 scale10_round_decimal_long_double (arg,
3860 END_LONG_DOUBLE_ROUNDING ();
3863 ndigits = strlen (digits);
3885 if (is_borderline (digits,
precision - 1))
3891 scale10_round_decimal_long_double (arg,
3893 if (digits2 == NULL)
3896 END_LONG_DOUBLE_ROUNDING ();
3914 while (nzeroes < ndigits
3915 && digits[nzeroes] ==
'0')
3928 size_t count = exponent + 1;
3931 *p++ = digits[--ndigits];
3932 if ((flags &
FLAG_ALT) || ndigits > nzeroes)
3934 *p++ = decimal_point_char ();
3935 while (ndigits > nzeroes)
3938 *p++ = digits[ndigits];
3944 size_t count = -exponent - 1;
3946 *p++ = decimal_point_char ();
3949 while (ndigits > nzeroes)
3952 *p++ = digits[ndigits];
3959 *p++ = digits[--ndigits];
3960 if ((flags &
FLAG_ALT) || ndigits > nzeroes)
3962 *p++ = decimal_point_char ();
3963 while (ndigits > nzeroes)
3966 *p++ = digits[ndigits];
3969 *p++ = dp->conversion -
'G' +
'E';
3970 # if WIDE_CHAR_VERSION
3972 static const wchar_t decimal_format[] =
3973 {
'%',
'+',
'.',
'2',
'd',
'\0' };
3974 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3981 sprintf ((
char *) p,
"%+.2d", exponent);
3989 sprintf (expbuf,
"%+.2d", exponent);
3990 for (ep = expbuf; (*p = *ep) !=
'\0'; ep++)
4008 if (dp->conversion ==
'f' || dp->conversion ==
'F')
4013 *p++ = decimal_point_char ();
4018 else if (dp->conversion ==
'e' || dp->conversion ==
'E')
4023 *p++ = decimal_point_char ();
4027 *p++ = dp->conversion;
4032 else if (dp->conversion ==
'g' || dp->conversion ==
'G')
4039 *p++ = decimal_point_char ();
4040 for (; ndigits > 0; --ndigits)
4044 else if (dp->conversion ==
'a' || dp->conversion ==
'A')
4047 *p++ = dp->conversion -
'A' +
'X';
4052 *p++ = decimal_point_char ();
4056 *p++ = dp->conversion -
'A' +
'P';
4065 END_LONG_DOUBLE_ROUNDING ();
4068 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
4072 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
4078 if (dp->conversion >=
'A' && dp->conversion <=
'Z')
4080 *p++ =
'N'; *p++ =
'A'; *p++ =
'N';
4084 *p++ =
'n'; *p++ =
'a'; *p++ =
'n';
4104 if (arg > 0.0 && arg + arg == arg)
4106 if (dp->conversion >=
'A' && dp->conversion <=
'Z')
4108 *p++ =
'I'; *p++ =
'N'; *p++ =
'F';
4112 *p++ =
'i'; *p++ =
'n'; *p++ =
'f';
4117 # if NEED_PRINTF_DOUBLE
4120 if (dp->conversion ==
'f' || dp->conversion ==
'F')
4126 scale10_round_decimal_double (arg,
precision);
4129 ndigits = strlen (digits);
4135 *p++ = digits[ndigits];
4143 *p++ = decimal_point_char ();
4149 *p++ = digits[ndigits];
4155 else if (dp->conversion ==
'e' || dp->conversion ==
'E')
4165 *p++ = decimal_point_char ();
4177 exponent = floorlog10 (arg);
4182 scale10_round_decimal_double (arg,
4186 ndigits = strlen (digits);
4214 scale10_round_decimal_double (arg,
4216 if (digits2 == NULL)
4232 *p++ = digits[--ndigits];
4235 *p++ = decimal_point_char ();
4239 *p++ = digits[ndigits];
4246 *p++ = dp->conversion;
4247 # if WIDE_CHAR_VERSION
4249 static const wchar_t decimal_format[] =
4252 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4253 {
'%',
'+',
'.',
'3',
'd',
'\0' };
4255 {
'%',
'+',
'.',
'2',
'd',
'\0' };
4257 SNPRINTF (p, 6 + 1, decimal_format, exponent);
4263 static const char decimal_format[] =
4266 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4273 sprintf ((
char *) p, decimal_format, exponent);
4281 sprintf (expbuf, decimal_format, exponent);
4282 for (ep = expbuf; (*p = *ep) !=
'\0'; ep++)
4288 else if (dp->conversion ==
'g' || dp->conversion ==
'G')
4306 if ((flags &
FLAG_ALT) || ndigits > nzeroes)
4308 *p++ = decimal_point_char ();
4309 while (ndigits > nzeroes)
4325 exponent = floorlog10 (arg);
4330 scale10_round_decimal_double (arg,
4334 ndigits = strlen (digits);
4356 if (is_borderline (digits,
precision - 1))
4362 scale10_round_decimal_double (arg,
4364 if (digits2 == NULL)
4384 while (nzeroes < ndigits
4385 && digits[nzeroes] ==
'0')
4398 size_t count = exponent + 1;
4401 *p++ = digits[--ndigits];
4402 if ((flags &
FLAG_ALT) || ndigits > nzeroes)
4404 *p++ = decimal_point_char ();
4405 while (ndigits > nzeroes)
4408 *p++ = digits[ndigits];
4414 size_t count = -exponent - 1;
4416 *p++ = decimal_point_char ();
4419 while (ndigits > nzeroes)
4422 *p++ = digits[ndigits];
4429 *p++ = digits[--ndigits];
4430 if ((flags &
FLAG_ALT) || ndigits > nzeroes)
4432 *p++ = decimal_point_char ();
4433 while (ndigits > nzeroes)
4436 *p++ = digits[ndigits];
4439 *p++ = dp->conversion -
'G' +
'E';
4440 # if WIDE_CHAR_VERSION
4442 static const wchar_t decimal_format[] =
4445 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4446 {
'%',
'+',
'.',
'3',
'd',
'\0' };
4448 {
'%',
'+',
'.',
'2',
'd',
'\0' };
4450 SNPRINTF (p, 6 + 1, decimal_format, exponent);
4456 static const char decimal_format[] =
4459 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4466 sprintf ((
char *) p, decimal_format, exponent);
4474 sprintf (expbuf, decimal_format, exponent);
4475 for (ep = expbuf; (*p = *ep) !=
'\0'; ep++)
4494 if (dp->conversion ==
'f' || dp->conversion ==
'F')
4499 *p++ = decimal_point_char ();
4504 else if (dp->conversion ==
'e' || dp->conversion ==
'E')
4509 *p++ = decimal_point_char ();
4513 *p++ = dp->conversion;
4517 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4523 else if (dp->conversion ==
'g' || dp->conversion ==
'G')
4530 *p++ = decimal_point_char ();
4531 for (; ndigits > 0; --ndigits)
4545 if (has_width && p - tmp < width)
4547 size_t pad = width - (p - tmp);
4553 for (; pad > 0; pad--)
4556 else if ((flags &
FLAG_ZERO) && pad_ptr != NULL)
4563 for (; pad > 0; pad--)
4573 for (; pad > 0; pad--)
4581 size_t count = p - tmp;
4583 if (
count >= tmp_length)
4589 if (
count >= allocated - length)
4597 memcpy (result + length, tmp,
count *
sizeof (
DCHAR_T));
4607 int flags = dp->flags;
4608 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4612 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
4616 #if NEED_PRINTF_UNBOUNDED_PRECISION
4619 # define prec_ourselves 0
4621 #if NEED_PRINTF_FLAG_LEFTADJUST
4622 # define pad_ourselves 1
4623 #elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4626 # define pad_ourselves 0
4629 unsigned int prefix_count;
4638 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4641 if (dp->width_start != dp->width_end)
4643 if (dp->width_arg_index !=
ARG_NONE)
4649 arg = a.
arg[dp->width_arg_index].
a.
a_int;
4655 width = (
unsigned int) (-arg);
4662 const FCHAR_T *digitp = dp->width_start;
4665 width =
xsum (
xtimes (width, 10), *digitp++ -
'0');
4666 while (digitp != dp->width_end);
4672 #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
4675 if (dp->precision_start != dp->precision_end)
4677 if (dp->precision_arg_index !=
ARG_NONE)
4683 arg = a.
arg[dp->precision_arg_index].
a.
a_int;
4694 const FCHAR_T *digitp = dp->precision_start + 1;
4697 while (digitp != dp->precision_end)
4705 #if NEED_PRINTF_UNBOUNDED_PRECISION
4706 switch (dp->conversion)
4708 case 'd':
case 'i':
case 'u':
4710 case 'x':
case 'X':
case 'p':
4720 #if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
4721 switch (dp->conversion)
4723 # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
4730 # if NEED_PRINTF_FLAG_ZERO
4731 case 'f':
case 'F':
case 'e':
case 'E':
case 'g':
case 'G':
4750 if (tmp_length <=
sizeof (tmpbuf) /
sizeof (
TCHAR_T))
4770 #if NEED_PRINTF_FLAG_GROUPING
4786 #if __GLIBC__ >= 2 && !defined __UCLIBC__
4787 if (flags & FLAG_LOCALIZED)
4794 if (dp->width_start != dp->width_end)
4796 size_t n = dp->width_end - dp->width_start;
4801 memcpy (fbp, dp->width_start, n * sizeof (
TCHAR_T));
4806 const FCHAR_T *mp = dp->width_start;
4808 *fbp++ = (
unsigned char) *mp++;
4815 if (dp->precision_start != dp->precision_end)
4817 size_t n = dp->precision_end - dp->precision_start;
4822 memcpy (fbp, dp->precision_start, n * sizeof (
TCHAR_T));
4827 const FCHAR_T *mp = dp->precision_start;
4829 *fbp++ = (
unsigned char) *mp++;
4837 #if HAVE_LONG_LONG_INT
4838 case TYPE_LONGLONGINT:
4839 case TYPE_ULONGLONGINT:
4840 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4853 case TYPE_WIDE_CHAR:
4856 case TYPE_WIDE_STRING:
4866 #if NEED_PRINTF_DIRECTIVE_F
4867 if (dp->conversion ==
'F')
4871 *fbp = dp->conversion;
4873 # if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
4929 # define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T))
4933 (2 + TCHARS_PER_DCHAR - 1)
4934 / TCHARS_PER_DCHAR));
4937 *(
TCHAR_T *) (result + length) =
'\0';
4948 size_t maxlen = allocated - length;
4951 if (maxlen > INT_MAX / TCHARS_PER_DCHAR)
4952 maxlen = INT_MAX / TCHARS_PER_DCHAR;
4953 maxlen = maxlen * TCHARS_PER_DCHAR;
4954 # define SNPRINTF_BUF(arg) \
4955 switch (prefix_count) \
4958 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4963 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4965 prefixes[0], arg, &count); \
4968 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4970 prefixes[0], prefixes[1], arg, \
4977 # define SNPRINTF_BUF(arg) \
4978 switch (prefix_count) \
4981 count = sprintf (tmp, buf, arg); \
4984 count = sprintf (tmp, buf, prefixes[0], arg); \
4987 count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
5006 unsigned int arg = a.
arg[dp->arg_index].
a.
a_uchar;
5030 unsigned int arg = a.
arg[dp->arg_index].
a.
a_uint;
5046 #if HAVE_LONG_LONG_INT
5047 case TYPE_LONGLONGINT:
5049 long long int arg = a.
arg[dp->arg_index].
a.a_longlongint;
5053 case TYPE_ULONGLONGINT:
5055 unsigned long long int arg = a.
arg[dp->arg_index].
a.a_ulonglongint;
5079 case TYPE_WIDE_CHAR:
5081 wint_t arg = a.
arg[dp->arg_index].
a.a_wide_char;
5093 case TYPE_WIDE_STRING:
5095 const wchar_t *arg = a.
arg[dp->arg_index].
a.a_wide_string;
5123 if (retcount >
count)
5142 # if !HAVE_SNPRINTF_RETVAL_C99
5155 dp->conversion,
type, flags,
5156 has_width ? width : 0,
5160 if (maxlen < tmp_length)
5164 size_t bigger_need =
5167 TCHARS_PER_DCHAR - 1)
5168 / TCHARS_PER_DCHAR);
5173 size_t bigger_need2 =
5175 if (bigger_need < bigger_need2)
5176 bigger_need = bigger_need2;
5193 int saved_errno = errno;
5195 if (!(result == resultbuf || result == NULL))
5197 if (buf_malloced != NULL)
5198 free (buf_malloced);
5203 : (dp->conversion ==
'c' || dp->conversion ==
's'
5215 if ((
unsigned int)
count + 1 >= maxlen)
5220 if (maxlen == INT_MAX / TCHARS_PER_DCHAR)
5235 ((
unsigned int)
count + 2
5236 + TCHARS_PER_DCHAR - 1)
5237 / TCHARS_PER_DCHAR),
5246 #if NEED_PRINTF_UNBOUNDED_PRECISION
5252 (
TCHAR_T *) (result + length);
5256 size_t prefix_count;
5262 && (*prec_ptr ==
'-' || *prec_ptr ==
'+'
5263 || *prec_ptr ==
' '))
5268 && prec_ptr[0] ==
'0'
5269 && (prec_ptr[1] ==
'x' || prec_ptr[1] ==
'X'))
5272 move =
count - prefix_count;
5282 (
count + insert + TCHARS_PER_DCHAR - 1)
5283 / TCHARS_PER_DCHAR);
5284 length += (
count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
5286 length -= (
count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
5287 prec_ptr = (
TCHAR_T *) (result + length);
5290 prec_end = prec_ptr +
count;
5291 prec_ptr += prefix_count;
5293 while (prec_end > prec_ptr)
5296 prec_end[insert] = prec_end[0];
5302 while (prec_end > prec_ptr);
5310 if (
count >= tmp_length)
5318 if (dp->conversion ==
'c' || dp->conversion ==
's')
5329 tmpsrc = (
TCHAR_T *) (result + length);
5334 DCHAR_CONV_FROM_ENCODING (locale_charset (),
5335 iconveh_question_mark,
5341 int saved_errno = errno;
5342 if (!(result == resultbuf || result == NULL))
5344 if (buf_malloced != NULL)
5345 free (buf_malloced);
5347 errno = saved_errno;
5351 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
5371 if (result == resultbuf)
5373 tmpsrc = (
TCHAR_T *) (result + length);
5383 tmpsrc = (
TCHAR_T *) (result + length);
5389 tmpdst = result + length;
5393 for (n =
count; n > 0; n--)
5394 *--tmpdst = (
unsigned char) *--tmpsrc;
5399 #if DCHAR_IS_TCHAR && !USE_SNPRINTF
5401 if (
count > allocated - length)
5415 #if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
5419 # if ENABLE_UNISTDIO
5423 w = DCHAR_MBSNLEN (result + length,
count);
5431 size_t pad = width - w;
5434 if (
xsum (
count, pad) > allocated - length)
5453 # if !DCHAR_IS_TCHAR || USE_SNPRINTF
5454 DCHAR_T *
const rp = result + length;
5461 # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
5462 if (dp->conversion ==
'c'
5463 || dp->conversion ==
's')
5469 pad_ptr = (*rp ==
'-' ? rp + 1 : rp);
5471 if ((*pad_ptr >=
'A' && *pad_ptr <=
'Z')
5472 || (*pad_ptr >=
'a' && *pad_ptr <=
'z'))
5484 for (; pad > 0; pad--)
5487 else if ((flags &
FLAG_ZERO) && pad_ptr != NULL)
5494 for (; pad > 0; pad--)
5504 for (; pad > 0; pad--)
5514 #if !DCHAR_IS_TCHAR || USE_SNPRINTF
5518 memcpy (result + length, tmp,
count *
sizeof (
DCHAR_T));
5525 #if NEED_PRINTF_DIRECTIVE_F
5526 if (dp->conversion ==
'F')
5529 DCHAR_T *rp = result + length;
5531 for (rc =
count; rc > 0; rc--, rp++)
5532 if (*rp >=
'a' && *rp <=
'z')
5533 *rp = *rp -
'a' +
'A';
5541 #undef pad_ourselves
5542 #undef prec_ourselves
5549 result[length] =
'\0';
5551 if (result != resultbuf && length + 1 < allocated)
5556 memory = (
DCHAR_T *) realloc (result, (length + 1) *
sizeof (
DCHAR_T));
5561 if (buf_malloced != NULL)
5562 free (buf_malloced);
5573 if (!(result == resultbuf || result == NULL))
5575 if (buf_malloced != NULL)
5576 free (buf_malloced);
5583 if (!(result == resultbuf || result == NULL))
5585 if (buf_malloced != NULL)
5586 free (buf_malloced);
5594 #undef MAX_ROOM_NEEDED
5595 #undef TCHARS_PER_DCHAR
5603 #undef DCHAR_IS_TCHAR
void * alloca(size_t)
Memory allocation on the stack.
void const char const char const int
static int wc
FI: Provisional management of warnings.
#define wchar_t
On NetBSD 5.0, the definition of NULL lacks proper parentheses.
void * memset(void *str, int c, size_t len)
memset.c – set an area of memory to a given value Copyright (C) 1991, 2003, 2009-2011 Free Software F...
@ TYPE_COUNT_SCHAR_POINTER
@ TYPE_COUNT_SHORT_POINTER
@ TYPE_COUNT_LONGINT_POINTER
#define PRINTF_FETCHARGS
Decomposed printf argument list.
#define FLAG_GROUP
Parse printf format string.
#define ARG_NONE
arg_index value indicating that no argument is consumed.
static void precision(struct rproblem *RR, int i, int nx)
fin validite
struct _newgen_struct_value_ * value
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
signed char * a_count_schar_pointer
long int * a_count_longint_pointer
unsigned long int a_ulongint
short * a_count_short_pointer
int * a_count_int_pointer
#define ENSURE_ALLOCATION(needed)
#define SNPRINTF_BUF(arg)
#define MAX_ROOM_NEEDED
Use a different function name, to make it possible that the 'wchar_t' parametrization and the 'char' ...
#define exp
Avoid some warnings from "gcc -Wshadow".
#define IF_LINT(Code)
Here we need to call the native snprintf, not rpl_snprintf.
static size_t local_strnlen(const char *string, size_t maxlen)
#define VASNPRINTF
Specification.
#define verify(R)
Verify requirement R at compile-time, as a declaration without a trailing ';'.
#define wint_t
The definitions of _GL_FUNCDECL_RPL etc.
XSIZE_INLINE size_t xsum4(size_t size1, size_t size2, size_t size3, size_t size4)
Sum of four sizes, with overflow check.
#define size_overflow_p(SIZE)
Check for overflow.
#define xtimes(N, ELSIZE)
Multiplication of a count with an element size, with overflow check.
XSIZE_INLINE size_t xsum(size_t size1, size_t size2)
Sum of two sizes, with overflow check.
XSIZE_INLINE size_t xmax(size_t size1, size_t size2)
Maximum of two sizes, with overflow check.
XSIZE_INLINE size_t xsum3(size_t size1, size_t size2, size_t size3)
Sum of three sizes, with overflow check.