ReactOS  r76032
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 void
farg = 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

#define AF_LONG   1

Definition at line 1372 of file format.c.

Referenced by _fmtarglist().

#define AF_LONG_DOUBLE   4

Definition at line 1374 of file format.c.

Referenced by _fmtarglist().

#define AF_LONG_LONG   2

Definition at line 1373 of file format.c.

Referenced by _fmtarglist().

#define AF_NONE   0

Definition at line 1371 of file format.c.

Referenced by _fmtarglist().

#define AF_STAR   8

Definition at line 1375 of file format.c.

Referenced by _fmtarglist().

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

Definition at line 100 of file format.c.

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

Definition at line 166 of file format.c.

Referenced by for().

#define args   fargs.ap /* Use working copy */

Definition at line 66 of file format.c.

Referenced by __report_error(), _mesa_debug(), _mesa_error(), _mesa_problem(), _mesa_snprintf(), _mesa_warning(), _snprintf(), _texecl(), _texecle(), _texeclp(), _texeclpe(), _tspawnl(), _tspawnle(), _tspawnlp(), _tspawnlpe(), _tspawnv(), _tspawnve(), CRegistryTree::AddErrorDescription(), AddToSendBuffer(), asmparser_message(), AVISplitter_first_request(), BaseInputPinImpl_NewSegment(), call_varargs(), cmd_rename(), cmd_rmdir(), comerr(), comerrno(), CommandDelete(), ConMsgPrintf(), ConPrintf(), ConResPrintf(), ConResPrintfEx(), convert_old_args(), CreateSnapshotW(), CreateSubvolW(), DbgP(), DbgPrint(), DbgPrintEarly(), anonymous_namespace{mstscax.cpp}::dbgprintf(), debug_printf(), DebugFunction(), DebugPrint(), die_func(), DispCallFunc(), DisplayMessage(), doc_complex_write(), doflag(), 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(), hlsl_message(), hlsl_report_message(), incomplete(), indent_printf(), InfoMessageBox(), init_arginfo(), install_wine_gecko(), invoke_procedure(), CShellLink::InvokeCommand(), ITERATE_StartService(), js_error(), js_fprintf(), js_printf(), js_snprintf(), LIBXML_ATTR_FORMAT(), LIBXSLT_ATTR_FORMAT(), LoadAndPrintString(), logmsg(), MCI_GetString(), MCI_ParseOptArgs(), mciSendStringW(), mp_clear_multi(), mp_init_multi(), msi_service_args_to_vector(), CBandProxy::NavigateToPIDL(), NdrAsyncClientCall(), NdrClientCall2(), NdrMesProcEncodeDecode(), NdrStubCall2(), nfs41_delegation_recall(), notify_webbrowser_close(), parse_arguments(), parse_event_elem(), ParseNoTildeEffect(), ParseTildeEffect(), pdie_func(), PICE_sprintf(), picture_render(), populate_definition(), pp_add_macro(), print_error(), printf(), PRINTF_ATTR(), printk(), PrintkCallback(), PrintMessageAnsi(), PrintParserError(), pSetupDebugPrint(), PullPin_NewSegment(), put_str(), RecvSubvolW(), ReflinkCopyW(), register_dlls_callback(), remglob(), SendSubvolW(), 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(), StartScrubW(), StopScrubW(), str_printf(), string_buffer_sprintf(), symbol_demangle(), T42_Face_Init(), test_commandline2argv(), test_disp(), test_Invoke(), test_invoke_func(), test_ShellExecute(), test_TypeInfo(), TMStubImpl_Invoke(), tokenizeCommand(), TRIO_VARGS2(), TRIO_VARGS3(), TRIO_VARGS4(), type_new_function(), UnderlinedResPrintf(), VfatPrint(), write_status(), xcomerr(), xcomerrno(), xmlGenericErrorDefaultFunc(), and xmlStrPrintf().

#define AT_BOUNDS   14

Definition at line 1369 of file format.c.

Referenced by _fmtarglist().

#define AT_CHAR_PTR   7

Definition at line 1362 of file format.c.

Referenced by _fmtarglist().

#define AT_DOUBLE   4

Definition at line 1359 of file format.c.

Referenced by _fmtarglist().

#define AT_INT   1

Definition at line 1356 of file format.c.

Referenced by _fmtarglist().

#define AT_INT_PTR   9

Definition at line 1364 of file format.c.

Referenced by _fmtarglist().

#define AT_LONG   2

Definition at line 1357 of file format.c.

Referenced by _fmtarglist().

#define AT_LONG_DOUBLE   5

Definition at line 1360 of file format.c.

Referenced by _fmtarglist().

#define AT_LONG_LONG   3

Definition at line 1358 of file format.c.

Referenced by _fmtarglist().

#define AT_LONG_LONG_PTR   11

Definition at line 1366 of file format.c.

Referenced by _fmtarglist().

#define AT_LONG_PTR   10

Definition at line 1365 of file format.c.

Referenced by _fmtarglist().

#define AT_NONE   0

Definition at line 1355 of file format.c.

Referenced by _fmtarglist().

#define AT_R_FMT   12

Definition at line 1367 of file format.c.

Referenced by _fmtarglist().

#define AT_R_VA_LIST   13

Definition at line 1368 of file format.c.

Referenced by _fmtarglist().

#define AT_SHORT_PTR   8

Definition at line 1363 of file format.c.

Referenced by _fmtarglist().

#define AT_VOID_PTR   6

Definition at line 1361 of file format.c.

Referenced by _fmtarglist().

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

Definition at line 125 of file format.c.

Referenced by for().

#define CHARMASK   makemask(char)

Definition at line 104 of file format.c.

Referenced by for().

#define CHECKFLAG ( )

Definition at line 81 of file format.c.

Referenced by for().

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

Definition at line 113 of file format.c.

Referenced by prdnum(), prlnum(), and prnum().

#define FARG   farg

Definition at line 240 of file format.c.

Referenced by for().

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

Definition at line 170 of file format.c.

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

#define FORMAT_FUNC_KR_ARGS   fun,

Definition at line 232 of file format.c.

Referenced by for().

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

Definition at line 231 of file format.c.

#define FORMAT_FUNC_NAME   format

Definition at line 227 of file format.c.

Referenced by for().

#define FORMAT_FUNC_PARM

Definition at line 228 of file format.c.

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

Definition at line 230 of file format.c.

#define FORMAT_IMPL

Definition at line 193 of file format.c.

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

Definition at line 167 of file format.c.

Referenced by for().

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

Definition at line 168 of file format.c.

Referenced by for().

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

Definition at line 165 of file format.c.

Referenced by for().

#define INTMASK   makemask(int)

Definition at line 106 of file format.c.

Referenced by for().

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

Definition at line 123 of file format.c.

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

Definition at line 122 of file format.c.

Referenced by _fmtarglist(), and for().

#define LONGMASK   makemask(long)

Definition at line 107 of file format.c.

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

Definition at line 101 of file format.c.

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

Definition at line 162 of file format.c.

Referenced by for().

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

Definition at line 114 of file format.c.

Referenced by prdnum(), prlnum(), and prnum().

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

Definition at line 234 of file format.c.

Referenced by for(), prbuf(), and prc().

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

Definition at line 163 of file format.c.

Referenced by for().

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

Definition at line 102 of file format.c.

Referenced by for().

#define SHORTMASK   makemask(short)

Definition at line 105 of file format.c.

Referenced by for().

#define SPACEFLG   4 /* ' ' flag */

Definition at line 164 of file format.c.

Referenced by for().

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

Definition at line 124 of file format.c.

Referenced by for().

#define USE_LONGLONG

Definition at line 45 of file format.c.

#define USE_NL_ARGS

Definition at line 53 of file format.c.

Typedef Documentation

typedef struct f_args f_args

Function Documentation

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

Referenced by prbuf(), and prc().

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 ( char fmt,
va_lists_t  fargs,
arglist   
) const

Definition at line 1390 of file format.c.

Referenced by for().

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
1453 error 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
1471 error 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;
1671  (void) __va_arg_list(fargs.ap);
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 }
#define AF_NONE
Definition: format.c:1371
#define AT_LONG_PTR
Definition: format.c:1365
#define AT_INT
Definition: format.c:1356
long Llong
Definition: stdint.h:152
#define AF_LONG
Definition: format.c:1372
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
_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
#define AT_LONG_DOUBLE
Definition: format.c:1360
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
smooth NULL
Definition: ftsmooth.c:557
register char * fmt
Definition: format.c:254
__kernel_size_t size_t
Definition: linux.h:237
register char c
Definition: format.c:268
static const char skips[]
Definition: format.c:1377
Definition: id3.c:18
#define AF_LONG_LONG
Definition: format.c:1373
#define AT_CHAR_PTR
Definition: format.c:1362
#define FMT_ARGMAX
Definition: format.c:170
#define AT_LONG
Definition: format.c:1357
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define AT_R_FMT
Definition: format.c:1367
#define is_dig(c)
Definition: format.c:122
#define AT_VOID_PTR
Definition: format.c:1361
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define AT_INT_PTR
Definition: format.c:1364
#define __va_arg_list(list)
Definition: varargs.h:123
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define AT_R_VA_LIST
Definition: format.c:1368
static const char * digits
Definition: format.c:1378
#define AF_STAR
Definition: format.c:1375
int i
Definition: format.c:271
#define AT_LONG_LONG_PTR
Definition: format.c:1366
#define AT_SHORT_PTR
Definition: format.c:1363
#define AT_LONG_LONG
Definition: format.c:1358
#define AT_BOUNDS
Definition: format.c:1369
#define AT_DOUBLE
Definition: format.c:1359
va_list ap
Definition: varargs.h:133
Definition: dsound.c:958
#define AT_NONE
Definition: format.c:1355
va_lists_t arglist[FMT_ARGMAX+1]
Definition: format.c:284
EXPORT void _fmtgetarg ( char fmt,
int  num,
va_lists_t fargs 
) const

Definition at line 1691 of file format.c.

Referenced by for().

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:257
int num
Definition: format.c:270
register char * fmt
Definition: format.c:254
#define FMT_ARGMAX
Definition: format.c:170
#define va_arg(ap, T)
Definition: acmsvcex.h:89
int i
Definition: format.c:271
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) {
400  fa.fldwidth = -fa.fldwidth;
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) {
469  fa.fldwidth = -fa.fldwidth;
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
570 error 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
589 error 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);
745  (void) gcvt(dval, fa.signific, buf);
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':
880  llval = va_arg(args, Llong);
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  }
LOCAL void prXnum(Ulong val, f_args *fa)
Definition: format.c:1108
#define TRUE
Definition: types.h:120
LOCAL void prlonum(Ullong val, f_args *fa)
Definition: format.c:1155
register int unsflag
Definition: format.c:264
long Llong
Definition: stdint.h:152
#define MINUSFLG
Definition: format.c:162
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define SHORTMASK
Definition: format.c:105
char * buf
Definition: format.c:149
BOOL didlist
Definition: format.c:286
#define PLUSFLG
Definition: format.c:163
char * rfmt
Definition: format.c:279
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int count
Definition: format.c:269
#define ofun(c, fp)
Definition: format.c:234
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define CHARMASK
Definition: format.c:104
#define CHECKFLAG()
Definition: format.c:81
int prefixlen
Definition: format.c:153
Definition: match.c:390
const char * sfmt
Definition: format.c:257
EXPORT void _fmtgetarg(char *fmt, int num, va_lists_t *fargs) const
Definition: format.c:1691
#define cap_ty(c)
Definition: format.c:125
#define FORMAT_FUNC_KR_ARGS
Definition: format.c:232
#define to_cap(c)
Definition: format.c:124
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
int signific
Definition: format.c:147
#define APOFLG
Definition: format.c:166
#define FALSE
Definition: types.h:117
va_lists_t fargs
Definition: format.c:282
LOCAL void prdnum(Ulong val, f_args *fa)
Definition: format.c:1060
EXPORT int ftoes(register char *s, MDOUBLE val, register int fieldwidth, register int ndigits)
Definition: fconv.c:209
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
LOCAL void prlnum(Ullong val, unsigned base, f_args *fa)
Definition: format.c:1124
unsigned char
Definition: typeof.h:27
int num
Definition: format.c:270
EXPORT int FORMAT_FUNC_KR_DECL register void * farg
Definition: format.c:253
register char * fmt
Definition: format.c:254
GLuint GLfloat * val
Definition: glext.h:7180
int flags
Definition: format.c:145
__kernel_size_t size_t
Definition: linux.h:237
int lzero
Definition: format.c:148
register char c
Definition: format.c:268
Llong llval
Definition: format.c:276
LOCAL void prlXnum(Ullong val, f_args *fa)
Definition: format.c:1185
double dval
Definition: format.c:274
#define GOTDOT
Definition: format.c:167
Definition: dhcpd.h:61
EXPORT void _fmtarglist(char *fmt, va_lists_t fargs, arglist) const
Definition: format.c:1390
const GLubyte * c
Definition: glext.h:8905
static FILE * out
Definition: regtests2xml.c:44
GLuint GLuint num
Definition: glext.h:9618
#define FORMAT_FUNC_NAME
Definition: format.c:227
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define SPACEFLG
Definition: format.c:164
char fillc
Definition: format.c:151
Definition: id3.c:18
LOCAL int prc(char c, f_args *fa)
Definition: format.c:1270
char * prefix
Definition: format.c:152
int minusflag
Definition: format.c:144
const char * ofmt
Definition: format.c:285
#define GOTSTAR
Definition: format.c:168
#define INTMASK
Definition: format.c:106
#define FMT_ARGMAX
Definition: format.c:170
LOCAL void prxnum(Ulong val, f_args *fa)
Definition: format.c:1093
va_lists_t sargs
Definition: format.c:283
EXPORT int ftofs(register char *s, MDOUBLE val, register int fieldwidth, register int ndigits)
Definition: fconv.c:290
int fldwidth
Definition: format.c:146
short sh
Definition: format.c:272
const char * str
Definition: format.c:273
#define va_arg(ap, T)
Definition: acmsvcex.h:89
LOCAL void prldnum(Ullong val, f_args *fa)
Definition: format.c:1140
#define FARG
Definition: format.c:240
#define is_dig(c)
Definition: format.c:122
char * bufp
Definition: format.c:150
#define HASHFLG
Definition: format.c:165
LOCAL int prbuf(const char *s, f_args *fa)
Definition: format.c:1205
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define __va_arg_list(list)
Definition: varargs.h:123
#define rshiftmask(t, s)
Definition: format.c:102
char * strchr(const char *String, int ch)
Definition: utclib.c:501
LOCAL int prstring(const char *s, f_args *fa)
Definition: format.c:1308
POINT cp
Definition: magnifier.c:58
GLuint res
Definition: glext.h:9613
int i
Definition: format.c:271
LOCAL void prlxnum(Ullong val, f_args *fa)
Definition: format.c:1170
static const WCHAR sp[]
Definition: suminfo.c:288
register long val
Definition: format.c:265
_CRTIMP char *__cdecl gcvt(_In_ double _Val, _In_ int _NumOfDigits, _Pre_notnull_ _Post_z_ char *_DstBuf)
va_list ap
Definition: varargs.h:133
Definition: dsound.c:958
LOCAL int checkfmt(char *fmt) const
Definition: getargs.c:1297
LOCAL void pronum(Ulong val, f_args *fa)
Definition: format.c:1078
LOCAL void prnum(Ulong val, unsigned base, f_args *fa)
Definition: format.c:1044
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
va_lists_t arglist[FMT_ARGMAX+1]
Definition: format.c:284
f_args fa
Definition: format.c:280
LOCAL int prbuf ( const char s,
f_args fa 
)

Definition at line 1205 of file format.c.

Referenced by for(), and prstring().

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
int count
Definition: format.c:269
#define ofun(c, fp)
Definition: format.c:234
int prefixlen
Definition: format.c:153
int signific
Definition: format.c:147
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int lzero
Definition: format.c:148
GLuint GLuint GLsizei count
Definition: gl.h:1545
char fillc
Definition: format.c:151
char * prefix
Definition: format.c:152
int minusflag
Definition: format.c:144
GLdouble s
Definition: gl.h:2039
int fldwidth
Definition: format.c:146
char *gcvt __PR((double, int, char *))
void * farg
Definition: format.c:143
fa outf
Definition: format.c:301
LOCAL int prc ( char  c,
f_args fa 
)

Definition at line 1270 of file format.c.

Referenced by for().

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 }
int count
Definition: format.c:269
#define ofun(c, fp)
Definition: format.c:234
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
const GLubyte * c
Definition: glext.h:8905
char fillc
Definition: format.c:151
int minusflag
Definition: format.c:144
int fldwidth
Definition: format.c:146
char *gcvt __PR((double, int, char *))
void * farg
Definition: format.c:143
fa outf
Definition: format.c:301
LOCAL void prdnum ( Ulong  val,
f_args fa 
)

Definition at line 1060 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
#define modlbys(val, base)
Definition: format.c:114
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
#define divlbys(val, base)
Definition: format.c:113
LOCAL void prldnum ( Ullong  val,
f_args fa 
)

Definition at line 1140 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
LOCAL void prlnum ( Ullong  val,
unsigned  base,
f_args fa 
)

Definition at line 1124 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
#define modlbys(val, base)
Definition: format.c:114
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
#define divlbys(val, base)
Definition: format.c:113
LOCAL void prlonum ( Ullong  val,
f_args fa 
)

Definition at line 1155 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
LOCAL void prlxnum ( Ullong  val,
f_args fa 
)

Definition at line 1170 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
LOCAL void prlXnum ( Ullong  val,
f_args fa 
)

Definition at line 1185 of file format.c.

Referenced by for().

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 }
GLuint GLfloat * val
Definition: glext.h:7180
LOCAL unsigned char udtab[]
Definition: format.c:1041
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
LOCAL void prnum ( Ulong  val,
unsigned  base,
f_args fa 
)

Definition at line 1044 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
#define modlbys(val, base)
Definition: format.c:114
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
#define divlbys(val, base)
Definition: format.c:113
LOCAL void pronum ( Ulong  val,
f_args fa 
)

Definition at line 1078 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
LOCAL int prstring ( const char s,
f_args fa 
)

Definition at line 1308 of file format.c.

Referenced by for().

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 }
char * buf
Definition: format.c:149
int signific
Definition: format.c:147
smooth NULL
Definition: ftsmooth.c:557
GLdouble s
Definition: gl.h:2039
LOCAL int prbuf(const char *s, f_args *fa)
Definition: format.c:1205
LOCAL void prxnum ( Ulong  val,
f_args fa 
)

Definition at line 1093 of file format.c.

Referenced by for().

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 }
LOCAL unsigned char dtab[]
Definition: format.c:1040
GLuint GLfloat * val
Definition: glext.h:7180
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
LOCAL void prXnum ( Ulong  val,
f_args fa 
)

Definition at line 1108 of file format.c.

Referenced by for().

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 }
GLuint GLfloat * val
Definition: glext.h:7180
LOCAL unsigned char udtab[]
Definition: format.c:1041
char * bufp
Definition: format.c:150
GLfloat GLfloat p
Definition: glext.h:8902
va_copy ( sargs.  ap,
oargs   
)

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

Variable Documentation

out __pad0__

Definition at line 1034 of file format.c.

va_lists_t arglist[FMT_ARGMAX+1]

Definition at line 284 of file format.c.

Referenced by _beginthread(), and TRIO_VARGS3().

register char c

Definition at line 268 of file format.c.

Referenced by _fmtarglist(), and for().

count = 0

Definition at line 269 of file format.c.

Referenced by build_default_format(), conv_s16_to_u16(), conv_s32_to_u32(), for(), prbuf(), and prc().

BOOL didlist = FALSE

Definition at line 286 of file format.c.

const char* digits = &skips[8]
static

Definition at line 1378 of file format.c.

LOCAL unsigned char dtab[] = "0123456789abcdef"

Definition at line 1040 of file format.c.

double dval

Definition at line 274 of file format.c.

fa farg = farg

Definition at line 253 of file format.c.

fargs = sargs

Definition at line 282 of file format.c.

Referenced by _fmtarglist().

register char* fmt

Definition at line 254 of file format.c.

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

Llong llval = 0

Definition at line 276 of file format.c.

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

register char mode

Definition at line 267 of file format.c.

Definition at line 270 of file format.c.

Referenced by _fmtgetarg(), and for().

va_list oargs

Definition at line 255 of file format.c.

Referenced by compound_encode_send_decode().

const char* ofmt = fmt

Definition at line 285 of file format.c.

Referenced by optend().

fa outf = fun

Definition at line 301 of file format.c.

char* rfmt

Definition at line 279 of file format.c.

va_lists_t sargs

Definition at line 283 of file format.c.

const char* sfmt
Initial value:
{
char buf[8192]
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

Definition at line 257 of file format.c.

Referenced by doflag(), and for().

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

Definition at line 1377 of file format.c.

LOCAL unsigned char udtab[] = "0123456789ABCDEF"

Definition at line 1041 of file format.c.

register int unsflag

Definition at line 264 of file format.c.

register long val

Definition at line 265 of file format.c.

Referenced by deformat_index(), dup_formstr(), and for().