ReactOS 0.4.15-dev-7958-gcd0bb1a
format.c File Reference
#include <schily/mconfig.h>
#include <schily/varargs.h>
#include <schily/string.h>
#include <schily/stdlib.h>
#include <schily/standard.h>
#include <schily/utypes.h>
#include <schily/schily.h>
Include dependency graph for format.c:

Go to the source code of this file.

Classes

struct  f_args
 

Macros

#define USE_LONGLONG
 
#define USE_NL_ARGS
 
#define args   fargs.ap /* Use working copy */
 
#define CHECKFLAG()
 
#define allmask(t)   ((unsigned t)~((unsigned t)0))
 
#define lowmask(t, x)   ((unsigned t)~((unsigned t)((1 << (x))-1)))
 
#define rshiftmask(t, s)   ((allmask(t) & lowmask(t, s)) >> (s))
 
#define CHARMASK   makemask(char)
 
#define SHORTMASK   makemask(short)
 
#define INTMASK   makemask(int)
 
#define LONGMASK   makemask(long)
 
#define divlbys(val, base)   ((val)/(base))
 
#define modlbys(val, base)   ((val)%(base))
 
#define is_dig(c)   (((c) >= '0') && ((c) <= '9'))
 
#define is_cap(c)   ((c) >= 'A' && (c) <= 'Z')
 
#define to_cap(c)   (is_cap(c) ? c : c - 'a' + 'A')
 
#define cap_ty(c)   (is_cap(c) ? 'L' : 'I')
 
#define MINUSFLG   1 /* '-' flag */
 
#define PLUSFLG   2 /* '+' flag */
 
#define SPACEFLG   4 /* ' ' flag */
 
#define HASHFLG   8 /* '#' flag */
 
#define APOFLG   16 /* '\'' flag */
 
#define GOTDOT   32 /* '.' found */
 
#define GOTSTAR   64 /* '*' found */
 
#define FMT_ARGMAX   30 /* Number of fast args */
 
#define FORMAT_IMPL
 
#define FORMAT_FUNC_NAME   format
 
#define FORMAT_FUNC_PARM
 
#define FORMAT_FUNC_PROTO_DECL   void (*fun)(char, void *),
 
#define FORMAT_FUNC_KR_DECL   register void (*fun)();
 
#define FORMAT_FUNC_KR_ARGS   fun,
 
#define ofun(c, fp)   (*fun)(c, fp)
 
#define FARG   farg
 
#define AT_NONE   0
 
#define AT_INT   1
 
#define AT_LONG   2
 
#define AT_LONG_LONG   3
 
#define AT_DOUBLE   4
 
#define AT_LONG_DOUBLE   5
 
#define AT_VOID_PTR   6
 
#define AT_CHAR_PTR   7
 
#define AT_SHORT_PTR   8
 
#define AT_INT_PTR   9
 
#define AT_LONG_PTR   10
 
#define AT_LONG_LONG_PTR   11
 
#define AT_R_FMT   12
 
#define AT_R_VA_LIST   13
 
#define AT_BOUNDS   14
 
#define AF_NONE   0
 
#define AF_LONG   1
 
#define AF_LONG_LONG   2
 
#define AF_LONG_DOUBLE   4
 
#define AF_STAR   8
 

Typedefs

typedef struct f_args f_args
 

Functions

char *gcvt __PR ((double, int, char *))
 
LOCAL void prnum __PR ((Ulong, unsigned, f_args *))
 
LOCAL void prdnum __PR ((Ulong, f_args *))
 
LOCAL int prbuf __PR ((const char *, f_args *))
 
LOCAL int prc __PR ((char, f_args *))
 
EXPORT void _fmtarglist __PR ((const char *fmt, va_lists_t, va_lists_t arglist[]))
 
EXPORT void _fmtgetarg __PR ((const char *fmt, int num, va_lists_t *))
 
 va_copy (sargs.ap, oargs)
 
 for (; *fmt !='\0';fmt++)
 
LOCAL void prnum (Ulong val, unsigned base, f_args *fa)
 
LOCAL void prdnum (Ulong val, f_args *fa)
 
LOCAL void pronum (Ulong val, f_args *fa)
 
LOCAL void prxnum (Ulong val, f_args *fa)
 
LOCAL void prXnum (Ulong val, f_args *fa)
 
LOCAL void prlnum (Ullong val, unsigned base, f_args *fa)
 
LOCAL void prldnum (Ullong val, f_args *fa)
 
LOCAL void prlonum (Ullong val, f_args *fa)
 
LOCAL void prlxnum (Ullong val, f_args *fa)
 
LOCAL void prlXnum (Ullong val, f_args *fa)
 
LOCAL int prbuf (const char *s, f_args *fa)
 
LOCAL int prc (char c, f_args *fa)
 
LOCAL int prstring (const char *s, f_args *fa)
 
EXPORT void _fmtarglist (char *fmt, va_lists_t fargs, arglist) const
 
EXPORT void _fmtgetarg (char *fmt, int num, va_lists_t *fargs) const
 

Variables

EXPORT int FORMAT_FUNC_KR_DECL register voidfarg = farg
 
register charfmt
 
va_list oargs
 
const charsfmt
 
register int unsflag
 
register long val
 
register char type
 
register char mode
 
register char c
 
int count = 0
 
int num
 
int i
 
short sh
 
const charstr
 
double dval
 
Llong llval = 0
 
Ulong res
 
charrfmt
 
f_args fa
 
va_lists_t fargs = sargs
 
va_lists_t sargs
 
va_lists_t arglist [FMT_ARGMAX+1]
 
const charofmt = fmt
 
BOOL didlist = FALSE
 
fa outf = fun
 
out __pad0__
 
LOCAL unsigned char dtab [] = "0123456789abcdef"
 
LOCAL unsigned char udtab [] = "0123456789ABCDEF"
 
static const char skips [] = "+- #'.$h1234567890"
 
static const chardigits = &skips[8]
 

Macro Definition Documentation

◆ AF_LONG

#define AF_LONG   1

Definition at line 1372 of file format.c.

◆ AF_LONG_DOUBLE

#define AF_LONG_DOUBLE   4

Definition at line 1374 of file format.c.

◆ AF_LONG_LONG

#define AF_LONG_LONG   2

Definition at line 1373 of file format.c.

◆ AF_NONE

#define AF_NONE   0

Definition at line 1371 of file format.c.

◆ AF_STAR

#define AF_STAR   8

Definition at line 1375 of file format.c.

◆ allmask

#define allmask (   t)    ((unsigned t)~((unsigned t)0))

Definition at line 100 of file format.c.

◆ APOFLG

#define APOFLG   16 /* '\'' flag */

Definition at line 166 of file format.c.

◆ args

FxRequestBuffer args   fargs.ap /* Use working copy */

Definition at line 66 of file format.c.

Referenced by __report_error(), _scprintf(), _scwprintf(), _snprintf(), _texecl(), _texecle(), _texeclp(), _texeclpe(), _tspawnl(), _tspawnle(), _tspawnlp(), _tspawnlpe(), _tspawnv(), _tspawnve(), CRegistryTree::AddErrorDescription(), AddToSendBuffer(), ATL::CStringT< BaseType, StringTraits >::AppendFormat(), AVISplitter_first_request(), BaseInputPinImpl_NewSegment(), call_varargs(), check_record_(), cmd_rename(), cmd_rmdir(), comerr(), comerrno(), CommandDelete(), ConMsgPrintf(), ConPrintf(), ConResMsgPrintf(), ConResMsgPrintfEx(), ConResPrintf(), ConResPrintfEx(), convert_old_args(), DbgP(), DbgPrint(), DbgPrintEarly(), anonymous_namespace{mstscax.cpp}::dbgprintf(), debug_printf(), DebugFunction(), DECLARE_INTERFACE_(), die(), DisplayMessage(), doc_complex_write(), doflag(), DoFormatDrive(), dosflags(), dprintf(), EfiPrintf(), eprintf(), errmsg(), errmsgno(), error(), ErrorMessageBox(), ErrorMsgBox(), expect_files(), ext3_warning(), find_arb_pshader(), find_arb_vshader(), find_glsl_domain_shader(), find_glsl_geometry_shader(), find_glsl_pshader(), find_glsl_vshader(), ATL::CStringT< BaseType, StringTraits >::Format(), FormatMessageA(), FormatMessageW(), FormatString(), FT_New_Face(), FT_New_Memory_Face(), get_template_name(), getallargs(), getargs(), getlallargs(), getlargs(), Global_InStr(), Global_InvokeEx(), HANDLE_CustomType23(), HANDLE_CustomType7(), indent_printf(), InfoMessageBox(), init_arginfo(), Install(), install_wine_gecko(), invoke_procedure(), ITERATE_StartService(), js_error(), js_fprintf(), js_printf(), js_snprintf(), LIBXML_ATTR_FORMAT(), LIBXSLT_ATTR_FORMAT(), Link(), MCI_GetString(), MCI_ParseOptArgs(), mciSendStringW(), ModuleMessage(), mp_clear_multi(), mp_init_multi(), msi_service_args_to_vector(), NdrAsyncClientCall(), NdrAsyncServerCall(), NdrClientCall2(), NdrMesProcEncodeDecode(), NdrStubCall2(), nfs41_delegation_recall(), notify_webbrowser_close(), Open(), parse_arguments(), parse_event_elem(), pdie(), picture_render(), pp_add_macro(), print_error(), printf(), PRINTF_ATTR(), PrintMessageAnsi(), PrintParserError(), PrintResourceString(), PrintString(), ProcessCommandLine(), pSetupDebugPrint(), PullPin_NewSegment(), put_str(), register_dlls_callback(), RegistryStatus(), remglob(), Remove(), ResourceMessageBox(), run_script(), SerenumInitMultiSzString(), CRegistryTree::SetError(), CardButton::SetText(), setup_arguments_object(), shader_addline(), shader_arb_generate_pshader(), shader_arb_generate_vshader(), shader_glsl_find_ffp_fragment_shader(), shader_glsl_generate_domain_shader(), shader_glsl_generate_pshader(), shader_glsl_generate_vshader(), ShellMessageBoxA(), ShellMessageBoxW(), ShellMessageBoxWrapW(), SHPackDispParamsV(), sprintf(), SQLConfigDriver(), SQLConfigDriverW(), Stop(), str_printf(), string_buffer_sprintf(), SuccessMsgBox(), swprintf(), symbol_demangle(), T42_Face_Init(), test_commandline2argv(), test_disp(), test_Invoke(), test_invoke_func(), test_ShellExecute(), test_TypeInfo(), tokenizeCommand(), type_new_function(), UnderlinedResPrintf(), Unlink(), VfatPrint(), write_status(), WriteToLogPrintf(), xcomerr(), xcomerrno(), xmlGenericErrorDefaultFunc(), and xmlStrPrintf().

◆ AT_BOUNDS

#define AT_BOUNDS   14

Definition at line 1369 of file format.c.

◆ AT_CHAR_PTR

#define AT_CHAR_PTR   7

Definition at line 1362 of file format.c.

◆ AT_DOUBLE

#define AT_DOUBLE   4

Definition at line 1359 of file format.c.

◆ AT_INT

#define AT_INT   1

Definition at line 1356 of file format.c.

◆ AT_INT_PTR

#define AT_INT_PTR   9

Definition at line 1364 of file format.c.

◆ AT_LONG

#define AT_LONG   2

Definition at line 1357 of file format.c.

◆ AT_LONG_DOUBLE

#define AT_LONG_DOUBLE   5

Definition at line 1360 of file format.c.

◆ AT_LONG_LONG

#define AT_LONG_LONG   3

Definition at line 1358 of file format.c.

◆ AT_LONG_LONG_PTR

#define AT_LONG_LONG_PTR   11

Definition at line 1366 of file format.c.

◆ AT_LONG_PTR

#define AT_LONG_PTR   10

Definition at line 1365 of file format.c.

◆ AT_NONE

#define AT_NONE   0

Definition at line 1355 of file format.c.

◆ AT_R_FMT

#define AT_R_FMT   12

Definition at line 1367 of file format.c.

◆ AT_R_VA_LIST

#define AT_R_VA_LIST   13

Definition at line 1368 of file format.c.

◆ AT_SHORT_PTR

#define AT_SHORT_PTR   8

Definition at line 1363 of file format.c.

◆ AT_VOID_PTR

#define AT_VOID_PTR   6

Definition at line 1361 of file format.c.

◆ cap_ty

#define cap_ty (   c)    (is_cap(c) ? 'L' : 'I')

Definition at line 125 of file format.c.

◆ CHARMASK

#define CHARMASK   makemask(char)

Definition at line 104 of file format.c.

◆ CHECKFLAG

#define CHECKFLAG ( )

Definition at line 81 of file format.c.

◆ divlbys

#define divlbys (   val,
  base 
)    ((val)/(base))

Definition at line 113 of file format.c.

◆ FARG

#define FARG   farg

Definition at line 240 of file format.c.

◆ FMT_ARGMAX

#define FMT_ARGMAX   30 /* Number of fast args */

Definition at line 170 of file format.c.

◆ FORMAT_FUNC_KR_ARGS

#define FORMAT_FUNC_KR_ARGS   fun,

Definition at line 232 of file format.c.

◆ FORMAT_FUNC_KR_DECL

#define FORMAT_FUNC_KR_DECL   register void (*fun)();

Definition at line 231 of file format.c.

◆ FORMAT_FUNC_NAME

#define FORMAT_FUNC_NAME   format

Definition at line 227 of file format.c.

◆ FORMAT_FUNC_PARM

#define FORMAT_FUNC_PARM

Definition at line 228 of file format.c.

◆ FORMAT_FUNC_PROTO_DECL

#define FORMAT_FUNC_PROTO_DECL   void (*fun)(char, void *),

Definition at line 230 of file format.c.

◆ FORMAT_IMPL

#define FORMAT_IMPL

Definition at line 193 of file format.c.

◆ GOTDOT

#define GOTDOT   32 /* '.' found */

Definition at line 167 of file format.c.

◆ GOTSTAR

#define GOTSTAR   64 /* '*' found */

Definition at line 168 of file format.c.

◆ HASHFLG

#define HASHFLG   8 /* '#' flag */

Definition at line 165 of file format.c.

◆ INTMASK

#define INTMASK   makemask(int)

Definition at line 106 of file format.c.

◆ is_cap

#define is_cap (   c)    ((c) >= 'A' && (c) <= 'Z')

Definition at line 123 of file format.c.

◆ is_dig

#define is_dig (   c)    (((c) >= '0') && ((c) <= '9'))

Definition at line 122 of file format.c.

◆ LONGMASK

#define LONGMASK   makemask(long)

Definition at line 107 of file format.c.

◆ lowmask

#define lowmask (   t,
  x 
)    ((unsigned t)~((unsigned t)((1 << (x))-1)))

Definition at line 101 of file format.c.

◆ MINUSFLG

#define MINUSFLG   1 /* '-' flag */

Definition at line 162 of file format.c.

◆ modlbys

#define modlbys (   val,
  base 
)    ((val)%(base))

Definition at line 114 of file format.c.

◆ ofun

#define ofun (   c,
  fp 
)    (*fun)(c, fp)

Definition at line 234 of file format.c.

◆ PLUSFLG

#define PLUSFLG   2 /* '+' flag */

Definition at line 163 of file format.c.

◆ rshiftmask

#define rshiftmask (   t,
  s 
)    ((allmask(t) & lowmask(t, s)) >> (s))

Definition at line 102 of file format.c.

◆ SHORTMASK

#define SHORTMASK   makemask(short)

Definition at line 105 of file format.c.

◆ SPACEFLG

#define SPACEFLG   4 /* ' ' flag */

Definition at line 164 of file format.c.

◆ to_cap

#define to_cap (   c)    (is_cap(c) ? c : c - 'a' + 'A')

Definition at line 124 of file format.c.

◆ USE_LONGLONG

#define USE_LONGLONG

Definition at line 45 of file format.c.

◆ USE_NL_ARGS

#define USE_NL_ARGS

Definition at line 53 of file format.c.

Typedef Documentation

◆ f_args

typedef struct f_args f_args

Function Documentation

◆ __PR() [1/7]

LOCAL int prc __PR ( (char, f_args *)  )

◆ __PR() [2/7]

LOCAL int prbuf __PR ( (const char *, f_args *)  )

◆ __PR() [3/7]

◆ __PR() [4/7]

◆ __PR() [5/7]

char *gcvt __PR ( (double, int, char *)  )

◆ __PR() [6/7]

LOCAL void prdnum __PR ( (Ulong, f_args *)  )

◆ __PR() [7/7]

LOCAL void prnum __PR ( (Ulong, unsigned, f_args *)  )

◆ _fmtarglist()

EXPORT void _fmtarglist ( char fmt,
va_lists_t  fargs,
arglist   
) const

Definition at line 1390 of file format.c.

1394{
1395 int i;
1396 int argindex;
1397 int maxindex;
1398 int thistype;
1399 int thisflag;
1400 int argtypes[FMT_ARGMAX+1];
1401
1402 for (i = 0; i < FMT_ARGMAX; i++)
1403 argtypes[i] = AT_NONE;
1404
1405 maxindex = -1;
1406 argindex = 0;
1407 while ((fmt = strchr(fmt, '%')) != NULL) {
1408 fmt++;
1409 i = strspn(fmt, digits);
1410 if (fmt[i] == '$') {
1411 int c;
1412
1413 argindex = *fmt++ - '0';
1414 while (c = *fmt, is_dig(c)) {
1415 argindex *= 10;
1416 argindex += c - '0';
1417 fmt++;
1418 }
1419 argindex -= 1;
1420 }
1421 thistype = AT_NONE;
1422 thisflag = AF_NONE;
1423 newarg:
1424 fmt += strspn(fmt, skips);
1425 switch (*fmt++) {
1426
1427 case '%': /* %% format no arg */
1428 continue;
1429
1430 case 'l':
1431 if (thisflag & AF_LONG) {
1432 thisflag |= AF_LONG_LONG;
1433 } else {
1434 thisflag |= AF_LONG;
1435 }
1436 goto newarg;
1437 case 'j': /* intmax_t for now is long long */
1438 thisflag |= AF_LONG_LONG;
1439 goto newarg;
1440 case 'z': /* size_t */
1441#if SIZEOF_SIZE_T == SIZEOF_INT
1442 if (thistype == AT_NONE)
1443 thistype = AT_INT;
1444#else
1445#if SIZEOF_SIZE_T == SIZEOF_LONG_INT
1446 if (thistype == AT_NONE)
1447 thistype = AT_LONG;
1448#else
1449#if SIZEOF_SIZE_T == SIZEOF_LLONG
1450 if (thistype == AT_NONE)
1451 thistype = AT_LONG_LONG;
1452#else
1453error sizeof (size_t) is unknown
1454#endif
1455#endif
1456#endif
1457 goto newarg;
1458 case 't': /* ptrdiff_t */
1459#if SIZEOF_PTRDIFF_T == SIZEOF_INT
1460 if (thistype == AT_NONE)
1461 thistype = AT_INT;
1462#else
1463#if SIZEOF_PTRDIFF_T == SIZEOF_LONG_INT
1464 if (thistype == AT_NONE)
1465 thistype = AT_LONG;
1466#else
1467#if SIZEOF_PTRDIFF_T == SIZEOF_LLONG
1468 if (thistype == AT_NONE)
1469 thistype = AT_LONG_LONG;
1470#else
1471error sizeof (ptrdiff_t) is unknown
1472#endif
1473#endif
1474#endif
1475 goto newarg;
1476#ifndef NO_UCSIL
1477 /*
1478 * Enhancements to K&R and ANSI:
1479 *
1480 * got a type specifyer
1481 *
1482 * XXX 'S' in C99 is %ls, 'S' should become 'H'
1483 */
1484 case 'U':
1485 if (!strchr("CSILZODX", *fmt)) {
1486 /*
1487 * Got only 'U'nsigned specifyer,
1488 * use default type and mode.
1489 */
1490 thistype = AT_INT;
1491 break;
1492 }
1493 if (!strchr("CSIL", *fmt)) {
1494 /*
1495 * Got 'U' and ZODX.
1496 * no type, use default
1497 */
1498 thistype = AT_INT;
1499 fmt++; /* Skip ZODX */
1500 break;
1501 }
1502 fmt++; /* Unsigned, skip 'U', get CSIL */
1503 /* FALLTHRU */
1504 case 'C':
1505 case 'S':
1506 case 'I':
1507 case 'L':
1508 fmt--; /* Undo fmt++ from switch() */
1509 {
1510 /*
1511 * got CSIL type
1512 */
1513 int type = *fmt++; /* Undo above fmt-- */
1514 int mode = *fmt;
1515 if (!strchr("ZODX", mode)) {
1516 /*
1517 * Check long double "Le", "Lf" or "Lg"
1518 */
1519 if (type == 'L' &&
1520 (mode == 'e' ||
1521 mode == 'f' ||
1522 mode == 'g')) {
1523 thisflag |= AF_LONG_DOUBLE;
1524 goto newarg;
1525 }
1526 } else {
1527 fmt++; /* Skip ZODX */
1528 }
1529 if (type == 'L')
1530 thistype = AT_LONG;
1531 else
1532 thistype = AT_INT;
1533 }
1534 break;
1535#else
1536 case 'L':
1537 thisflag |= AF_LONG_DOUBLE;
1538 goto newarg;
1539#endif
1540
1541 case 'e':
1542 case 'E':
1543 case 'f':
1544 case 'F':
1545 case 'g':
1546 case 'G':
1547 if (thisflag & AF_LONG_DOUBLE)
1548 thistype = AT_LONG_DOUBLE;
1549 else
1550 thistype = AT_DOUBLE;
1551 break;
1552
1553 case 'p':
1554 thistype = AT_VOID_PTR;
1555 break;
1556 case 's':
1557 thistype = AT_CHAR_PTR;
1558 break;
1559 case 'b':
1560 thistype = AT_BOUNDS;
1561 break;
1562 case 'n':
1563 if (thisflag & AF_LONG_LONG)
1564 thistype = AT_LONG_LONG_PTR;
1565 else if (thistype & AF_LONG)
1566 thistype = AT_LONG_PTR;
1567 else
1568 thistype = AT_INT_PTR;
1569 break;
1570 case 'r':
1571 thistype = AT_R_FMT;
1572 break;
1573 default:
1574 if (thistype == AT_NONE) {
1575 if (thisflag & AF_LONG_LONG)
1576 thistype = AT_LONG_LONG;
1577 else if (thistype & AF_LONG)
1578 thistype = AT_LONG;
1579 else
1580 thistype = AT_INT;
1581 }
1582 break;
1583
1584 case '*':
1585 if (is_dig(*fmt)) {
1586 int c;
1587 int starindex;
1588
1589 starindex = *fmt++ - '0';
1590 while (c = *fmt, is_dig(c)) {
1591 starindex *= 10;
1592 starindex += c - '0';
1593 fmt++;
1594 }
1595 starindex -= 1;
1596 if (starindex >= 0 && starindex < FMT_ARGMAX) {
1597 argtypes[starindex] = AT_INT;
1598 if (starindex > maxindex)
1599 maxindex = starindex;
1600 }
1601 goto newarg;
1602 }
1603 thistype = AT_INT;
1604 thisflag |= AF_STAR; /* Make sure to rescan for type */
1605 break;
1606 }
1607 if (argindex >= 0 && argindex < FMT_ARGMAX) {
1608 argtypes[argindex] = thistype;
1609 if (thistype == AT_R_FMT)
1610 argtypes[++argindex] = AT_R_VA_LIST;
1611 else if (thistype == AT_BOUNDS)
1612 argtypes[++argindex] = AT_INT;
1613
1614 if (argindex > maxindex)
1615 maxindex = argindex;
1616 }
1617 ++argindex; /* Default to next arg in list */
1618 if (thisflag & AF_STAR) { /* Found '*', continue for type */
1619 thisflag &= ~AF_STAR;
1620 goto newarg;
1621 }
1622 }
1623
1624 for (i = 0; i <= maxindex; i++) { /* Do not fetch more args than known */
1625 arglist[i] = fargs; /* Save state before fetching this */
1626
1627 switch (argtypes[i]) {
1628
1629 default:
1630 /* FALLTHRU */
1631 case AT_NONE: /* This matches '*' args */
1632 /* FALLTHRU */
1633 case AT_INT:
1634 (void) va_arg(fargs.ap, int);
1635 break;
1636 case AT_LONG:
1637 (void) va_arg(fargs.ap, long);
1638 break;
1639 case AT_LONG_LONG:
1640 (void) va_arg(fargs.ap, Llong);
1641 break;
1642 case AT_DOUBLE:
1643 (void) va_arg(fargs.ap, double);
1644 break;
1645 case AT_LONG_DOUBLE:
1646#ifdef HAVE_LONGDOUBLE
1647 (void) va_arg(fargs.ap, long double);
1648#endif
1649 break;
1650 case AT_VOID_PTR:
1651 (void) va_arg(fargs.ap, void *);
1652 break;
1653 case AT_CHAR_PTR:
1654 (void) va_arg(fargs.ap, char *);
1655 break;
1656 case AT_SHORT_PTR:
1657 (void) va_arg(fargs.ap, short *);
1658 break;
1659 case AT_INT_PTR:
1660 (void) va_arg(fargs.ap, int *);
1661 break;
1662 case AT_LONG_PTR:
1663 (void) va_arg(fargs.ap, long *);
1664 break;
1665 case AT_LONG_LONG_PTR:
1666 (void) va_arg(fargs.ap, Llong *);
1667 break;
1668 case AT_R_FMT:
1669 (void) va_arg(fargs.ap, char *);
1670 arglist[++i] = fargs;
1672 break;
1673 case AT_R_VA_LIST:
1674 break;
1675 case AT_BOUNDS:
1676 (void) va_arg(fargs.ap, char *);
1677 arglist[++i] = fargs;
1678 (void) va_arg(fargs.ap, int);
1679 break;
1680 }
1681 }
1682}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define NULL
Definition: types.h:112
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
__kernel_size_t size_t
Definition: linux.h:237
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const GLubyte * c
Definition: glext.h:8905
GLenum mode
Definition: glext.h:6217
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define error(str)
Definition: mkdosfs.c:1605
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
#define AF_LONG_DOUBLE
Definition: format.c:1374
va_lists_t fargs
Definition: format.c:282
static const char skips[]
Definition: format.c:1377
#define AT_DOUBLE
Definition: format.c:1359
#define AT_NONE
Definition: format.c:1355
#define AT_LONG_PTR
Definition: format.c:1365
#define AF_STAR
Definition: format.c:1375
#define FMT_ARGMAX
Definition: format.c:170
#define AF_NONE
Definition: format.c:1371
va_lists_t arglist[FMT_ARGMAX+1]
Definition: format.c:284
#define AT_LONG
Definition: format.c:1357
#define AT_INT
Definition: format.c:1356
#define AT_LONG_LONG_PTR
Definition: format.c:1366
#define AT_R_FMT
Definition: format.c:1367
register char c
Definition: format.c:268
static const char * digits
Definition: format.c:1378
#define AT_LONG_DOUBLE
Definition: format.c:1360
#define AF_LONG
Definition: format.c:1372
#define AT_CHAR_PTR
Definition: format.c:1362
#define AT_BOUNDS
Definition: format.c:1369
#define is_dig(c)
Definition: format.c:122
#define AF_LONG_LONG
Definition: format.c:1373
#define AT_VOID_PTR
Definition: format.c:1361
#define AT_LONG_LONG
Definition: format.c:1358
#define AT_SHORT_PTR
Definition: format.c:1363
#define AT_R_VA_LIST
Definition: format.c:1368
#define AT_INT_PTR
Definition: format.c:1364
register char * fmt
Definition: format.c:254
Definition: dsound.c:943
va_list ap
Definition: varargs.h:133
long Llong
Definition: stdint.h:152
#define __va_arg_list(list)
Definition: varargs.h:123

Referenced by for().

◆ _fmtgetarg()

EXPORT void _fmtgetarg ( char fmt,
int  num,
va_lists_t fargs 
) const

Definition at line 1691 of file format.c.

1695{
1696 const char *sfmt = fmt;
1697 int i;
1698
1699 /*
1700 * Hacky preliminary support for all int type args bejond FMT_ARGMAX.
1701 */
1702 for (i = FMT_ARGMAX; i < num; i++)
1703 (void) va_arg((*fargs).ap, int);
1704}
const char * sfmt
Definition: format.c:263
int num
Definition: format.c:270

Referenced by for().

◆ for()

for ( ; *fmt = '\0'; fmt++)

Definition at line 315 of file format.c.

315 {
316 c = *fmt;
317 while (c != '%') {
318 if (c == '\0')
319 goto out;
320 ofun(c, farg);
321 c = *(++fmt);
322 count++;
323 }
324
325 /*
326 * We reached a '%' sign.
327 */
328 buf[0] = '\0';
329 fa.buf = fa.bufp = buf;
330 fa.minusflag = 0;
331 fa.flags = 0;
332 fa.fldwidth = 0;
333 fa.signific = -1;
334 fa.lzero = 0;
335 fa.fillc = ' ';
336 fa.prefixlen = 0;
337 sfmt = fmt;
338 unsflag = FALSE;
339 type = '\0';
340 mode = '\0';
341 /*
342 * %<flags>f.s<length-mod><conversion-spec>
343 * %<flags>*.*<length-mod><conversion-spec>
344 * %n$<flags>f.s<length-mod><conversion-spec>
345 * %n$<flags>*n$.*n$<length-mod><conversion-spec>
346 */
347 newflag:
348 switch (*(++fmt)) {
349
350 case '+':
351 CHECKFLAG();
352 fa.flags |= PLUSFLG;
353 goto newflag;
354
355 case '-':
356 CHECKFLAG();
357 fa.minusflag++;
358 fa.flags |= MINUSFLG;
359 goto newflag;
360
361 case ' ':
362 CHECKFLAG();
363 /*
364 * If the space and the + flag are present,
365 * the space flag will be ignored.
366 */
367 fa.flags |= SPACEFLG;
368 goto newflag;
369
370 case '#':
371 CHECKFLAG();
372 fa.flags |= HASHFLG;
373 goto newflag;
374
375 case '\'':
376 CHECKFLAG();
377 fa.flags |= APOFLG;
378 goto newflag;
379
380 case '.':
381 fa.flags |= GOTDOT;
382 fa.signific = 0;
383 goto newflag;
384
385 case '*':
386 fa.flags |= GOTSTAR;
387#ifdef USE_NL_ARGS
388 if (is_dig(fmt[1])) { /* *n$ */
389 fmt++; /* Eat up '*' */
390 goto dodig;
391 }
392#endif
393 if (!(fa.flags & GOTDOT)) {
394 fa.fldwidth = va_arg(args, int);
395 /*
396 * A negative fieldwith is a minus flag with a
397 * positive fieldwidth.
398 */
399 if (fa.fldwidth < 0) {
401 fa.minusflag = 1;
402 }
403 } else {
404 /*
405 * A negative significance (precision) is taken
406 * as if the precision and '.' were omitted.
407 */
408 fa.signific = va_arg(args, int);
409 if (fa.signific < 0)
410 fa.signific = -1;
411 }
412 goto newflag;
413
414 case '0':
415 /*
416 * '0' may be a flag.
417 */
418 if (!(fa.flags & (GOTDOT | GOTSTAR | MINUSFLG)))
419 fa.fillc = '0';
420 /* FALLTHRU */
421 case '1': case '2': case '3': case '4':
422 case '5': case '6': case '7': case '8': case '9':
423#ifdef USE_NL_ARGS
424 dodig:
425#endif
426 num = *fmt++ - '0';
427 while (c = *fmt, is_dig(c)) {
428 num *= 10;
429 num += c - '0';
430 fmt++;
431 }
432#ifdef USE_NL_ARGS
433 if (c == '$')
434 goto doarglist;
435#endif
436 fmt--; /* backup to last digit */
437 if (!(fa.flags & GOTDOT))
438 fa.fldwidth = num;
439 else
440 fa.signific = num;
441 goto newflag;
442
443#ifdef USE_NL_ARGS
444 doarglist:
445 {
446 va_lists_t tmp; /* Temporary arg state */
447 if (num <= 0) /* Illegal arg offset */
448 goto newflag; /* Continue after '$' */
449 if (!didlist) { /* Need to init arglist */
451 didlist = TRUE;
452 }
453 if (num <= FMT_ARGMAX) {
454 tmp = arglist[num-1];
455 } else {
456 tmp = arglist[FMT_ARGMAX-1];
457 _fmtgetarg(ofmt, num, &tmp);
458 }
459 if (!(fa.flags & GOTSTAR)) {
460 fargs = tmp;
461 } else {
462 if (!(fa.flags & GOTDOT)) {
463 fa.fldwidth = va_arg(tmp.ap, int);
464 /*
465 * A negative fieldwith is a minus flag
466 * with a positive fieldwidth.
467 */
468 if (fa.fldwidth < 0) {
470 fa.minusflag = 1;
471 }
472 } else {
473 /*
474 * A negative significance (precision)
475 * is taken as if the precision and '.'
476 * were omitted.
477 */
478 fa.signific = va_arg(tmp.ap, int);
479 if (fa.signific < 0)
480 fa.signific = -1;
481 }
482 }
483 goto newflag;
484 }
485#endif
486
487#ifdef USE_CHECKFLAG
488 flagerror:
489 fmt = ++sfmt; /* Don't print '%' */
490 continue;
491#endif
492 }
493
494 if (strchr("UCSIL", *fmt)) {
495 /*
496 * Enhancements to K&R and ANSI:
497 *
498 * got a type specifyer
499 *
500 * XXX 'S' in C99 is %ls, 'S' should become 'H'
501 */
502 if (*fmt == 'U') {
503 fmt++;
504 unsflag = TRUE;
505 }
506 if (!strchr("CSILZODX", *fmt)) {
507 /*
508 * Got only 'U'nsigned specifyer,
509 * use default type and mode.
510 */
511 type = 'I';
512 mode = 'D';
513 fmt--;
514 } else if (!strchr("CSIL", *fmt)) {
515 /*
516 * no type, use default
517 */
518 type = 'I';
519 mode = *fmt;
520 } else {
521 /*
522 * got CSIL type
523 */
524 type = *fmt++;
525 if (!strchr("ZODX", mode = *fmt)) {
526 /*
527 * Check long double "Le", "Lf" or "Lg"
528 */
529 if (type == 'L' &&
530 (mode == 'e' ||
531 mode == 'f' ||
532 mode == 'g'))
533 goto checkfmt;
534 fmt--;
535 mode = 'D'; /* default mode */
536 }
537 }
538 } else {
539 checkfmt:
540 switch (*fmt) {
541
542 case 'h':
543 if (!type)
544 type = 'H'; /* convert to short type */
545 goto getmode;
546
547 case 'l':
548 if (!type)
549 type = 'L'; /* convert to long type */
550 goto getmode;
551
552 case 'j':
553 if (!type)
554 type = 'J'; /* convert to intmax_t type */
555 goto getmode;
556
557 case 'z': /* size_t */
558#if SIZEOF_SIZE_T == SIZEOF_INT
559 if (!type)
560 type = 'I'; /* convert to int type */
561#else
562#if SIZEOF_SIZE_T == SIZEOF_LONG_INT
563 if (!type)
564 type = 'L'; /* convert to long type */
565#else
566#if SIZEOF_SIZE_T == SIZEOF_LLONG
567 if (!type)
568 type = 'Q'; /* convert to long long type */
569#else
570error sizeof (size_t) is unknown
571#endif
572#endif
573#endif
574 goto getmode;
575
576 case 't': /* ptrdiff_t */
577#if SIZEOF_PTRDIFF_T == SIZEOF_INT
578 if (!type)
579 type = 'I'; /* convert to int type */
580#else
581#if SIZEOF_PTRDIFF_T == SIZEOF_LONG_INT
582 if (!type)
583 type = 'L'; /* convert to long type */
584#else
585#if SIZEOF_PTRDIFF_T == SIZEOF_LLONG
586 if (!type)
587 type = 'Q'; /* convert to long long type */
588#else
589error sizeof (ptrdiff_t) is unknown
590#endif
591#endif
592#endif
593 /*
594 * XXX Future length modifiers:
595 * XXX 'L' with double: long double
596 */
597
598 getmode:
599 if (!strchr("udioxXn", *(++fmt))) {
600 /*
601 * %hhd -> char in decimal
602 */
603 if (type == 'H' && *fmt == 'h') {
604 type = 'C';
605 goto getmode;
606 }
607#ifdef USE_LONGLONG
608 if (type == 'L' && *fmt == 'l') {
609 type = 'Q';
610 goto getmode;
611 }
612#endif
613 fmt--;
614 mode = 'D';
615 } else { /* One of "udioxXn": */
616 mode = *fmt;
617 if (mode == 'n')
618 goto gotn;
619 if (mode != 'x')
620 mode = to_cap(mode);
621 if (mode == 'U')
622 unsflag = TRUE;
623 else if (mode == 'I') /* XXX */
624 mode = 'D';
625 }
626 break;
627 case 'x':
628 mode = 'x';
629 goto havemode;
630 case 'X':
631 mode = 'X';
632 type = 'I';
633 goto havemode;
634 case 'u':
635 unsflag = TRUE;
636 /*
637 * XXX Need to remove uppercase letters for 'long'
638 * XXX in future for POSIX/C99 compliance.
639 */
640 /* FALLTHRU */
641 case 'o': case 'O':
642 case 'd': case 'D':
643 case 'i': case 'I':
644 case 'Z':
645 mode = to_cap(*fmt);
646 havemode:
647 if (!type)
648 type = cap_ty(*fmt);
649#ifdef DEBUG
650 dbg_print("*fmt: '%c' mode: '%c' type: '%c'\n",
651 *fmt, mode, type);
652#endif
653 if (mode == 'I') /* XXX kann entfallen */
654 mode = 'D'; /* wenn besseres uflg */
655 break;
656 case 'p':
657 mode = 'P';
658 type = 'L';
659 break;
660
661 case '%':
662 count += prc('%', &fa);
663 continue;
664 case ' ':
665 count += prbuf("", &fa);
666 continue;
667 case 'c':
668 c = va_arg(args, int);
669 count += prc(c, &fa);
670 continue;
671 case 's':
672 str = va_arg(args, char *);
673 count += prstring(str, &fa);
674 continue;
675 case 'b':
676 str = va_arg(args, char *);
677 fa.signific = va_arg(args, int);
678 count += prstring(str, &fa);
679 continue;
680
681#ifndef NO_FLOATINGPOINT
682 case 'e':
683 if (fa.signific == -1)
684 fa.signific = 6;
685 if (type == 'L') {
686#ifdef HAVE_LONGDOUBLE
687 long double ldval = va_arg(args, long double);
688
689#if (defined(HAVE_QECVT) || defined(HAVE__LDECVT))
690 qftoes(buf, ldval, 0, fa.signific);
691 count += prbuf(buf, &fa);
692 continue;
693#else
694 dval = ldval;
695#endif
696#endif
697 }
698 dval = va_arg(args, double);
699 ftoes(buf, dval, 0, fa.signific);
700 count += prbuf(buf, &fa);
701 continue;
702 case 'f':
703 if (fa.signific == -1)
704 fa.signific = 6;
705 if (type == 'L') {
706#ifdef HAVE_LONGDOUBLE
707 long double ldval = va_arg(args, long double);
708
709#if (defined(HAVE_QFCVT) || defined(HAVE__LDFCVT))
710 qftofs(buf, ldval, 0, fa.signific);
711 count += prbuf(buf, &fa);
712 continue;
713#else
714 dval = ldval;
715#endif
716#endif
717 }
718 dval = va_arg(args, double);
719 ftofs(buf, dval, 0, fa.signific);
720 count += prbuf(buf, &fa);
721 continue;
722 case 'g':
723 if (fa.signific == -1)
724 fa.signific = 6;
725 if (fa.signific == 0)
726 fa.signific = 1;
727 if (type == 'L') {
728#ifdef HAVE_LONGDOUBLE
729 long double ldval = va_arg(args, long double);
730
731#if (defined(HAVE_QGCVT) || defined(HAVE__LDGCVT))
732
733#ifdef HAVE__LDGCVT
734#define qgcvt(ld, n, b) _ldgcvt(*(long_double *)&ld, n, b)
735#endif
736 (void) qgcvt(ldval, fa.signific, buf);
737 count += prbuf(buf, &fa);
738 continue;
739#else
740 dval = ldval;
741#endif
742#endif
743 }
744 dval = va_arg(args, double);
746 count += prbuf(buf, &fa);
747 continue;
748#else
749# ifdef USE_FLOATINGARGS
750 case 'e':
751 case 'f':
752 case 'g':
753 dval = va_arg(args, double);
754 continue;
755# endif
756#endif
757
758 case 'r': /* recursive printf */
759 case 'R': /* recursive printf */
760 rfmt = va_arg(args, char *);
761 /*
762 * I don't know any portable way to get an arbitrary
763 * C object from a var arg list so I use a
764 * system-specific routine __va_arg_list() that knows
765 * if 'va_list' is an array. You will not be able to
766 * assign the value of __va_arg_list() but it works
767 * to be used as an argument of a function.
768 * It is a requirement for recursive printf to be able
769 * to use this function argument. If your system
770 * defines va_list to be an array you need to know this
771 * via autoconf or another mechanism.
772 * It would be nice to have something like
773 * __va_arg_list() in stdarg.h
774 */
777 continue;
778
779 gotn:
780 case 'n':
781 switch (type) {
782
783 case 'C': {
784 signed char *cp = va_arg(args, signed char *);
785
786 *cp = count;
787 }
788 continue;
789 case 'H': {
790 short *sp = va_arg(args, short *);
791
792 *sp = count;
793 }
794 continue;
795 case 'L': {
796 long *lp = va_arg(args, long *);
797
798 *lp = count;
799 }
800 continue;
801#ifdef USE_LONGLONG
802 case 'J': /* For now Intmax_t is Llong */
803 case 'Q': {
804 Llong *qp = va_arg(args, Llong *);
805
806 *qp = count;
807 }
808 continue;
809#endif
810 default: {
811 int *ip = va_arg(args, int *);
812
813 *ip = count;
814 }
815 continue;
816 }
817
818 default: /* Unknown '%' format */
819 sfmt++; /* Dont't print '%' */
820 count += fmt - sfmt;
821 while (sfmt < fmt)
822 ofun(*(sfmt++), farg);
823 if (*fmt == '\0') {
824 fmt--;
825 continue;
826 } else {
827 ofun(*fmt, farg);
828 count++;
829 continue;
830 }
831 }
832 }
833 /*
834 * print numbers:
835 * first prepare type 'C'har, s'H'ort, 'I'nt, or 'L'ong
836 * or 'Q'ad and 'J'==maxint_t
837 */
838 switch (type) {
839
840 case 'C':
841 c = va_arg(args, int);
842 val = c; /* extend sign here */
843 if (unsflag || mode != 'D')
844#ifdef DO_MASK
845 val &= CHARMASK;
846#else
847 val = (unsigned char)val;
848#endif
849 break;
850 case 'H':
851 case 'S': /* XXX remove 'S' in future */
852 sh = va_arg(args, int);
853 val = sh; /* extend sign here */
854 if (unsflag || mode != 'D')
855#ifdef DO_MASK
856 val &= SHORTMASK;
857#else
858 val = (unsigned short)val;
859#endif
860 break;
861 case 'I':
862 default:
863 i = va_arg(args, int);
864 val = i; /* extend sign here */
865 if (unsflag || mode != 'D')
866#ifdef DO_MASK
867 val &= INTMASK;
868#else
869 val = (unsigned int)val;
870#endif
871 break;
872 case 'P':
873 case 'L':
874 val = va_arg(args, long);
875 break;
876#ifdef USE_LONGLONG
877 case 'J': /* For now Intmax_t is Llong */
878 type = 'Q'; /* use 'Q' for processing */
879 case 'Q':
881 val = llval != 0;
882 break;
883#endif
884 }
885
886 /*
887 * Final print out, take care of mode:
888 * mode is one of: 'O'ctal, 'D'ecimal, or he'X'
889 * oder 'Z'weierdarstellung.
890 */
891 fa.bufp = &buf[sizeof (buf)-1];
892 *--fa.bufp = '\0';
893
894 if (val == 0 && mode != 'D') {
895 printzero:
896 /*
897 * Printing '0' with fieldwidth 0 results in no chars.
898 */
899 fa.lzero = -1;
900 if (fa.signific >= 0)
901 fa.fillc = ' ';
902 count += prstring("0", &fa);
903 continue;
904 } else switch (mode) {
905
906 case 'D':
907#ifdef USE_LONGLONG
908 if (type == 'Q') {
909 if (!unsflag && llval < 0) {
910 fa.prefix = "-";
911 fa.prefixlen = 1;
912 llval = -llval;
913 } else if (fa.flags & PLUSFLG) {
914 fa.prefix = "+";
915 fa.prefixlen = 1;
916 } else if (fa.flags & SPACEFLG) {
917 fa.prefix = " ";
918 fa.prefixlen = 1;
919 }
920 if (llval == 0)
921 goto printzero;
922 goto prunsigned;
923 }
924#endif
925 if (!unsflag && val < 0) {
926 fa.prefix = "-";
927 fa.prefixlen = 1;
928 val = -val;
929 } else if (fa.flags & PLUSFLG) {
930 fa.prefix = "+";
931 fa.prefixlen = 1;
932 } else if (fa.flags & SPACEFLG) {
933 fa.prefix = " ";
934 fa.prefixlen = 1;
935 }
936 if (val == 0)
937 goto printzero;
938 /* FALLTHRU */
939 case 'U':
940 /* output a long unsigned decimal number */
941#ifdef USE_LONGLONG
942 prunsigned:
943 if (type == 'Q')
944 prldnum(llval, &fa);
945 else
946#endif
947 prdnum(val, &fa);
948 break;
949 case 'O':
950 /* output a long octal number */
951 if (fa.flags & HASHFLG) {
952 fa.prefix = "0";
953 fa.prefixlen = 1;
954 }
955#ifdef USE_LONGLONG
956 if (type == 'Q') {
957 prlonum(llval, &fa);
958 } else
959#endif
960 {
961 pronum(val & 07, &fa);
962 if ((res = (val>>3) & rshiftmask(long, 3)) != 0)
963 pronum(res, &fa);
964 }
965 break;
966 case 'p':
967 case 'x':
968 /* output a hex long */
969 if (fa.flags & HASHFLG) {
970 fa.prefix = "0x";
971 fa.prefixlen = 2;
972 }
973#ifdef USE_LONGLONG
974 if (type == 'Q')
975 prlxnum(llval, &fa);
976 else
977#endif
978 {
979 prxnum(val & 0xF, &fa);
980 if ((res = (val>>4) & rshiftmask(long, 4)) != 0)
981 prxnum(res, &fa);
982 }
983 break;
984 case 'P':
985 case 'X':
986 /* output a hex long */
987 if (fa.flags & HASHFLG) {
988 fa.prefix = "0X";
989 fa.prefixlen = 2;
990 }
991#ifdef USE_LONGLONG
992 if (type == 'Q')
993 prlXnum(llval, &fa);
994 else
995#endif
996 {
997 prXnum(val & 0xF, &fa);
998 if ((res = (val>>4) & rshiftmask(long, 4)) != 0)
999 prXnum(res, &fa);
1000 }
1001 break;
1002 case 'Z':
1003 /* output a binary long */
1004#ifdef USE_LONGLONG
1005 if (type == 'Q')
1006 prlnum(llval, 2, &fa);
1007 else
1008#endif
1009 {
1010 prnum(val & 0x1, 2, &fa);
1011 if ((res = (val>>1) & rshiftmask(long, 1)) != 0)
1012 prnum(res, 2, &fa);
1013 }
1014 }
1015 fa.lzero = -1;
1016 /*
1017 * If a precision (fielwidth) is specified
1018 * on diouXx conversions, the '0' flag is ignored.
1019 */
1020 if (fa.signific >= 0)
1021 fa.fillc = ' ';
1022 count += prbuf(fa.bufp, &fa);
1023 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned char
Definition: typeof.h:29
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
EXPORT int ftoes(register char *s, MDOUBLE val, register int fieldwidth, register int ndigits)
Definition: fconv.c:209
EXPORT int ftofs(register char *s, MDOUBLE val, register int fieldwidth, register int ndigits)
Definition: fconv.c:290
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLfloat * val
Definition: glext.h:7180
GLuint GLuint num
Definition: glext.h:9618
_CRTIMP char *__cdecl gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char *_DstBuf)
POINT cp
Definition: magnifier.c:59
static const WCHAR sp[]
Definition: suminfo.c:287
_Out_ LPRECT prc
Definition: ntgdi.h:1658
static FILE * out
Definition: regtests2xml.c:44
const WCHAR * str
LOCAL void prlonum(Ullong val, f_args *fa)
Definition: format.c:1155
#define HASHFLG
Definition: format.c:165
#define cap_ty(c)
Definition: format.c:125
Llong llval
Definition: format.c:276
va_lists_t sargs
Definition: format.c:283
#define APOFLG
Definition: format.c:166
LOCAL void prnum(Ulong val, unsigned base, f_args *fa)
Definition: format.c:1044
#define CHECKFLAG()
Definition: format.c:81
#define GOTSTAR
Definition: format.c:168
register int unsflag
Definition: format.c:264
LOCAL void pronum(Ulong val, f_args *fa)
Definition: format.c:1078
LOCAL void prXnum(Ulong val, f_args *fa)
Definition: format.c:1108
char * rfmt
Definition: format.c:279
BOOL didlist
Definition: format.c:286
LOCAL int prbuf(const char *s, f_args *fa)
Definition: format.c:1205
#define to_cap(c)
Definition: format.c:124
#define INTMASK
Definition: format.c:106
#define SHORTMASK
Definition: format.c:105
LOCAL void prldnum(Ullong val, f_args *fa)
Definition: format.c:1140
#define MINUSFLG
Definition: format.c:162
#define FARG
Definition: format.c:240
LOCAL void prlnum(Ullong val, unsigned base, f_args *fa)
Definition: format.c:1124
const char * ofmt
Definition: format.c:285
LOCAL void prlXnum(Ullong val, f_args *fa)
Definition: format.c:1185
#define ofun(c, fp)
Definition: format.c:234
#define GOTDOT
Definition: format.c:167
LOCAL int prstring(const char *s, f_args *fa)
Definition: format.c:1308
#define CHARMASK
Definition: format.c:104
#define FORMAT_FUNC_NAME
Definition: format.c:227
LOCAL void prxnum(Ulong val, f_args *fa)
Definition: format.c:1093
#define PLUSFLG
Definition: format.c:163
EXPORT void _fmtarglist(char *fmt, va_lists_t fargs, arglist) const
Definition: format.c:1390
double dval
Definition: format.c:274
#define SPACEFLG
Definition: format.c:164
short sh
Definition: format.c:272
#define FORMAT_FUNC_KR_ARGS
Definition: format.c:232
EXPORT void _fmtgetarg(char *fmt, int num, va_lists_t *fargs) const
Definition: format.c:1691
LOCAL void prdnum(Ulong val, f_args *fa)
Definition: format.c:1060
#define rshiftmask(t, s)
Definition: format.c:102
LOCAL void prlxnum(Ullong val, f_args *fa)
Definition: format.c:1170
EXPORT int FORMAT_FUNC_KR_DECL register void * farg
Definition: format.c:253
f_args fa
Definition: format.c:280
Definition: match.c:390
int lzero
Definition: format.c:148
char * buf
Definition: format.c:149
char * bufp
Definition: format.c:150
int prefixlen
Definition: format.c:153
int fldwidth
Definition: format.c:146
int minusflag
Definition: format.c:144
char * prefix
Definition: format.c:152
char fillc
Definition: format.c:151
int signific
Definition: format.c:147
int flags
Definition: format.c:145
Definition: dhcpd.h:62
LOCAL int checkfmt(char *fmt) const
Definition: getargs.c:1297

◆ prbuf()

LOCAL int prbuf ( const char s,
f_args fa 
)

Definition at line 1205 of file format.c.

1208{
1209 register int diff;
1210 register int rfillc;
1211 register void *arg = fa->farg;
1212#ifdef FORMAT_FUNC_PARM
1213 register void (*fun) __PR((char, void *)) = fa->outf;
1214#endif
1215 register int count;
1216 register int lzero = 0;
1217
1218 count = strlen(s);
1219
1220 /*
1221 * lzero becomes the number of left fill chars needed to reach signific
1222 */
1223 if (fa->lzero < 0 && count < fa->signific)
1224 lzero = fa->signific - count;
1225 count += lzero + fa->prefixlen;
1226 diff = fa->fldwidth - count;
1227 if (diff > 0)
1228 count += diff;
1229
1230 if (fa->prefixlen && fa->fillc != ' ') {
1231 while (*fa->prefix != '\0')
1232 ofun(*fa->prefix++, arg);
1233 }
1234 if (!fa->minusflag) {
1235 rfillc = fa->fillc;
1236 while (--diff >= 0)
1237 ofun(rfillc, arg);
1238 }
1239 if (fa->prefixlen && fa->fillc == ' ') {
1240 while (*fa->prefix != '\0')
1241 ofun(*fa->prefix++, arg);
1242 }
1243 if (lzero > 0) {
1244 rfillc = '0';
1245 while (--lzero >= 0)
1246 ofun(rfillc, arg);
1247 }
1248 while (*s != '\0')
1249 ofun(*s++, arg);
1250 if (fa->minusflag) {
1251 rfillc = ' ';
1252 while (--diff >= 0)
1253 ofun(rfillc, arg);
1254 }
1255 return (count);
1256}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLdouble s
Definition: gl.h:2039
#define __PR(a)
Definition: prototyp.h:106
void * farg
Definition: format.c:143

Referenced by for(), and prstring().

◆ prc()

LOCAL int prc ( char  c,
f_args fa 
)

Definition at line 1270 of file format.c.

1274{
1275 register int diff;
1276 register int rfillc;
1277 register void *arg = fa->farg;
1278#ifdef FORMAT_FUNC_PARM
1279 register void (*fun) __PR((char, void *)) = fa->outf;
1280#endif
1281 register int count;
1282
1283 count = 1;
1284 diff = fa->fldwidth - 1;
1285 if (diff > 0)
1286 count += diff;
1287
1288 if (!fa->minusflag) {
1289 rfillc = fa->fillc;
1290 while (--diff >= 0)
1291 ofun(rfillc, arg);
1292 }
1293 ofun(c, arg);
1294 if (fa->minusflag) {
1295 rfillc = ' ';
1296 while (--diff >= 0)
1297 ofun(rfillc, arg);
1298 }
1299 return (count);
1300}

◆ prdnum()

LOCAL void prdnum ( Ulong  val,
f_args fa 
)

Definition at line 1060 of file format.c.

1063{
1064 register char *p = fa->bufp;
1065
1066 do {
1067 *--p = dtab[modlbys(val, (unsigned)10)];
1068 val = divlbys(val, (unsigned)10);
1069 } while (val > 0);
1070
1071 fa->bufp = p;
1072}
GLfloat GLfloat p
Definition: glext.h:8902
#define modlbys(val, base)
Definition: format.c:114
#define divlbys(val, base)
Definition: format.c:113
LOCAL unsigned char dtab[]
Definition: format.c:1040

Referenced by for().

◆ prldnum()

LOCAL void prldnum ( Ullong  val,
f_args fa 
)

Definition at line 1140 of file format.c.

1143{
1144 register char *p = fa->bufp;
1145
1146 do {
1147 *--p = dtab[val % (unsigned)10];
1148 val = val / (unsigned)10;
1149 } while (val > 0);
1150
1151 fa->bufp = p;
1152}
static unsigned(__cdecl *hash_bstr)(bstr_t s)

Referenced by for().

◆ prlnum()

LOCAL void prlnum ( Ullong  val,
unsigned  base,
f_args fa 
)

Definition at line 1124 of file format.c.

1128{
1129 register char *p = fa->bufp;
1130
1131 do {
1132 *--p = dtab[modlbys(val, base)];
1133 val = divlbys(val, base);
1134 } while (val > 0);
1135
1136 fa->bufp = p;
1137}

Referenced by for().

◆ prlonum()

LOCAL void prlonum ( Ullong  val,
f_args fa 
)

Definition at line 1155 of file format.c.

1158{
1159 register char *p = fa->bufp;
1160
1161 do {
1162 *--p = dtab[val & 7];
1163 val >>= 3;
1164 } while (val > 0);
1165
1166 fa->bufp = p;
1167}

Referenced by for().

◆ prlxnum()

LOCAL void prlxnum ( Ullong  val,
f_args fa 
)

Definition at line 1170 of file format.c.

1173{
1174 register char *p = fa->bufp;
1175
1176 do {
1177 *--p = dtab[val & 15];
1178 val >>= 4;
1179 } while (val > 0);
1180
1181 fa->bufp = p;
1182}

Referenced by for().

◆ prlXnum()

LOCAL void prlXnum ( Ullong  val,
f_args fa 
)

Definition at line 1185 of file format.c.

1188{
1189 register char *p = fa->bufp;
1190
1191 do {
1192 *--p = udtab[val & 15];
1193 val >>= 4;
1194 } while (val > 0);
1195
1196 fa->bufp = p;
1197}
LOCAL unsigned char udtab[]
Definition: format.c:1041

Referenced by for().

◆ prnum()

LOCAL void prnum ( Ulong  val,
unsigned  base,
f_args fa 
)

Definition at line 1044 of file format.c.

1048{
1049 register char *p = fa->bufp;
1050
1051 do {
1052 *--p = dtab[modlbys(val, base)];
1053 val = divlbys(val, base);
1054 } while (val > 0);
1055
1056 fa->bufp = p;
1057}

Referenced by for().

◆ pronum()

LOCAL void pronum ( Ulong  val,
f_args fa 
)

Definition at line 1078 of file format.c.

1081{
1082 register char *p = fa->bufp;
1083
1084 do {
1085 *--p = dtab[val & 7];
1086 val >>= 3;
1087 } while (val > 0);
1088
1089 fa->bufp = p;
1090}

Referenced by for().

◆ prstring()

LOCAL int prstring ( const char s,
f_args fa 
)

Definition at line 1308 of file format.c.

1311{
1312 register char *bp;
1313 register int signific;
1314
1315 if (s == NULL)
1316 return (prbuf("(NULL POINTER)", fa));
1317
1318 if (fa->signific < 0)
1319 return (prbuf(s, fa));
1320
1321 bp = fa->buf;
1322 signific = fa->signific;
1323
1324 while (--signific >= 0 && *s != '\0')
1325 *bp++ = *s++;
1326 *bp = '\0';
1327
1328 return (prbuf(fa->buf, fa));
1329}

Referenced by for().

◆ prxnum()

LOCAL void prxnum ( Ulong  val,
f_args fa 
)

Definition at line 1093 of file format.c.

1096{
1097 register char *p = fa->bufp;
1098
1099 do {
1100 *--p = dtab[val & 15];
1101 val >>= 4;
1102 } while (val > 0);
1103
1104 fa->bufp = p;
1105}

Referenced by for().

◆ prXnum()

LOCAL void prXnum ( Ulong  val,
f_args fa 
)

Definition at line 1108 of file format.c.

1111{
1112 register char *p = fa->bufp;
1113
1114 do {
1115 *--p = udtab[val & 15];
1116 val >>= 4;
1117 } while (val > 0);
1118
1119 fa->bufp = p;
1120}

Referenced by for().

◆ va_copy()

va_copy ( sargs.  ap,
oargs   
)

Variable Documentation

◆ __pad0__

out __pad0__

Definition at line 1024 of file format.c.

◆ arglist

◆ c

register char c

Definition at line 268 of file format.c.

Referenced by _fmtarglist(), and for().

◆ count

count = 0

Definition at line 269 of file format.c.

◆ didlist

BOOL didlist = FALSE

Definition at line 286 of file format.c.

Referenced by for().

◆ digits

const char* digits = &skips[8]
static

Definition at line 1378 of file format.c.

Referenced by _fmtarglist().

◆ dtab

LOCAL unsigned char dtab[] = "0123456789abcdef"

Definition at line 1040 of file format.c.

Referenced by prdnum(), prldnum(), prlnum(), prlonum(), prlxnum(), prnum(), pronum(), and prxnum().

◆ dval

double dval

Definition at line 274 of file format.c.

Referenced by for(), and tinyxml2::XMLElement::QueryDoubleText().

◆ fa

◆ farg

fa farg = farg

Definition at line 253 of file format.c.

Referenced by for().

◆ fargs

fargs = sargs

Definition at line 282 of file format.c.

Referenced by _fmtarglist(), and for().

◆ fmt

register char* fmt

Definition at line 254 of file format.c.

Referenced by _fmtarglist(), _fmtgetarg(), and for().

◆ i

int i

Definition at line 271 of file format.c.

◆ llval

Llong llval = 0

Definition at line 276 of file format.c.

Referenced by doflag(), for(), and test_intconversions().

◆ mode

register char mode

Definition at line 267 of file format.c.

◆ num

Definition at line 270 of file format.c.

Referenced by _fmtgetarg(), and for().

◆ oargs

va_list oargs

Definition at line 255 of file format.c.

Referenced by compound_encode_send_decode(), doflag(), and dosflags().

◆ ofmt

const char* ofmt = fmt

Definition at line 285 of file format.c.

Referenced by for(), and optend().

◆ outf

fa outf = fun

Definition at line 301 of file format.c.

Referenced by printline(), and proclog().

◆ res

Definition at line 278 of file format.c.

◆ rfmt

char* rfmt

Definition at line 279 of file format.c.

Referenced by for().

◆ sargs

va_lists_t sargs

Definition at line 283 of file format.c.

Referenced by for().

◆ sfmt

const char* sfmt
Initial value:
{
char buf[8192]

Definition at line 263 of file format.c.

Referenced by _fmtgetarg(), doflag(), and for().

◆ sh

◆ skips

const char skips[] = "+- #'.$h1234567890"
static

Definition at line 1377 of file format.c.

Referenced by _fmtarglist().

◆ str

const char* str

Definition at line 273 of file format.c.

◆ type

register char type

Definition at line 266 of file format.c.

◆ udtab

LOCAL unsigned char udtab[] = "0123456789ABCDEF"

Definition at line 1041 of file format.c.

Referenced by prlXnum(), and prXnum().

◆ unsflag

register int unsflag

Definition at line 264 of file format.c.

Referenced by for().

◆ val

register long val

Definition at line 265 of file format.c.