Deleted Added
full compact
vfwprintf.c (180102) vfwprintf.c (180104)
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

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#if 0
34#if defined(LIBC_SCCS) && !defined(lint)
35static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
36#endif /* LIBC_SCCS and not lint */
37#endif
38#include <sys/cdefs.h>
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

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#if 0
34#if defined(LIBC_SCCS) && !defined(lint)
35static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
36#endif /* LIBC_SCCS and not lint */
37#endif
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/lib/libc/stdio/vfwprintf.c 180102 2008-06-29 21:01:27Z das $");
39__FBSDID("$FreeBSD: head/lib/libc/stdio/vfwprintf.c 180104 2008-06-29 21:52:40Z das $");
40
41/*
42 * Actual wprintf innards.
43 *
44 * Avoid making gratuitous changes to this source file; it should be kept
45 * as close as possible to vfprintf.c for ease of maintenance.
46 */
47

--- 11 unchanged lines hidden (view full) ---

59#include <string.h>
60#include <wchar.h>
61#include <wctype.h>
62#include "un-namespace.h"
63
64#include "libc_private.h"
65#include "local.h"
66#include "fvwrite.h"
40
41/*
42 * Actual wprintf innards.
43 *
44 * Avoid making gratuitous changes to this source file; it should be kept
45 * as close as possible to vfprintf.c for ease of maintenance.
46 */
47

--- 11 unchanged lines hidden (view full) ---

59#include <string.h>
60#include <wchar.h>
61#include <wctype.h>
62#include "un-namespace.h"
63
64#include "libc_private.h"
65#include "local.h"
66#include "fvwrite.h"
67#include "printflocal.h"
67
68
68union arg {
69 int intarg;
70 u_int uintarg;
71 long longarg;
72 u_long ulongarg;
73 long long longlongarg;
74 unsigned long long ulonglongarg;
75 ptrdiff_t ptrdiffarg;
76 size_t sizearg;
77 intmax_t intmaxarg;
78 uintmax_t uintmaxarg;
79 void *pvoidarg;
80 char *pchararg;
81 signed char *pschararg;
82 short *pshortarg;
83 int *pintarg;
84 long *plongarg;
85 long long *plonglongarg;
86 ptrdiff_t *pptrdiffarg;
87 size_t *psizearg;
88 intmax_t *pintmaxarg;
89#ifndef NO_FLOATING_POINT
90 double doublearg;
91 long double longdoublearg;
92#endif
93 wint_t wintarg;
94 wchar_t *pwchararg;
95};
96
97/*
98 * Type ids for argument type table.
99 */
100enum typeid {
101 T_UNUSED, TP_SHORT, T_INT, T_U_INT, TP_INT,
102 T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG,
103 T_PTRDIFFT, TP_PTRDIFFT, T_SIZET, TP_SIZET,
104 T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR,
105 T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR
106};
107
108#define STATIC_ARG_TBL_SIZE 8 /* Size of static argument table. */
109
110/* An expandable array of types. */
111struct typetable {
112 enum typeid *table; /* table of types */
113 enum typeid stattable[STATIC_ARG_TBL_SIZE];
114 int tablesize; /* current size of type table */
115 int tablemax; /* largest used index in table */
116 int nextarg; /* 1-based argument index */
117};
118
119static int __sbprintf(FILE *, const wchar_t *, va_list);
120static wint_t __xfputwc(wchar_t, FILE *);
121static wchar_t *__ujtoa(uintmax_t, wchar_t *, int, int, const char *, int,
122 char, const char *);
123static wchar_t *__ultoa(u_long, wchar_t *, int, int, const char *, int,
124 char, const char *);
125static wchar_t *__mbsconv(char *, int);
69static int __sbprintf(FILE *, const wchar_t *, va_list);
70static wint_t __xfputwc(wchar_t, FILE *);
71static wchar_t *__ujtoa(uintmax_t, wchar_t *, int, int, const char *, int,
72 char, const char *);
73static wchar_t *__ultoa(u_long, wchar_t *, int, int, const char *, int,
74 char, const char *);
75static wchar_t *__mbsconv(char *, int);
126static void __find_arguments(const wchar_t *, va_list, union arg **);
127static void __grow_type_table(struct typetable *);
128
129/*
130 * Helper function for `fprintf to unbuffered unix file': creates a
131 * temporary buffer. We only work on write-only files; this avoids
132 * worries about ungetc buffers and so forth.
133 */
134static int
135__sbprintf(FILE *fp, const wchar_t *fmt, va_list ap)

--- 50 unchanged lines hidden (view full) ---

186 uio.uio_resid = len;
187 uio.uio_iovcnt = 1;
188 iov.iov_base = buf;
189 iov.iov_len = len;
190 return (__sfvwrite(fp, &uio) != EOF ? (wint_t)wc : WEOF);
191}
192
193/*
76
77/*
78 * Helper function for `fprintf to unbuffered unix file': creates a
79 * temporary buffer. We only work on write-only files; this avoids
80 * worries about ungetc buffers and so forth.
81 */
82static int
83__sbprintf(FILE *fp, const wchar_t *fmt, va_list ap)

--- 50 unchanged lines hidden (view full) ---

134 uio.uio_resid = len;
135 uio.uio_iovcnt = 1;
136 iov.iov_base = buf;
137 iov.iov_len = len;
138 return (__sfvwrite(fp, &uio) != EOF ? (wint_t)wc : WEOF);
139}
140
141/*
194 * Macros for converting digits to letters and vice versa
195 */
196#define to_digit(c) ((c) - '0')
197#define is_digit(c) ((unsigned)to_digit(c) <= 9)
198#define to_char(n) ((n) + '0')
199
200/*
201 * Convert an unsigned long to ASCII for printf purposes, returning
202 * a pointer to the first character of the string representation.
203 * Octal numbers can be forced to have a leading zero; hex numbers
204 * use the given digits.
205 */
206static wchar_t *
207__ultoa(u_long val, wchar_t *endp, int base, int octzero, const char *xdigs,
208 int needgrp, char thousep, const char *grp)

--- 250 unchanged lines hidden (view full) ---

459 * conversions, among other things. Technically, we would need the
460 * most space for base 10 conversions with thousands' grouping
461 * characters between each pair of digits. 100 bytes is a
462 * conservative overestimate even for a 128-bit uintmax_t.
463 */
464#define BUF 100
465
466/*
142 * Convert an unsigned long to ASCII for printf purposes, returning
143 * a pointer to the first character of the string representation.
144 * Octal numbers can be forced to have a leading zero; hex numbers
145 * use the given digits.
146 */
147static wchar_t *
148__ultoa(u_long val, wchar_t *endp, int base, int octzero, const char *xdigs,
149 int needgrp, char thousep, const char *grp)

--- 250 unchanged lines hidden (view full) ---

400 * conversions, among other things. Technically, we would need the
401 * most space for base 10 conversions with thousands' grouping
402 * characters between each pair of digits. 100 bytes is a
403 * conservative overestimate even for a 128-bit uintmax_t.
404 */
405#define BUF 100
406
407/*
467 * Flags used during conversion.
468 */
469#define ALT 0x001 /* alternate form */
470#define LADJUST 0x004 /* left adjustment */
471#define LONGDBL 0x008 /* long double */
472#define LONGINT 0x010 /* long integer */
473#define LLONGINT 0x020 /* long long integer */
474#define SHORTINT 0x040 /* short integer */
475#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
476#define FPT 0x100 /* Floating point number */
477#define GROUPING 0x200 /* use grouping ("'" flag) */
478 /* C99 additional size modifiers: */
479#define SIZET 0x400 /* size_t */
480#define PTRDIFFT 0x800 /* ptrdiff_t */
481#define INTMAXT 0x1000 /* intmax_t */
482#define CHARINT 0x2000 /* print char using int format */
483
484/*
485 * Non-MT-safe version
486 */
487int
488__vfwprintf(FILE *fp, const wchar_t *fmt0, va_list ap)
489{
490 wchar_t *fmt; /* format string */
491 wchar_t ch; /* character from fmt */
492 int n, n2, n3; /* handy integer (short term usage) */

--- 138 unchanged lines hidden (view full) ---

631 while (is_digit(*cp)) { \
632 n2 = 10 * n2 + to_digit(*cp); \
633 cp++; \
634 } \
635 if (*cp == '$') { \
636 int hold = nextarg; \
637 if (argtable == NULL) { \
638 argtable = statargtable; \
408 * Non-MT-safe version
409 */
410int
411__vfwprintf(FILE *fp, const wchar_t *fmt0, va_list ap)
412{
413 wchar_t *fmt; /* format string */
414 wchar_t ch; /* character from fmt */
415 int n, n2, n3; /* handy integer (short term usage) */

--- 138 unchanged lines hidden (view full) ---

554 while (is_digit(*cp)) { \
555 n2 = 10 * n2 + to_digit(*cp); \
556 cp++; \
557 } \
558 if (*cp == '$') { \
559 int hold = nextarg; \
560 if (argtable == NULL) { \
561 argtable = statargtable; \
639 __find_arguments (fmt0, orgap, &argtable); \
562 __find_warguments (fmt0, orgap, &argtable); \
640 } \
641 nextarg = n2; \
642 val = GETARG (int); \
643 nextarg = hold; \
644 fmt = ++cp; \
645 } else { \
646 val = GETARG (int); \
647 }

--- 107 unchanged lines hidden (view full) ---

755 do {
756 n = 10 * n + to_digit(ch);
757 ch = *fmt++;
758 } while (is_digit(ch));
759 if (ch == '$') {
760 nextarg = n;
761 if (argtable == NULL) {
762 argtable = statargtable;
563 } \
564 nextarg = n2; \
565 val = GETARG (int); \
566 nextarg = hold; \
567 fmt = ++cp; \
568 } else { \
569 val = GETARG (int); \
570 }

--- 107 unchanged lines hidden (view full) ---

678 do {
679 n = 10 * n + to_digit(ch);
680 ch = *fmt++;
681 } while (is_digit(ch));
682 if (ch == '$') {
683 nextarg = n;
684 if (argtable == NULL) {
685 argtable = statargtable;
763 __find_arguments (fmt0, orgap,
686 __find_warguments (fmt0, orgap,
764 &argtable);
765 }
766 goto rflag;
767 }
768 width = n;
769 goto reswitch;
770#ifndef NO_FLOATING_POINT
771 case 'L':

--- 479 unchanged lines hidden (view full) ---

1251 if (__sferror(fp))
1252 ret = EOF;
1253 if ((argtable != NULL) && (argtable != statargtable))
1254 free (argtable);
1255 return (ret);
1256 /* NOTREACHED */
1257}
1258
687 &argtable);
688 }
689 goto rflag;
690 }
691 width = n;
692 goto reswitch;
693#ifndef NO_FLOATING_POINT
694 case 'L':

--- 479 unchanged lines hidden (view full) ---

1174 if (__sferror(fp))
1175 ret = EOF;
1176 if ((argtable != NULL) && (argtable != statargtable))
1177 free (argtable);
1178 return (ret);
1179 /* NOTREACHED */
1180}
1181
1259/*
1260 * Initialize a struct typetable.
1261 */
1262static inline void
1263inittypes(struct typetable *types)
1264{
1265 int n;
1266
1182
1267 types->table = types->stattable;
1268 types->tablesize = STATIC_ARG_TBL_SIZE;
1269 types->tablemax = 0;
1270 types->nextarg = 1;
1271 for (n = 0; n < STATIC_ARG_TBL_SIZE; n++)
1272 types->table[n] = T_UNUSED;
1273}
1274
1275/*
1276 * struct typetable destructor.
1277 */
1278static inline void
1279freetypes(struct typetable *types)
1280{
1281
1282 if (types->table != types->stattable)
1283 free(types->table);
1284}
1285
1286/*
1287 * Add an argument type to the table, expanding if necessary.
1288 */
1289static inline void
1290addtype(struct typetable *types, enum typeid type)
1291{
1292
1293 if (types->nextarg >= types->tablesize)
1294 __grow_type_table(types);
1295 if (types->nextarg > types->tablemax)
1296 types->tablemax = types->nextarg;
1297 types->table[types->nextarg++] = type;
1298}
1299
1300static inline void
1301addsarg(struct typetable *types, int flags)
1302{
1303
1304 if (flags & INTMAXT)
1305 addtype(types, T_INTMAXT);
1306 else if (flags & SIZET)
1307 addtype(types, T_SIZET);
1308 else if (flags & PTRDIFFT)
1309 addtype(types, T_PTRDIFFT);
1310 else if (flags & LLONGINT)
1311 addtype(types, T_LLONG);
1312 else if (flags & LONGINT)
1313 addtype(types, T_LONG);
1314 else
1315 addtype(types, T_INT);
1316}
1317
1318static inline void
1319adduarg(struct typetable *types, int flags)
1320{
1321
1322 if (flags & INTMAXT)
1323 addtype(types, T_UINTMAXT);
1324 else if (flags & SIZET)
1325 addtype(types, T_SIZET);
1326 else if (flags & PTRDIFFT)
1327 addtype(types, T_PTRDIFFT);
1328 else if (flags & LLONGINT)
1329 addtype(types, T_U_LLONG);
1330 else if (flags & LONGINT)
1331 addtype(types, T_U_LONG);
1332 else
1333 addtype(types, T_U_INT);
1334}
1335
1336/*
1337 * Add * arguments to the type array.
1338 */
1339static inline void
1340addaster(struct typetable *types, wchar_t **fmtp)
1341{
1342 wchar_t *cp;
1343 int n2;
1344
1345 n2 = 0;
1346 cp = *fmtp;
1347 while (is_digit(*cp)) {
1348 n2 = 10 * n2 + to_digit(*cp);
1349 cp++;
1350 }
1351 if (*cp == '$') {
1352 int hold = types->nextarg;
1353 types->nextarg = n2;
1354 addtype(types, T_INT);
1355 types->nextarg = hold;
1356 *fmtp = ++cp;
1357 } else {
1358 addtype(types, T_INT);
1359 }
1360}
1361
1362/*
1363 * Find all arguments when a positional parameter is encountered. Returns a
1364 * table, indexed by argument number, of pointers to each arguments. The
1365 * initial argument table should be an array of STATIC_ARG_TBL_SIZE entries.
1366 * It will be replaces with a malloc-ed one if it overflows.
1367 */
1368static void
1369__find_arguments (const wchar_t *fmt0, va_list ap, union arg **argtable)
1370{
1371 wchar_t *fmt; /* format string */
1372 wchar_t ch; /* character from fmt */
1373 int n; /* handy integer (short term usage) */
1374 int flags; /* flags as above */
1375 int width; /* width from format (%8d), or 0 */
1376 struct typetable types; /* table of types */
1377
1378 fmt = (wchar_t *)fmt0;
1379 inittypes(&types);
1380
1381 /*
1382 * Scan the format for conversions (`%' character).
1383 */
1384 for (;;) {
1385 while ((ch = *fmt) != '\0' && ch != '%')
1386 fmt++;
1387 if (ch == '\0')
1388 goto done;
1389 fmt++; /* skip over '%' */
1390
1391 flags = 0;
1392 width = 0;
1393
1394rflag: ch = *fmt++;
1395reswitch: switch (ch) {
1396 case ' ':
1397 case '#':
1398 goto rflag;
1399 case '*':
1400 addaster(&types, &fmt);
1401 goto rflag;
1402 case '-':
1403 case '+':
1404 case '\'':
1405 goto rflag;
1406 case '.':
1407 if ((ch = *fmt++) == '*') {
1408 addaster(&types, &fmt);
1409 goto rflag;
1410 }
1411 while (is_digit(ch)) {
1412 ch = *fmt++;
1413 }
1414 goto reswitch;
1415 case '0':
1416 goto rflag;
1417 case '1': case '2': case '3': case '4':
1418 case '5': case '6': case '7': case '8': case '9':
1419 n = 0;
1420 do {
1421 n = 10 * n + to_digit(ch);
1422 ch = *fmt++;
1423 } while (is_digit(ch));
1424 if (ch == '$') {
1425 types.nextarg = n;
1426 goto rflag;
1427 }
1428 width = n;
1429 goto reswitch;
1430#ifndef NO_FLOATING_POINT
1183#ifndef NO_FLOATING_POINT
1431 case 'L':
1432 flags |= LONGDBL;
1433 goto rflag;
1434#endif
1435 case 'h':
1436 if (flags & SHORTINT) {
1437 flags &= ~SHORTINT;
1438 flags |= CHARINT;
1439 } else
1440 flags |= SHORTINT;
1441 goto rflag;
1442 case 'j':
1443 flags |= INTMAXT;
1444 goto rflag;
1445 case 'l':
1446 if (flags & LONGINT) {
1447 flags &= ~LONGINT;
1448 flags |= LLONGINT;
1449 } else
1450 flags |= LONGINT;
1451 goto rflag;
1452 case 'q':
1453 flags |= LLONGINT; /* not necessarily */
1454 goto rflag;
1455 case 't':
1456 flags |= PTRDIFFT;
1457 goto rflag;
1458 case 'z':
1459 flags |= SIZET;
1460 goto rflag;
1461 case 'C':
1462 flags |= LONGINT;
1463 /*FALLTHROUGH*/
1464 case 'c':
1465 if (flags & LONGINT)
1466 addtype(&types, T_WINT);
1467 else
1468 addtype(&types, T_INT);
1469 break;
1470 case 'D':
1471 flags |= LONGINT;
1472 /*FALLTHROUGH*/
1473 case 'd':
1474 case 'i':
1475 addsarg(&types, flags);
1476 break;
1477#ifndef NO_FLOATING_POINT
1478 case 'a':
1479 case 'A':
1480 case 'e':
1481 case 'E':
1482 case 'f':
1483 case 'g':
1484 case 'G':
1485 if (flags & LONGDBL)
1486 addtype(&types, T_LONG_DOUBLE);
1487 else
1488 addtype(&types, T_DOUBLE);
1489 break;
1490#endif /* !NO_FLOATING_POINT */
1491 case 'n':
1492 if (flags & INTMAXT)
1493 addtype(&types, TP_INTMAXT);
1494 else if (flags & PTRDIFFT)
1495 addtype(&types, TP_PTRDIFFT);
1496 else if (flags & SIZET)
1497 addtype(&types, TP_SIZET);
1498 else if (flags & LLONGINT)
1499 addtype(&types, TP_LLONG);
1500 else if (flags & LONGINT)
1501 addtype(&types, TP_LONG);
1502 else if (flags & SHORTINT)
1503 addtype(&types, TP_SHORT);
1504 else if (flags & CHARINT)
1505 addtype(&types, TP_SCHAR);
1506 else
1507 addtype(&types, TP_INT);
1508 continue; /* no output */
1509 case 'O':
1510 flags |= LONGINT;
1511 /*FALLTHROUGH*/
1512 case 'o':
1513 adduarg(&types, flags);
1514 break;
1515 case 'p':
1516 addtype(&types, TP_VOID);
1517 break;
1518 case 'S':
1519 flags |= LONGINT;
1520 /*FALLTHROUGH*/
1521 case 's':
1522 if (flags & LONGINT)
1523 addtype(&types, TP_WCHAR);
1524 else
1525 addtype(&types, TP_CHAR);
1526 break;
1527 case 'U':
1528 flags |= LONGINT;
1529 /*FALLTHROUGH*/
1530 case 'u':
1531 case 'X':
1532 case 'x':
1533 adduarg(&types, flags);
1534 break;
1535 default: /* "%?" prints ?, unless ? is NUL */
1536 if (ch == '\0')
1537 goto done;
1538 break;
1539 }
1540 }
1541done:
1542 /*
1543 * Build the argument table.
1544 */
1545 if (types.tablemax >= STATIC_ARG_TBL_SIZE) {
1546 *argtable = (union arg *)
1547 malloc (sizeof (union arg) * (types.tablemax + 1));
1548 }
1549
1184
1550 (*argtable) [0].intarg = 0;
1551 for (n = 1; n <= types.tablemax; n++) {
1552 switch (types.table[n]) {
1553 case T_UNUSED: /* whoops! */
1554 (*argtable) [n].intarg = va_arg (ap, int);
1555 break;
1556 case TP_SCHAR:
1557 (*argtable) [n].pschararg = va_arg (ap, signed char *);
1558 break;
1559 case TP_SHORT:
1560 (*argtable) [n].pshortarg = va_arg (ap, short *);
1561 break;
1562 case T_INT:
1563 (*argtable) [n].intarg = va_arg (ap, int);
1564 break;
1565 case T_U_INT:
1566 (*argtable) [n].uintarg = va_arg (ap, unsigned int);
1567 break;
1568 case TP_INT:
1569 (*argtable) [n].pintarg = va_arg (ap, int *);
1570 break;
1571 case T_LONG:
1572 (*argtable) [n].longarg = va_arg (ap, long);
1573 break;
1574 case T_U_LONG:
1575 (*argtable) [n].ulongarg = va_arg (ap, unsigned long);
1576 break;
1577 case TP_LONG:
1578 (*argtable) [n].plongarg = va_arg (ap, long *);
1579 break;
1580 case T_LLONG:
1581 (*argtable) [n].longlongarg = va_arg (ap, long long);
1582 break;
1583 case T_U_LLONG:
1584 (*argtable) [n].ulonglongarg = va_arg (ap, unsigned long long);
1585 break;
1586 case TP_LLONG:
1587 (*argtable) [n].plonglongarg = va_arg (ap, long long *);
1588 break;
1589 case T_PTRDIFFT:
1590 (*argtable) [n].ptrdiffarg = va_arg (ap, ptrdiff_t);
1591 break;
1592 case TP_PTRDIFFT:
1593 (*argtable) [n].pptrdiffarg = va_arg (ap, ptrdiff_t *);
1594 break;
1595 case T_SIZET:
1596 (*argtable) [n].sizearg = va_arg (ap, size_t);
1597 break;
1598 case TP_SIZET:
1599 (*argtable) [n].psizearg = va_arg (ap, size_t *);
1600 break;
1601 case T_INTMAXT:
1602 (*argtable) [n].intmaxarg = va_arg (ap, intmax_t);
1603 break;
1604 case T_UINTMAXT:
1605 (*argtable) [n].uintmaxarg = va_arg (ap, uintmax_t);
1606 break;
1607 case TP_INTMAXT:
1608 (*argtable) [n].pintmaxarg = va_arg (ap, intmax_t *);
1609 break;
1610 case T_DOUBLE:
1611#ifndef NO_FLOATING_POINT
1612 (*argtable) [n].doublearg = va_arg (ap, double);
1613#endif
1614 break;
1615 case T_LONG_DOUBLE:
1616#ifndef NO_FLOATING_POINT
1617 (*argtable) [n].longdoublearg = va_arg (ap, long double);
1618#endif
1619 break;
1620 case TP_CHAR:
1621 (*argtable) [n].pchararg = va_arg (ap, char *);
1622 break;
1623 case TP_VOID:
1624 (*argtable) [n].pvoidarg = va_arg (ap, void *);
1625 break;
1626 case T_WINT:
1627 (*argtable) [n].wintarg = va_arg (ap, wint_t);
1628 break;
1629 case TP_WCHAR:
1630 (*argtable) [n].pwchararg = va_arg (ap, wchar_t *);
1631 break;
1632 }
1633 }
1634
1635 freetypes(&types);
1636}
1637
1638/*
1639 * Increase the size of the type table.
1640 */
1641static void
1642__grow_type_table(struct typetable *types)
1643{
1644 enum typeid *const oldtable = types->table;
1645 const int oldsize = types->tablesize;
1646 enum typeid *newtable;
1647 int n, newsize = oldsize * 2;
1648
1649 if (newsize < types->nextarg + 1)
1650 newsize = types->nextarg + 1;
1651 if (oldsize == STATIC_ARG_TBL_SIZE) {
1652 if ((newtable = malloc(newsize * sizeof(enum typeid))) == NULL)
1653 abort(); /* XXX handle better */
1654 bcopy(oldtable, newtable, oldsize * sizeof(enum typeid));
1655 } else {
1656 newtable = reallocf(oldtable, newsize * sizeof(enum typeid));
1657 if (newtable == NULL)
1658 abort(); /* XXX handle better */
1659 }
1660 for (n = oldsize; n < newsize; n++)
1661 newtable[n] = T_UNUSED;
1662
1663 types->table = newtable;
1664 types->tablesize = newsize;
1665}
1666
1667
1668#ifndef NO_FLOATING_POINT
1669
1670static int
1671exponent(wchar_t *p0, int exp, wchar_t fmtch)
1672{
1673 wchar_t *p, *t;
1674 wchar_t expbuf[MAXEXPDIG];
1675
1676 p = p0;
1677 *p++ = fmtch;

--- 28 unchanged lines hidden ---
1185static int
1186exponent(wchar_t *p0, int exp, wchar_t fmtch)
1187{
1188 wchar_t *p, *t;
1189 wchar_t expbuf[MAXEXPDIG];
1190
1191 p = p0;
1192 *p++ = fmtch;

--- 28 unchanged lines hidden ---