1 --- vfwprintf.c.orig 2008-09-07 11:37:54.000000000 -0700
2 +++ vfwprintf.c 2008-09-07 17:47:18.000000000 -0700
3 @@ -42,6 +42,8 @@ static char sccsid[] = "@(#)vfprintf.c 8
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.23 2004/08/26 06:25:28 des Exp $");
7 +#include "xlocale_private.h"
10 * Actual wprintf innards.
12 @@ -63,12 +65,20 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/v
17 #include "un-namespace.h"
19 #include "libc_private.h"
24 +typedef __attribute__ ((vector_size(16))) unsigned char VECTORTYPE;
27 +#endif /* __SSE2__ */
33 @@ -96,6 +106,21 @@ union arg {
38 + VECTORTYPE vectorarg;
39 + unsigned char vuchararg[16];
40 + signed char vchararg[16];
41 + unsigned short vushortarg[8];
42 + signed short vshortarg[8];
43 + unsigned int vuintarg[4];
44 + signed int vintarg[4];
47 + double vdoublearg[2];
48 + unsigned long long vulonglongarg[2];
49 + long long vlonglongarg[2];
55 @@ -106,16 +131,20 @@ enum typeid {
56 T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG,
57 T_PTRDIFFT, TP_PTRDIFFT, T_SIZET, TP_SIZET,
58 T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR,
60 + T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR, T_VECTOR
61 +#else /* ! VECTORS */
62 T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR
66 -static int __sbprintf(FILE *, const wchar_t *, va_list);
67 -static wint_t __xfputwc(wchar_t, FILE *);
68 +static int __sbprintf(FILE *, locale_t, const wchar_t *, va_list);
69 +static wint_t __xfputwc(wchar_t, FILE *, locale_t);
70 static wchar_t *__ujtoa(uintmax_t, wchar_t *, int, int, const char *, int,
72 static wchar_t *__ultoa(u_long, wchar_t *, int, int, const char *, int,
74 -static wchar_t *__mbsconv(char *, int);
75 +static wchar_t *__mbsconv(char *, int, locale_t);
76 static void __find_arguments(const wchar_t *, va_list, union arg **);
77 static void __grow_type_table(int, enum typeid **, int *);
79 @@ -125,7 +154,7 @@ static void __grow_type_table(int, enum
80 * worries about ungetc buffers and so forth.
83 -__sbprintf(FILE *fp, const wchar_t *fmt, va_list ap)
84 +__sbprintf(FILE *fp, locale_t loc, const wchar_t *fmt, va_list ap)
88 @@ -144,7 +173,7 @@ __sbprintf(FILE *fp, const wchar_t *fmt,
89 fake._lbfsize = 0; /* not actually used, but Just In Case */
91 /* do the work, then copy any error status */
92 - ret = __vfwprintf(&fake, fmt, ap);
93 + ret = __vfwprintf(&fake, loc, fmt, ap);
94 if (ret >= 0 && __fflush(&fake))
96 if (fake._flags & __SERR)
97 @@ -157,7 +186,7 @@ __sbprintf(FILE *fp, const wchar_t *fmt,
98 * File must already be locked.
101 -__xfputwc(wchar_t wc, FILE *fp)
102 +__xfputwc(wchar_t wc, FILE *fp, locale_t loc)
104 static const mbstate_t initial;
106 @@ -167,10 +196,10 @@ __xfputwc(wchar_t wc, FILE *fp)
109 if ((fp->_flags & __SSTR) == 0)
110 - return (__fputwc(wc, fp));
111 + return (__fputwc(wc, fp, loc));
114 - if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1) {
115 + if ((len = wcrtomb_l(buf, wc, &mbs, loc)) == (size_t)-1) {
116 fp->_flags |= __SERR;
119 @@ -266,7 +295,7 @@ __ultoa(u_long val, wchar_t *endp, int b
124 + LIBC_ABORT("base = %d", base);
128 @@ -338,7 +367,7 @@ __ujtoa(uintmax_t val, wchar_t *endp, in
133 + LIBC_ABORT("base = %d", base);
137 @@ -350,13 +379,14 @@ __ujtoa(uintmax_t val, wchar_t *endp, in
138 * that the multibyte char. string ends in a null character.
141 -__mbsconv(char *mbsarg, int prec)
142 +__mbsconv(char *mbsarg, int prec, locale_t loc)
144 static const mbstate_t initial;
146 wchar_t *convbuf, *wcp;
148 - size_t insize, nchars, nconv;
149 + size_t insize, nchars, nconv = 0;
150 + int mb_cur_max = MB_CUR_MAX_L(loc);
154 @@ -374,7 +404,7 @@ __mbsconv(char *mbsarg, int prec)
157 while (nchars != (size_t)prec) {
158 - nconv = mbrlen(p, MB_CUR_MAX, &mbs);
159 + nconv = mbrlen_l(p, mb_cur_max, &mbs, loc);
160 if (nconv == 0 || nconv == (size_t)-1 ||
163 @@ -399,7 +429,7 @@ __mbsconv(char *mbsarg, int prec)
166 while (insize != 0) {
167 - nconv = mbrtowc(wcp, p, insize, &mbs);
168 + nconv = mbrtowc_l(wcp, p, insize, &mbs, loc);
169 if (nconv == 0 || nconv == (size_t)-1 || nconv == (size_t)-2)
172 @@ -418,6 +448,8 @@ __mbsconv(char *mbsarg, int prec)
176 +__private_extern__ const char *__fix_nogrouping(const char *);
179 vfwprintf(FILE * __restrict fp, const wchar_t * __restrict fmt0, va_list ap)
181 @@ -425,7 +457,21 @@ vfwprintf(FILE * __restrict fp, const wc
185 - ret = __vfwprintf(fp, fmt0, ap);
186 + ret = __vfwprintf(fp, __current_locale(), fmt0, ap);
192 +vfwprintf_l(FILE * __restrict fp, locale_t loc, const wchar_t * __restrict fmt0,
198 + NORMALIZE_LOCALE(loc);
200 + ret = __vfwprintf(fp, loc, fmt0, ap);
204 @@ -474,12 +520,15 @@ static int exponent(wchar_t *, int, wcha
205 #define PTRDIFFT 0x800 /* ptrdiff_t */
206 #define INTMAXT 0x1000 /* intmax_t */
207 #define CHARINT 0x2000 /* print char using int format */
209 +#define VECTOR 0x4000 /* Altivec or SSE vector */
210 +#endif /* VECTORS */
213 * Non-MT-safe version
216 -__vfwprintf(FILE *fp, const wchar_t *fmt0, va_list ap)
217 +__private_extern__ int
218 +__vfwprintf(FILE *fp, locale_t loc, const wchar_t *fmt0, va_list ap)
220 wchar_t *fmt; /* format string */
221 wchar_t ch; /* character from fmt */
222 @@ -507,7 +556,8 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
223 * D: expchar holds this character; '\0' if no exponent, e.g. %f
224 * F: at least two digits for decimal, at least one digit for hex
226 - char *decimal_point; /* locale specific decimal point */
227 + wchar_t decimal_point; /* locale specific decimal point */
228 + char *decimal_point_mb; /* multibyte decimal point */
229 int signflag; /* true if float is negative */
230 union { /* floating point arguments %[aAeEfFgG] */
232 @@ -524,6 +574,11 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
233 int nseps; /* number of group separators with ' */
234 int nrepeats; /* number of repeats of the last group */
237 + union arg vval; /* Vector argument. */
238 + wchar_t *pct; /* Pointer to '%' at beginning of specifier. */
239 + wchar_t vsep; /* Vector separator character. */
241 u_long ulval; /* integer arguments %[diouxX] */
242 uintmax_t ujval; /* %j, %ll, %q, %t, %z integers */
243 int base; /* base for [diouxX] conversion */
244 @@ -560,7 +615,7 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
246 #define PRINT(ptr, len) do { \
247 for (n3 = 0; n3 < (len); n3++) \
248 - __xfputwc((ptr)[n3], fp); \
249 + __xfputwc((ptr)[n3], fp, loc); \
251 #define PAD(howmany, with) do { \
252 if ((n = (howmany)) > 0) { \
253 @@ -606,13 +661,13 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
254 #define INTMAX_SIZE (INTMAXT|SIZET|PTRDIFFT|LLONGINT)
256 (flags&INTMAXT ? GETARG(intmax_t) : \
257 - flags&SIZET ? (intmax_t)GETARG(size_t) : \
258 + flags&SIZET ? (intmax_t)GETARG(ssize_t) : \
259 flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \
260 (intmax_t)GETARG(long long))
262 (flags&INTMAXT ? GETARG(uintmax_t) : \
263 flags&SIZET ? (uintmax_t)GETARG(size_t) : \
264 - flags&PTRDIFFT ? (uintmax_t)GETARG(ptrdiff_t) : \
265 + flags&PTRDIFFT ? (uintmax_t)(unsigned)GETARG(ptrdiff_t) : \
266 (uintmax_t)GETARG(unsigned long long))
269 @@ -640,21 +695,24 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
270 val = GETARG (int); \
274 thousands_sep = '\0';
276 #ifndef NO_FLOATING_POINT
277 - decimal_point = localeconv()->decimal_point;
278 + decimal_point_mb = localeconv_l(loc)->decimal_point;
279 + mbtowc_l(&decimal_point, decimal_point_mb, strlen(decimal_point_mb), loc);
282 /* sorry, fwprintf(read_only_file, L"") returns WEOF, not 0 */
283 - if (prepwrite(fp) != 0)
284 + if (prepwrite(fp) != 0) {
290 /* optimise fprintf(stderr) (and other unbuffered Unix files) */
291 if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
293 - return (__sbprintf(fp, fmt0, ap));
294 + return (__sbprintf(fp, loc, fmt0, ap));
296 fmt = (wchar_t *)fmt0;
298 @@ -678,6 +736,9 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
304 +#endif /* VECTORS */
305 fmt++; /* skip over '%' */
308 @@ -686,6 +747,9 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
313 + vsep = 'X'; /* Illegal value, changed to defaults later. */
314 +#endif /* VECTORS */
317 reswitch: switch (ch) {
318 @@ -701,6 +765,11 @@ reswitch: switch (ch) {
323 + case ',': case ';': case ':': case '_':
326 +#endif /* VECTORS */
329 * ``A negative field width argument is taken as a
330 @@ -721,8 +790,8 @@ reswitch: switch (ch) {
334 - thousands_sep = *(localeconv()->thousands_sep);
335 - grouping = localeconv()->grouping;
336 + thousands_sep = *(localeconv_l(loc)->thousands_sep);
337 + grouping = __fix_nogrouping(localeconv_l(loc)->grouping);
340 if ((ch = *fmt++) == '*') {
341 @@ -796,10 +865,14 @@ reswitch: switch (ch) {
346 + if (flags & VECTOR)
348 +#endif /* VECTORS */
350 *(cp = buf) = (wchar_t)GETARG(wint_t);
352 - *(cp = buf) = (wchar_t)btowc(GETARG(int));
353 + *(cp = buf) = (wchar_t)btowc_l(GETARG(int), loc);
357 @@ -808,6 +881,10 @@ reswitch: switch (ch) {
362 + if (flags & VECTOR)
364 +#endif /* VECTORS */
365 if (flags & INTMAX_SIZE) {
367 if ((intmax_t)ujval < 0) {
368 @@ -826,6 +903,12 @@ reswitch: switch (ch) {
369 #ifndef NO_FLOATING_POINT
373 + if (flags & VECTOR) {
377 +#endif /* VECTORS */
381 @@ -837,6 +920,12 @@ reswitch: switch (ch) {
386 + fparg.dbl = GETARG(double);
388 + __hdtoa(fparg.dbl, xdigs, prec,
389 + &expt, &signflag, &dtoaend);
390 +#else /* !LDBL_COMPAT */
391 if (flags & LONGDBL) {
392 fparg.ldbl = GETARG(long double);
394 @@ -848,6 +937,7 @@ reswitch: switch (ch) {
395 __hdtoa(fparg.dbl, xdigs, prec,
396 &expt, &signflag, &dtoaend);
398 +#endif /* LDBL_COMPAT */
400 prec = dtoaend - dtoaresult;
402 @@ -855,11 +945,17 @@ reswitch: switch (ch) {
405 ndig = dtoaend - dtoaresult;
406 - cp = convbuf = __mbsconv(dtoaresult, -1);
407 + cp = convbuf = __mbsconv(dtoaresult, -1, loc);
408 freedtoa(dtoaresult);
413 + if (flags & VECTOR) {
417 +#endif /* VECTORS */
419 if (prec < 0) /* account for digit before decpt */
421 @@ -868,10 +964,22 @@ reswitch: switch (ch) {
426 + if (flags & VECTOR) {
430 +#endif /* VECTORS */
436 + if (flags & VECTOR) {
440 +#endif /* VECTORS */
441 expchar = ch - ('g' - 'e');
444 @@ -880,6 +988,14 @@ fp_begin:
449 + fparg.dbl = GETARG(double);
451 + dtoa(fparg.dbl, expchar ? 2 : 3, prec,
452 + &expt, &signflag, &dtoaend);
455 +#else /* !LDBL_COMPAT */
456 if (flags & LONGDBL) {
457 fparg.ldbl = GETARG(long double);
459 @@ -893,8 +1009,9 @@ fp_begin:
463 +#endif /* LDBL_COMPAT */
464 ndig = dtoaend - dtoaresult;
465 - cp = convbuf = __mbsconv(dtoaresult, -1);
466 + cp = convbuf = __mbsconv(dtoaresult, -1, loc);
467 freedtoa(dtoaresult);
470 @@ -989,6 +1106,10 @@ fp_common:
475 + if (flags & VECTOR)
477 +#endif /* VECTORS */
478 if (flags & INTMAX_SIZE)
481 @@ -1003,6 +1124,10 @@ fp_common:
486 + if (flags & VECTOR)
488 +#endif /* VECTORS */
489 ujval = (uintmax_t)(uintptr_t)GETARG(void *);
492 @@ -1024,7 +1149,7 @@ fp_common:
493 if ((mbp = GETARG(char *)) == NULL)
496 - convbuf = __mbsconv(mbp, prec);
497 + convbuf = __mbsconv(mbp, prec, loc);
498 if (convbuf == NULL) {
499 fp->_flags |= __SERR;
501 @@ -1055,6 +1180,10 @@ fp_common:
506 + if (flags & VECTOR)
508 +#endif /* VECTORS */
509 if (flags & INTMAX_SIZE)
512 @@ -1067,6 +1196,10 @@ fp_common:
517 + if (flags & VECTOR)
519 +#endif /* VECTORS */
520 if (flags & INTMAX_SIZE)
523 @@ -1092,6 +1225,7 @@ number: if ((dprec = prec) >= 0)
524 * ``The result of converting a zero value with an
525 * explicit precision of zero is no characters.''
527 + * except for %#.0o and zero value
530 if (flags & INTMAX_SIZE) {
531 @@ -1101,7 +1235,7 @@ number: if ((dprec = prec) >= 0)
532 flags & GROUPING, thousands_sep,
535 - if (ulval != 0 || prec != 0)
536 + if (ulval != 0 || prec != 0 || (flags & ALT))
537 cp = __ultoa(ulval, cp, base,
539 flags & GROUPING, thousands_sep,
540 @@ -1109,8 +1243,13 @@ number: if ((dprec = prec) >= 0)
542 size = buf + BUF - cp;
543 if (size > BUF) /* should never happen */
545 + LIBC_ABORT("size %d > BUF %d", size, BUF);
551 +#endif /* VECTORS */
552 default: /* "%?" prints ?, unless ? is NUL */
555 @@ -1122,6 +1261,288 @@ number: if ((dprec = prec) >= 0)
560 + if (flags & VECTOR) {
562 + * Do the minimum amount of work necessary to construct
563 + * a format specifier that can be used to recursively
564 + * call vfprintf() for each element in the vector.
566 + int i, j; /* Counter. */
567 + int vcnt; /* Number of elements in vector. */
568 + char *vfmt; /* Pointer to format specifier. */
570 + char vfmt_buf[32 + EXTRAHH]; /* Static buffer for format spec. */
571 + int vwidth = 0; /* Width specified via '*'. */
572 + int vprec = 0; /* Precision specified via '*'. */
573 + char *vstr; /* Used for asprintf(). */
574 + int vlen; /* Length returned by asprintf(). */
576 + V_CHAR, V_SHORT, V_INT,
577 + V_PCHAR, V_PSHORT, V_PINT,
580 + V_LONGLONG, V_PLONGLONG,
582 +#endif /* V64TYPE */
585 + vval.vectorarg = GETARG(VECTORTYPE);
587 + * Set vfmt. If vfmt_buf may not be big enough,
588 + * malloc() space, taking care to free it later.
589 + * (EXTRAHH is for possible extra "hh")
591 + if (&fmt[-1] - pct + EXTRAHH < sizeof(vfmt_buf))
594 + vfmt = (char *)malloc(&fmt[-1] - pct + EXTRAHH + 1);
596 + /* Set the separator character, if not specified. */
604 + /* Create the format specifier. */
605 + for (i = j = 0; i < &fmt[-1] - pct; i++) {
607 + case ',': case ';': case ':': case '_':
608 + case 'v': case 'h': case 'l':
612 + if (pct[i - 1] != '.')
618 + vfmt[j++] = pct[i];
623 + * Determine the number of elements in the vector and
624 + * finish up the format specifier.
626 + if (flags & SHORTINT) {
640 + } else if (flags & LONGINT) {
642 + vtype = (ch == 'p') ? V_PINT : V_INT;
644 + } else if (flags & LLONGINT) {
666 + vtype = (ch == 'p') ? V_PLONGLONG : V_LONGLONG;
670 + * The default case should never
677 +#endif /* V64TYPE */
692 + * The default case should never
707 + vtype = (ch == 'p') ? V_PCHAR : V_CHAR;
713 +/* Get a vector element. */
715 +#define VPRINT(type, ind, args...) do { \
718 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vuchararg[ind]); \
721 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, (void *)(long)vval.vuchararg[ind]); \
724 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vushortarg[ind]); \
727 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, (void *)(long)vval.vushortarg[ind]); \
730 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vuintarg[ind]); \
733 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, (void *)(long)vval.vuintarg[ind]); \
736 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vulonglongarg[ind]); \
738 + case V_PLONGLONG: \
739 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, (void *)(long)vval.vulonglongarg[ind]); \
742 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vfloatarg[ind]); \
745 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vdoublearg[ind]); \
749 + PRINT(vstr, vlen); \
752 +#else /* !V64TYPE */
753 +#define VPRINT(type, ind, args...) do { \
756 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vuchararg[ind]); \
759 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, (void *)(long)vval.vuchararg[ind]); \
762 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vushortarg[ind]); \
765 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, (void *)(long)vval.vushortarg[ind]); \
768 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vuintarg[ind]); \
771 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, (void *)(long)vval.vuintarg[ind]); \
774 + vlen = asprintf_l(&vstr, loc, vfmt , ## args, vval.vfloatarg[ind]); \
778 + PRINT(vstr, vlen); \
781 +#endif /* V64TYPE */
783 + /* Actually print. */
786 + /* First element. */
788 + for (i = 1; i < vcnt; i++) {
797 + /* First element. */
798 + VPRINT(vtype, 0, prec);
799 + for (i = 1; i < vcnt; i++) {
805 + VPRINT(vtype, i, prec);
810 + /* First element. */
811 + VPRINT(vtype, 0, width);
812 + for (i = 1; i < vcnt; i++) {
818 + VPRINT(vtype, i, width);
821 + /* First element. */
822 + VPRINT(vtype, 0, width, prec);
823 + for (i = 1; i < vcnt; i++) {
829 + VPRINT(vtype, i, width, prec);
835 + if (vfmt != vfmt_buf)
840 +#endif /* VECTORS */
842 * All reasonable formats wind up here. At this point, `cp'
843 * points to a string which (if not flags&LADJUST) should be
844 @@ -1177,7 +1598,7 @@ number: if ((dprec = prec) >= 0)
847 if (prec || flags & ALT)
848 - PRINT(decimal_point, 1);
849 + PRINT(&decimal_point, 1);
851 /* already handled initial 0's */
853 @@ -1203,15 +1624,14 @@ number: if ((dprec = prec) >= 0)
856 if (prec || flags & ALT) {
857 - buf[0] = *decimal_point;
859 + PRINT(&decimal_point, 1);
862 PRINTANDPAD(cp, convbuf + ndig, prec, zeroes);
863 } else { /* %[eE] or sufficiently long %[gG] */
864 if (prec > 1 || flags & ALT) {
866 - buf[1] = *decimal_point;
867 + buf[1] = decimal_point;
870 PAD(prec - ndig, zeroes);
871 @@ -1401,6 +1821,11 @@ reswitch: switch (ch) {
876 + if (flags & VECTOR)
879 +#endif /* VECTORS */
883 @@ -1408,6 +1833,11 @@ reswitch: switch (ch) {
888 + if (flags & VECTOR)
891 +#endif /* VECTORS */
894 #ifndef NO_FLOATING_POINT
895 @@ -1416,8 +1846,14 @@ reswitch: switch (ch) {
903 + if (flags & VECTOR)
906 +#endif /* VECTORS */
908 ADDTYPE(T_LONG_DOUBLE);
910 @@ -1446,9 +1882,19 @@ reswitch: switch (ch) {
915 + if (flags & VECTOR)
918 +#endif /* VECTORS */
923 + if (flags & VECTOR)
926 +#endif /* VECTORS */
930 @@ -1466,6 +1912,11 @@ reswitch: switch (ch) {
935 + if (flags & VECTOR)
938 +#endif /* VECTORS */
941 default: /* "%?" prints ?, unless ? is NUL */
942 @@ -1532,7 +1983,7 @@ done:
943 (*argtable) [n].sizearg = va_arg (ap, size_t);
946 - (*argtable) [n].psizearg = va_arg (ap, ssize_t *);
947 + (*argtable) [n].psizearg = va_arg (ap, size_t *);
950 (*argtable) [n].intmaxarg = va_arg (ap, intmax_t);
951 @@ -1551,6 +2002,11 @@ done:
952 (*argtable) [n].longdoublearg = va_arg (ap, long double);
957 + (*argtable) [n].vectorarg = va_arg (ap, VECTORTYPE);
959 +#endif /* VECTORS */
961 (*argtable) [n].pchararg = va_arg (ap, char *);
963 @@ -1585,12 +2041,12 @@ __grow_type_table (int nextarg, enum typ
964 newsize = nextarg + 1;
965 if (oldsize == STATIC_ARG_TBL_SIZE) {
966 if ((newtable = malloc(newsize * sizeof(enum typeid))) == NULL)
967 - abort(); /* XXX handle better */
968 + LIBC_ABORT("malloc: %s", strerror(errno)); /* XXX handle better */
969 bcopy(oldtable, newtable, oldsize * sizeof(enum typeid));
971 newtable = reallocf(oldtable, newsize * sizeof(enum typeid));
972 if (newtable == NULL)
973 - abort(); /* XXX handle better */
974 + LIBC_ABORT("reallocf: %s", strerror(errno)); /* XXX handle better */
976 for (n = oldsize; n < newsize; n++)
977 newtable[n] = T_UNUSED;