2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #define _finite __finite
29 #define _isnan __isnan
30 inline int iswdigit ( wchar_t c
)
32 return ( c
>= L
'0' && c
<= L
'9' );
37 # define __isnan isnan
38 # define __finite finite
39 # define powl __builtin_powl
40 # define modfl __builtin_modfl
44 #define alloca _alloca
48 typedef __int64 LONGLONG
;
49 typedef unsigned __int64 ULONGLONG
;
51 typedef long long LONGLONG
;
52 typedef unsigned long long ULONGLONG
;
56 unsigned int mantissa
:23;
57 unsigned int exponent
:8;
62 unsigned int mantissal
:32;
63 unsigned int mantissah
:20;
64 unsigned int exponent
:11;
69 unsigned int mantissal
:32;
70 unsigned int mantissah
:32;
71 unsigned int exponent
:15;
73 unsigned int empty
:16;
77 ssprintf ( const char* fmt
, ... )
81 std::string f
= ssvprintf ( fmt
, arg
);
87 sswprintf ( const wchar_t* fmt
, ... )
91 std::wstring f
= sswvprintf ( fmt
, arg
);
96 #define ZEROPAD 1 /* pad with zero */
97 #define SIGN 2 /* unsigned/signed long */
98 #define PLUS 4 /* show plus */
99 #define SPACE 8 /* space if plus */
100 #define LEFT 16 /* left justified */
101 #define SPECIAL 32 /* 0x */
102 #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
103 #define ZEROTRUNC 128 /* truncate zero 's */
107 skip_atoi(const char **s
)
112 i
= i
*10 + *((*s
)++) - '0';
117 skip_wtoi(const wchar_t **s
)
121 while (iswdigit(**s
))
122 i
= i
*10 + *((*s
)++) - L
'0';
128 do_div(LONGLONG
*n
,int base
)
130 int __res
= ((ULONGLONG
) *n
) % (unsigned) base
;
131 *n
= ((ULONGLONG
) *n
) / (unsigned) base
;
137 number(std::string
& f
, LONGLONG num
, int base
, int size
, int precision
,int type
)
140 const char *digits
="0123456789abcdefghijklmnopqrstuvwxyz";
144 digits
= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
147 if (base
< 2 || base
> 36)
149 c
= (type
& ZEROPAD
) ? '0' : ' ';
156 } else if (type
& PLUS
) {
159 } else if (type
& SPACE
) {
164 if (type
& SPECIAL
) {
173 else while (num
!= 0)
174 tmp
[i
++] = digits
[do_div(&num
,base
)];
178 if (!(type
&(ZEROPAD
+LEFT
)))
198 while (i
< precision
--)
214 wnumber(std::wstring
& f
, LONGLONG num
, int base
, int size
, int precision
,int type
)
216 wchar_t c
,sign
,tmp
[66];
217 const wchar_t *digits
= L
"0123456789abcdefghijklmnopqrstuvwxyz";
221 digits
= L
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
224 if (base
< 2 || base
> 36)
226 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
233 } else if (type
& PLUS
) {
236 } else if (type
& SPACE
) {
241 if (type
& SPECIAL
) {
250 else while (num
!= 0)
251 tmp
[i
++] = digits
[do_div(&num
,base
)];
255 if (!(type
&(ZEROPAD
+LEFT
)))
275 while (i
< precision
--)
292 numberf(std::string
& f
, double __n
, char exp_sign
, int size
, int precision
, int type
)
294 double exponent
= 0.0;
319 if ( exp_sign
== 'g' || exp_sign
== 'G' || exp_sign
== 'e' || exp_sign
== 'E' ) {
320 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3ff);
321 exponent
= ie
/3.321928;
324 if ( exp_sign
== 'g' || exp_sign
== 'G' ) {
326 if ( exponent
< -4 || fabs(exponent
) >= precision
)
327 exp_sign
-= 2; // g -> e and G -> E
332 if ( exp_sign
== 'e' || exp_sign
== 'E' ) {
333 frac
= modf(exponent
,&e
);
336 else if ( frac
< -0.5 )
339 result
= numberf(f
,__n
/pow(10.0L,(long double)e
),'f',size
-4, precision
, type
);
349 result
= number(f
,ie
, 10,2, 2,type
);
355 if ( exp_sign
== 'f' ) {
356 buf
= (char*)alloca(4096);
361 c
= (type
& ZEROPAD
) ? '0' : ' ';
368 } else if (type
& PLUS
) {
371 } else if (type
& SPACE
) {
377 frac
= modf(__n
,&intr
);
379 // # flags forces a . and prevents trucation of trailing zero's
381 if ( precision
> 0 ) {
382 //frac = modfl(__n,&intr);
386 frac
= modf(frac
, &p
);
387 buf
[i
] = (int)p
+ '0';
398 if ( precision
>= 1 || type
& SPECIAL
) {
409 while ( intr
> 0.0 ) {
416 buf
[i
++] = (int)p
+ '0';
422 while ( j
< i
&& ro
== 1) {
423 if ( buf
[j
] >= '0' && buf
[j
] <= '8' ) {
427 else if ( buf
[j
] == '9' ) {
438 if (!(type
&(ZEROPAD
+LEFT
)))
448 if (!(type
&(ZEROPAD
+LEFT
)))
453 if (type
& SPECIAL
) {
463 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
466 while ( j
< i
&& ( *tmp
== '0' || *tmp
== '.' ))
473 // while (i < precision--)
488 wnumberf(std::wstring
& f
, double __n
, wchar_t exp_sign
, int size
, int precision
, int type
)
490 double exponent
= 0.0;
499 wchar_t *buf
, *tmp
, sign
, c
, ro
= 0;
510 if ( exp_sign
== L
'g' || exp_sign
== L
'G' || exp_sign
== L
'e' || exp_sign
== L
'E' ) {
511 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3ff);
512 exponent
= ie
/3.321928;
515 if ( exp_sign
== L
'g' || exp_sign
== L
'G' )
518 if ( exponent
< -4 || fabs(exponent
) >= precision
)
519 exp_sign
-= 2; // g -> e and G -> E
524 if ( exp_sign
== L
'e' || exp_sign
== L
'E' )
526 frac
= modf(exponent
,&e
);
529 else if ( frac
< -0.5 )
532 result
= wnumberf(f
,__n
/pow(10.0L,(long double) e
),L
'f',size
-4, precision
, type
);
542 result
= wnumber(f
,ie
, 10,2, 2,type
);
548 if ( exp_sign
== L
'f' )
550 buf
= (wchar_t*)alloca(4096*sizeof(wchar_t));
554 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
564 else if (type
& PLUS
)
569 else if (type
& SPACE
)
576 frac
= modf(__n
,&intr
);
578 // # flags forces a . and prevents trucation of trailing zero's
580 if ( precision
> 0 ) {
581 //frac = modfl(__n,&intr);
585 frac
= modf(frac
, &p
);
586 buf
[i
] = (int)p
+ L
'0';
597 if ( precision
>= 1 || type
& SPECIAL
) {
608 while ( intr
> 0.0 ) {
615 buf
[i
++] = (int)p
+ L
'0';
621 while ( j
< i
&& ro
== 1) {
622 if ( buf
[j
] >= L
'0' && buf
[j
] <= L
'8' ) {
626 else if ( buf
[j
] == L
'9' ) {
637 if (!(type
&(ZEROPAD
+LEFT
)))
647 if (!(type
&(ZEROPAD
+LEFT
)))
652 if (type
& SPECIAL
) {
662 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
665 while ( j
< i
&& ( *tmp
== L
'0' || *tmp
== L
'.' ))
684 numberfl(std::string
& f
, long double __n
, char exp_sign
, int size
, int precision
, int type
)
686 long double exponent
= 0.0;
696 long double frac
, intr
;
707 ieee_long_double_t
* n
;
712 if ( exp_sign
== 'g' || exp_sign
== 'G' || exp_sign
== 'e' || exp_sign
== 'E' ) {
713 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3fff);
714 exponent
= ie
/3.321928;
717 if ( exp_sign
== 'g' || exp_sign
== 'G' ) {
719 if ( exponent
< -4 || fabs(exponent
) >= precision
)
720 exp_sign
-= 2; // g -> e and G -> E
725 if ( exp_sign
== 'e' || exp_sign
== 'E' ) {
726 frac
= modfl(exponent
,&e
);
729 else if ( frac
< -0.5 )
732 result
= numberf(f
,__n
/powl(10.0L,e
),'f',size
-4, precision
, type
);
742 result
= number(f
,ie
, 10,2, 2,type
);
748 if ( exp_sign
== 'f' )
751 buf
= (char*)alloca(4096);
757 c
= (type
& ZEROPAD
) ? '0' : ' ';
766 } else if (type
& PLUS
)
770 } else if (type
& SPACE
)
777 frac
= modfl(__n
,&intr
);
779 // # flags forces a . and prevents trucation of trailing zero's
782 //frac = modfl(__n,&intr);
788 frac
= modfl((long double)frac
, &p
);
789 buf
[i
] = (int)p
+ '0';
801 if ( precision
>= 1 || type
& SPECIAL
)
823 buf
[i
++] = (int)p
+ '0';
829 while ( j
< i
&& ro
== 1) {
830 if ( buf
[j
] >= '0' && buf
[j
] <= '8' )
835 else if ( buf
[j
] == '9' )
847 if (!(type
&(ZEROPAD
+LEFT
)))
857 if (!(type
&(ZEROPAD
+LEFT
)))
862 if (type
& SPECIAL
) {
871 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
874 while ( j
< i
&& ( *tmp
== '0' || *tmp
== '.' ))
893 wnumberfl(std::wstring
& f
, long double __n
, wchar_t exp_sign
, int size
, int precision
, int type
)
895 long double exponent
= 0.0;
899 wchar_t *buf
, *tmp
, sign
, c
, ro
= 0;
903 long double frac
, intr
;
911 ieee_long_double_t
* n
;
916 if ( exp_sign
== L
'g' || exp_sign
== L
'G' || exp_sign
== L
'e' || exp_sign
== L
'E' ) {
917 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3fff);
918 exponent
= ie
/3.321928;
921 if ( exp_sign
== L
'g' || exp_sign
== L
'G' ) {
923 if ( exponent
< -4 || fabs(exponent
) >= precision
)
924 exp_sign
-= 2; // g -> e and G -> E
929 if ( exp_sign
== L
'e' || exp_sign
== L
'E' ) {
930 frac
= modfl(exponent
,&e
);
933 else if ( frac
< -0.5 )
936 result
= wnumberf(f
,__n
/powl(10.0L,e
),L
'f',size
-4, precision
, type
);
946 result
= wnumber(f
,ie
, 10,2, 2,type
);
952 if ( exp_sign
== L
'f' )
955 buf
= (wchar_t*)alloca(4096*sizeof(wchar_t));
961 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
970 } else if (type
& PLUS
)
974 } else if (type
& SPACE
)
981 frac
= modfl(__n
,&intr
);
983 // # flags forces a . and prevents trucation of trailing zero's
986 //frac = modfl(__n,&intr);
992 frac
= modfl((long double)frac
, &p
);
993 buf
[i
] = (int)p
+ L
'0';
1005 if ( precision
>= 1 || type
& SPECIAL
)
1019 while ( intr
> 0.0 )
1027 buf
[i
++] = (int)p
+ L
'0';
1033 while ( j
< i
&& ro
== 1) {
1034 if ( buf
[j
] >= L
'0' && buf
[j
] <= L
'8' )
1039 else if ( buf
[j
] == L
'9' )
1051 if (!(type
&(ZEROPAD
+LEFT
)))
1061 if (!(type
&(ZEROPAD
+LEFT
)))
1066 if (type
& SPECIAL
) {
1075 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
1078 while ( j
< i
&& ( *tmp
== L
'0' || *tmp
== L
'.' ))
1097 do_string(std::string
& f
, const char* s
, int len
, int field_width
, int precision
, int flags
)
1110 while ((unsigned int)len
< (unsigned int)precision
&& s
[len
])
1115 if ((unsigned int)len
> (unsigned int)precision
)
1119 if (!(flags
& LEFT
))
1120 while (len
< field_width
--)
1125 for (i
= 0; i
< len
; ++i
)
1130 while (len
< field_width
--)
1139 do_wstring(std::wstring
& f
, const wchar_t* s
, int len
, int field_width
, int precision
, int flags
)
1152 while ((unsigned int)len
< (unsigned int)precision
&& s
[len
])
1157 if ((unsigned int)len
> (unsigned int)precision
)
1161 if (!(flags
& LEFT
))
1162 while (len
< field_width
--)
1167 for (i
= 0; i
< len
; ++i
)
1172 while (len
< field_width
--)
1181 stringw(std::string
& f
, const wchar_t* sw
, int len
, int field_width
, int precision
, int flags
)
1194 while ((unsigned int)len
< (unsigned int)precision
&& sw
[len
])
1199 if ((unsigned int)len
> (unsigned int)precision
)
1203 if (!(flags
& LEFT
))
1204 while (len
< field_width
--)
1209 for (i
= 0; i
< len
; ++i
)
1211 #define MY_MB_CUR_MAX 1
1212 char mb
[MY_MB_CUR_MAX
];
1214 mbcount
= wctomb(mb
, *sw
++);
1219 for (j
= 0; j
< mbcount
; j
++)
1225 while (len
< field_width
--)
1234 wstringa(std::wstring
& f
, const char* sa
, int len
, int field_width
, int precision
, int flags
)
1247 while ((unsigned int)len
< (unsigned int)precision
&& sa
[len
])
1252 if ((unsigned int)len
> (unsigned int)precision
)
1256 if (!(flags
& LEFT
))
1257 while (len
< field_width
--)
1262 for (i
= 0; i
< len
;)
1266 mbcount
= mbtowc(&w
, sa
, len
-i
);
1273 while (len
< field_width
--)
1281 #define _isnanl _isnan
1282 #define _finitel _finite
1285 ssvprintf ( const char *fmt
, va_list args
)
1289 long double _ldouble
;
1296 int flags
; /* flags to number() */
1298 int field_width
; /* width of output field */
1299 int precision
; /* min. # of digits for integers; max
1300 number of chars for from string */
1301 int qualifier
= 0; /* 'h', 'l', 'L' or 'I64' for integer fields */
1303 for (; *fmt
; ++fmt
)
1314 ++fmt
; /* this also skips first '%' */
1316 case '-': flags
|= LEFT
; goto repeat
;
1317 case '+': flags
|= PLUS
; goto repeat
;
1318 case ' ': flags
|= SPACE
; goto repeat
;
1319 case '#': flags
|= SPECIAL
; goto repeat
;
1320 case '0': flags
|= ZEROPAD
; goto repeat
;
1323 /* get field width */
1326 field_width
= skip_atoi(&fmt
);
1327 else if (*fmt
== '*') {
1329 /* it's the next argument */
1330 field_width
= va_arg(args
, int);
1331 if (field_width
< 0) {
1332 field_width
= -field_width
;
1337 /* get the precision */
1342 precision
= skip_atoi(&fmt
);
1343 else if (*fmt
== '*') {
1345 /* it's the next argument */
1346 precision
= va_arg(args
, int);
1352 /* get the conversion qualifier */
1354 // %Z can be just stand alone or as size_t qualifier
1355 if ( *fmt
== 'Z' ) {
1357 switch ( *(fmt
+1)) {
1370 } else if (*fmt
== 'h' || *fmt
== 'l' || *fmt
== 'L' || *fmt
== 'w') {
1373 } else if (*fmt
== 'I' && *(fmt
+1) == '6' && *(fmt
+2) == '4') {
1378 // go fine with ll instead of L
1379 if ( *fmt
== 'l' ) {
1389 if (!(flags
& LEFT
))
1390 while (--field_width
> 0)
1394 if (qualifier
== 'l' || qualifier
== 'w')
1396 f
+= (char)(unsigned char)(wchar_t) va_arg(args
,int);
1400 f
+= (char)(unsigned char) va_arg(args
,int);
1402 while (--field_width
> 0)
1409 if (!(flags
& LEFT
))
1410 while (--field_width
> 0)
1414 if (qualifier
== 'h')
1416 f
+= (char)(unsigned char) va_arg(args
,int);
1420 f
+= (char)(unsigned char)(wchar_t) va_arg(args
,int);
1422 while (--field_width
> 0)
1429 if (qualifier
== 'l' || qualifier
== 'w') {
1430 /* print unicode string */
1431 sw
= va_arg(args
, wchar_t *);
1432 result
= stringw(f
, sw
, -1, field_width
, precision
, flags
);
1434 /* print ascii string */
1435 s
= va_arg(args
, char *);
1436 result
= do_string(f
, s
, -1, field_width
, precision
, flags
);
1440 assert(!"TODO FIXME handle error better");
1446 if (qualifier
== 'h') {
1447 /* print ascii string */
1448 s
= va_arg(args
, char *);
1449 result
= do_string(f
, s
, -1, field_width
, precision
, flags
);
1451 /* print unicode string */
1452 sw
= va_arg(args
, wchar_t *);
1453 result
= stringw(f
, sw
, -1, field_width
, precision
, flags
);
1457 assert(!"TODO FIXME handle error better");
1463 if (qualifier == 'w') {
1464 // print counted unicode string
1465 PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
1466 if ((pus == NULL) || (pus->Buffer == NULL)) {
1471 len = pus->Length / sizeof(WCHAR);
1473 result = stringw(f, sw, len, field_width, precision, flags);
1475 // print counted ascii string
1476 PANSI_STRING pas = va_arg(args, PANSI_STRING);
1477 if ((pas == NULL) || (pas->Buffer == NULL)) {
1484 result = string(f, s, -1, field_width, precision, flags);
1495 if (qualifier
== 'l' || qualifier
== 'L' ) {
1496 _ldouble
= va_arg(args
, long double);
1498 if ( _isnanl(_ldouble
) )
1502 else if ( !_finitel(_ldouble
) )
1509 if ( precision
== -1 )
1511 result
= numberfl(f
,_ldouble
,*fmt
,field_width
,precision
,flags
);
1514 assert(!"TODO FIXME handle error better");
1519 _double
= (double)va_arg(args
, double);
1521 if ( _isnan(_double
) )
1525 else if ( !_finite(_double
) )
1534 if ( precision
== -1 )
1536 result
= numberf(f
,_double
,*fmt
,field_width
,precision
,flags
);
1539 assert(!"TODO FIXME handle error better");
1547 if (field_width
== -1) {
1548 field_width
= 2*sizeof(void *);
1552 (unsigned long) va_arg(args
, void *), 16,
1553 field_width
, precision
, flags
);
1556 assert(!"TODO FIXME handle error better");
1562 if (qualifier
== 'l') {
1563 long * ip
= va_arg(args
, long *);
1566 int * ip
= va_arg(args
, int *);
1571 /* integer number formats - set up the flags and "break" */
1606 if (qualifier
== 'I')
1607 num
= va_arg(args
, ULONGLONG
);
1608 else if (qualifier
== 'l') {
1610 num
= va_arg(args
, long);
1612 num
= va_arg(args
, unsigned long);
1614 else if (qualifier
== 'h') {
1616 num
= va_arg(args
, int);
1618 num
= va_arg(args
, unsigned int);
1620 else if (flags
& SIGN
)
1621 num
= va_arg(args
, int);
1623 num
= va_arg(args
, unsigned int);
1624 result
= number(f
, num
, base
, field_width
, precision
, flags
);
1627 assert(!"TODO FIXME handle error better");
1636 sswvprintf ( const wchar_t* fmt
, va_list args
)
1640 long double _ldouble
;
1647 int flags
; /* flags to number() */
1649 int field_width
; /* width of output field */
1650 int precision
; /* min. # of digits for integers; max
1651 number of chars for from string */
1652 int qualifier
= 0; /* 'h', 'l', 'L' or 'I64' for integer fields */
1654 for (; *fmt
; ++fmt
)
1665 ++fmt
; /* this also skips first '%' */
1667 case L
'-': flags
|= LEFT
; goto repeat
;
1668 case L
'+': flags
|= PLUS
; goto repeat
;
1669 case L
' ': flags
|= SPACE
; goto repeat
;
1670 case L
'#': flags
|= SPECIAL
; goto repeat
;
1671 case L
'0': flags
|= ZEROPAD
; goto repeat
;
1674 /* get field width */
1677 field_width
= skip_wtoi(&fmt
);
1678 else if (*fmt
== L
'*') {
1680 /* it's the next argument */
1681 field_width
= va_arg(args
, int);
1682 if (field_width
< 0) {
1683 field_width
= -field_width
;
1688 /* get the precision */
1693 precision
= skip_wtoi(&fmt
);
1694 else if (*fmt
== L
'*') {
1696 /* it's the next argument */
1697 precision
= va_arg(args
, int);
1703 /* get the conversion qualifier */
1705 // %Z can be just stand alone or as size_t qualifier
1706 if ( *fmt
== L
'Z' ) {
1708 switch ( *(fmt
+1)) {
1721 } else if (*fmt
== L
'h' || *fmt
== L
'l' || *fmt
== L
'L' || *fmt
== L
'w') {
1724 } else if (*fmt
== L
'I' && *(fmt
+1) == L
'6' && *(fmt
+2) == L
'4') {
1729 // go fine with ll instead of L
1730 if ( *fmt
== L
'l' ) {
1740 if (!(flags
& LEFT
))
1741 while (--field_width
> 0)
1745 if ( qualifier
== L
'h' )
1747 f
+= (wchar_t)(char)(unsigned char) va_arg(args
,int);
1751 f
+= (wchar_t) va_arg(args
,int);
1753 while (--field_width
> 0)
1760 if (!(flags
& LEFT
))
1761 while (--field_width
> 0)
1765 if (qualifier
== L
'l' || qualifier
== L
'w')
1767 f
+= (wchar_t) va_arg(args
,int);
1771 f
+= (wchar_t)(char)(unsigned char) va_arg(args
,int);
1773 while (--field_width
> 0)
1780 if (qualifier
== L
'h') {
1781 /* print ascii string */
1782 sa
= va_arg(args
, char *);
1783 result
= wstringa(f
, sa
, -1, field_width
, precision
, flags
);
1785 /* print unicode string */
1786 s
= va_arg(args
, wchar_t *);
1787 result
= do_wstring(f
, s
, -1, field_width
, precision
, flags
);
1791 assert(!"TODO FIXME handle error better");
1797 if (qualifier
== L
'l' || qualifier
== L
'w') {
1798 /* print unicode string */
1799 s
= va_arg(args
, wchar_t *);
1800 result
= do_wstring(f
, s
, -1, field_width
, precision
, flags
);
1802 /* print ascii string */
1803 sa
= va_arg(args
, char *);
1804 result
= wstringa(f
, sa
, -1, field_width
, precision
, flags
);
1808 assert(!"TODO FIXME handle error better");
1818 if (qualifier
== L
'l' || qualifier
== L
'L' )
1820 _ldouble
= va_arg(args
, long double);
1822 if ( _isnanl(_ldouble
) )
1826 else if ( !_finitel(_ldouble
) )
1833 if ( precision
== -1 )
1835 result
= wnumberfl(f
,_ldouble
,*fmt
,field_width
,precision
,flags
);
1838 assert(!"TODO FIXME handle error better");
1843 _double
= (double)va_arg(args
, double);
1845 if ( _isnan(_double
) )
1849 else if ( !_finite(_double
) )
1858 if ( precision
== -1 )
1860 result
= wnumberf(f
,_double
,*fmt
,field_width
,precision
,flags
);
1863 assert(!"TODO FIXME handle error better");
1871 if (field_width
== -1) {
1872 field_width
= 2*sizeof(void *);
1876 (unsigned long) va_arg(args
, void *), 16,
1877 field_width
, precision
, flags
);
1880 assert(!"TODO FIXME handle error better");
1886 if (qualifier
== L
'l') {
1887 long * ip
= va_arg(args
, long *);
1890 int * ip
= va_arg(args
, int *);
1895 /* integer number formats - set up the flags and "break" */
1930 if (qualifier
== L
'I')
1931 num
= va_arg(args
, ULONGLONG
);
1932 else if (qualifier
== L
'l') {
1934 num
= va_arg(args
, long);
1936 num
= va_arg(args
, unsigned long);
1938 else if (qualifier
== L
'h') {
1940 num
= va_arg(args
, int);
1942 num
= va_arg(args
, unsigned int);
1944 else if (flags
& SIGN
)
1945 num
= va_arg(args
, int);
1947 num
= va_arg(args
, unsigned int);
1948 result
= wnumber(f
, num
, base
, field_width
, precision
, flags
);
1951 assert(!"TODO FIXME handle error better");