41#define uchar unsigned char
47#define ushort unsigned short
52#define SFSETLOCALE(decimal,thousand) \
53 { struct lconv* lv_; \
56 if((lv_ = localeconv())) \
57 { if(lv_->decimal_point && lv_->decimal_point[0]) \
58 (decimal) = lv_->decimal_point[0]; \
59 if(lv_->thousands_sep && lv_->thousands_sep[0]) \
60 (thousand) = lv_->thousands_sep[0]; \
66#define FP_SET(fp,fn) (fp < 0 ? (fn += 1) : (fn = fp) )
76 unsigned long long lu;
89#define FMTSET(ft, frm, fv, sz, flgs, wid,pr,bs, ts,ns) \
90 ((ft->form = (char*)frm), \
91 (ft->fmt = fv), (ft->size = sz), \
92 (ft->flags = (flgs&SFFMT_SET)), \
93 (ft->width = wid), (ft->precis = pr), (ft->base = bs), \
94 (ft->t_str = ts), (ft->n_str = ns) )
95#define FMTGET(ft, frm, fv, sz, flgs, wid,pr,bs) \
96 ((frm = ft->form), (fv = ft->fmt), (sz = ft->size), \
97 (flgs = (flgs&~(SFFMT_SET))|(ft->flags&SFFMT_SET)), \
98 (wid = ft->width), (pr = ft->precis), (bs = ft->base) )
99#define FMTCMP(sz, type, maxtype) \
100 (sz == sizeof(type) || (sz == 0 && sizeof(type) == sizeof(maxtype)) || \
101 (sz == 64 && sz == sizeof(type)*CHAR_BIT) )
104#define SFFMT_EFORMAT 01000000000
105#define SFFMT_MINUS 02000000000
107#define SFFMT_TYPES (SFFMT_SHORT|SFFMT_SSHORT | SFFMT_LONG|SFFMT_LLONG|\
108 SFFMT_LDOUBLE | SFFMT_IFLAG|SFFMT_JFLAG| \
109 SFFMT_TFLAG | SFFMT_ZFLAG )
113#define SFFMT_UINT 002
114#define SFFMT_FLOAT 004
115#define SFFMT_BYTE 010
116#define SFFMT_POINTER 020
117#define SFFMT_CLASS 040
123#define SF_FDIGITS 256
124#define SF_IDIGITS 1024
125#define SF_MAXDIGITS (((SF_FDIGITS+SF_IDIGITS)/sizeof(int) + 1)*sizeof(int))
128#define _Sfpos10 (_Sftable.sf_pos10)
129#define _Sfneg10 (_Sftable.sf_neg10)
130#define _Sfdec (_Sftable.sf_dec)
131#define _Sfdigits (_Sftable.sf_digits)
132#define _Sfcvinit (_Sftable.sf_cvinit)
133#define _Sffmtintf (_Sftable.sf_fmtintf)
134#define _Sfcv36 (_Sftable.sf_cv36)
135#define _Sfcv64 (_Sftable.sf_cv64)
136#define _Sftype (_Sftable.sf_type)
143 char *(*sf_fmtintf) (
const char *,
int *);
150#define SFDIGIT(v,scale,digit) \
155 else { digit = '1'; v -= 1*scale; } \
156 else if(v < 3*scale) \
157 { digit = '2'; v -= 2*scale; } \
158 else if(v < 4*scale) \
159 { digit = '3'; v -= 3*scale; } \
160 else { digit = '4'; v -= 4*scale; } \
161 else if(v < 7*scale) \
163 { digit = '5'; v -= 5*scale; } \
164 else { digit = '6'; v -= 6*scale; } \
165 else if(v < 8*scale) \
166 { digit = '7'; v -= 7*scale; } \
167 else if(v < 9*scale) \
168 { digit = '8'; v -= 8*scale; } \
169 else { digit = '9'; v -= 9*scale; } \
171#define sfucvt(v,s,n,list,type,utype) \
172 { while((utype)v >= 10000) \
173 { n = v; v = (type)(((utype)v)/10000); \
174 n = (type)((utype)n - ((utype)v)*10000); \
175 s -= 4; SFDIGIT(n,1000,s[0]); SFDIGIT(n,100,s[1]); \
176 s[2] = *(list = (char*)_Sfdec + (n <<= 1)); s[3] = *(list+1); \
180 { s -= 1; s[0] = (char)('0'+v); \
182 { s -= 2; s[0] = *(list = (char*)_Sfdec + (v <<= 1)); s[1] = *(list+1); \
186 { s -= 3; SFDIGIT(v,100,s[0]); \
187 s[1] = *(list = (char*)_Sfdec + (v <<= 1)); s[2] = *(list+1); \
189 { s -= 4; SFDIGIT(v,1000,s[0]); SFDIGIT(v,100,s[1]); \
190 s[2] = *(list = (char*)_Sfdec + (v <<= 1)); s[3] = *(list+1); \
197 extern char *
_sfcvt(
void *,
int,
int *,
int *,
int);
char * _sfcvt(void *, int, int *, int *, int)
long double sf_pos10[SF_MAXEXP10]
positive powers of 10
uchar sf_cv64[UCHAR_MAX+1]
uchar sf_type[UCHAR_MAX+1]
long double sf_neg10[SF_MAXEXP10]
negative powers of 10
uchar sf_cv36[UCHAR_MAX+1]