#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/* inline keyword is non-ANSI C7 extension */
/* CONSIDER: move to cruntime.h! */
#if !defined(_MSC_VER) || defined(__STDC__)
#define __inline static
#else
/* UNDONE: compiler is broken */
#define __inline static
#endif
#if defined(WPRFLAG) && !defined(_UNICODE)
#define _UNICODE 1
#endif
#ifdef _MBCS /* always want either Unicode or SBCS for tchar.h */
#undef _MBCS
#endif
#include
/* this macro defines a function which is private and as fast as possible: */
/* for example, in C 6.0, it might be static _fastcall
#define LOCAL(x) static x _CALLTYPE4
/* int/long/short/pointer sizes */
/* the following should be set depending on the sizes of various types */
#define LONG_IS_INT 1 /* 1 means long is same size as int */
#define SHORT_IS_INT 0 /* 1 means short is same size as int */
#define LONGDOUBLE_IS_DOUBLE 1 /* 1 means long double is same as double */
#define PTR_IS_INT 1 /* 1 means ptr is same size as int */
#define PTR_IS_LONG 1 /* 1 means ptr is same size as long */
#if LONG_IS_INT
#define get_long_arg(x) (long)get_int_arg(x)
#endif
#ifndef WPRFLAG
#if SHORT_IS_INT
#define get_short_arg(x) (short)get_int_arg(x)
#endif
#endif
#if PTR_IS_INT
#define get_ptr_arg(x) (void *)get_int_arg(x)
#elif PTR_IS_LONG
#define get_ptr_arg(x) (void *)get_long_arg(x)
#else
#error Size of pointer must be same as size of int or long
/* CONSTANTS */
/* size of conversion buffer (ANSI-specified minimum is 509) */
#define BUFFERSIZE 512
#if (BUFFERSIZE < CVTBUFSIZE)
#error Conversion buffer too small for max double.
#endif
/* flag definitions */
#define FL_SIGN 0x0001 /* put plus or minus in front */
#define FL_SIGNSP 0x0002 /* put space or minus in front */
#define FL_LEFT 0x0004 /* left justify */
#define FL_LEADZERO 0x0008 /* pad with leading zeros */
#define FL_LONG 0x0010 /* long value given */
#define FL_SHORT 0x0020 /* short value given */
#define FL_SIGNED 0x0040 /* signed data given */
#define FL_ALTERNATE 0x0080 /* alternate form requested */
#define FL_NEGATIVE 0x0100 /* value is negative */
#define FL_FORCEOCTAL 0x0200 /* force leading '0' for octals */
#define FL_LONGDOUBLE 0x0400 /* long double value given */
#define FL_WIDECHAR 0x0800 /* wide characters */
/* state definitions */
enum STATE {
ST_NORMAL, /* normal state; outputting literal chars */
ST_PERCENT, /* just read '%' */
ST_FLAG, /* just read flag character */
ST_WIDTH, /* just read width specifier */
ST_DOT, /* just read '.' */
ST_PRECIS, /* just read precision specifier */
ST_SIZE, /* just read size specifier */
ST_TYPE /* just read type specifier */
};
#define NUMSTATES (ST_TYPE + 1)
/* character type values */
enum CHARTYPE {
CH_OTHER, /* character with no special meaning */
CH_PERCENT, /* '%' */
CH_DOT, /* '.' */
CH_STAR, /* '*' */
CH_ZERO, /* '0' */
CH_DIGIT, /* '1'..'9' */
CH_FLAG, /* ' ', '+', '-', '#' */
CH_SIZE, /* 'h', 'l', 'L', 'N', 'F', 'w' */
CH_TYPE /* type specifying character */
};
/* static data (read only, since we are re-entrant) */
#if defined(WPRFLAG) || defined(CPRFLAG)
extern ch