cea328a22e04db5a18ebb3bd86c94371f0e5fab8
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 __isnan isnan
29 # define __finite finite
30 # define powl __builtin_powl
31 # define modfl __builtin_modfl
35 #define alloca _alloca
39 typedef __int64 LONGLONG
;
40 typedef unsigned __int64 ULONGLONG
;
42 typedef long long LONGLONG
;
43 typedef unsigned long long ULONGLONG
;
47 unsigned int mantissa
:23;
48 unsigned int exponent
:8;
53 unsigned int mantissal
:32;
54 unsigned int mantissah
:20;
55 unsigned int exponent
:11;
60 unsigned int mantissal
:32;
61 unsigned int mantissah
:32;
62 unsigned int exponent
:15;
64 unsigned int empty
:16;
68 ssprintf ( const char* fmt
, ... )
72 std::string f
= ssvprintf ( fmt
, arg
);
78 sswprintf ( const wchar_t* fmt
, ... )
82 std::wstring f
= sswvprintf ( fmt
, arg
);
87 #define ZEROPAD 1 /* pad with zero */
88 #define SIGN 2 /* unsigned/signed long */
89 #define PLUS 4 /* show plus */
90 #define SPACE 8 /* space if plus */
91 #define LEFT 16 /* left justified */
92 #define SPECIAL 32 /* 0x */
93 #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
94 #define ZEROTRUNC 128 /* truncate zero 's */
98 skip_atoi(const char **s
)
103 i
= i
*10 + *((*s
)++) - '0';
108 skip_wtoi(const wchar_t **s
)
112 while (iswdigit(**s
))
113 i
= i
*10 + *((*s
)++) - L
'0';
119 do_div(LONGLONG
*n
,int base
)
121 int __res
= ((ULONGLONG
) *n
) % (unsigned) base
;
122 *n
= ((ULONGLONG
) *n
) / (unsigned) base
;
128 number(std::string
& f
, LONGLONG num
, int base
, int size
, int precision
,int type
)
131 const char *digits
="0123456789abcdefghijklmnopqrstuvwxyz";
135 digits
= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
138 if (base
< 2 || base
> 36)
140 c
= (type
& ZEROPAD
) ? '0' : ' ';
147 } else if (type
& PLUS
) {
150 } else if (type
& SPACE
) {
155 if (type
& SPECIAL
) {
164 else while (num
!= 0)
165 tmp
[i
++] = digits
[do_div(&num
,base
)];
169 if (!(type
&(ZEROPAD
+LEFT
)))
189 while (i
< precision
--)
205 wnumber(std::wstring
& f
, LONGLONG num
, int base
, int size
, int precision
,int type
)
207 wchar_t c
,sign
,tmp
[66];
208 const wchar_t *digits
= L
"0123456789abcdefghijklmnopqrstuvwxyz";
212 digits
= L
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
215 if (base
< 2 || base
> 36)
217 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
224 } else if (type
& PLUS
) {
227 } else if (type
& SPACE
) {
232 if (type
& SPECIAL
) {
241 else while (num
!= 0)
242 tmp
[i
++] = digits
[do_div(&num
,base
)];
246 if (!(type
&(ZEROPAD
+LEFT
)))
266 while (i
< precision
--)
283 numberf(std::string
& f
, double __n
, char exp_sign
, int size
, int precision
, int type
)
285 double exponent
= 0.0;
310 if ( exp_sign
== 'g' || exp_sign
== 'G' || exp_sign
== 'e' || exp_sign
== 'E' ) {
311 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3ff);
312 exponent
= ie
/3.321928;
315 if ( exp_sign
== 'g' || exp_sign
== 'G' ) {
317 if ( exponent
< -4 || fabs(exponent
) >= precision
)
318 exp_sign
-= 2; // g -> e and G -> E
323 if ( exp_sign
== 'e' || exp_sign
== 'E' ) {
324 frac
= modf(exponent
,&e
);
327 else if ( frac
< -0.5 )
330 result
= numberf(f
,__n
/pow(10.0L,(long double)e
),'f',size
-4, precision
, type
);
340 result
= number(f
,ie
, 10,2, 2,type
);
346 if ( exp_sign
== 'f' ) {
347 buf
= (char*)alloca(4096);
352 c
= (type
& ZEROPAD
) ? '0' : ' ';
359 } else if (type
& PLUS
) {
362 } else if (type
& SPACE
) {
368 frac
= modf(__n
,&intr
);
370 // # flags forces a . and prevents trucation of trailing zero's
372 if ( precision
> 0 ) {
373 //frac = modfl(__n,&intr);
377 frac
= modf(frac
, &p
);
378 buf
[i
] = (int)p
+ '0';
389 if ( precision
>= 1 || type
& SPECIAL
) {
400 while ( intr
> 0.0 ) {
407 buf
[i
++] = (int)p
+ '0';
413 while ( j
< i
&& ro
== 1) {
414 if ( buf
[j
] >= '0' && buf
[j
] <= '8' ) {
418 else if ( buf
[j
] == '9' ) {
429 if (!(type
&(ZEROPAD
+LEFT
)))
439 if (!(type
&(ZEROPAD
+LEFT
)))
444 if (type
& SPECIAL
) {
454 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
457 while ( j
< i
&& ( *tmp
== '0' || *tmp
== '.' ))
464 // while (i < precision--)
479 wnumberf(std::wstring
& f
, double __n
, wchar_t exp_sign
, int size
, int precision
, int type
)
481 double exponent
= 0.0;
490 wchar_t *buf
, *tmp
, sign
, c
, ro
= 0;
501 if ( exp_sign
== L
'g' || exp_sign
== L
'G' || exp_sign
== L
'e' || exp_sign
== L
'E' ) {
502 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3ff);
503 exponent
= ie
/3.321928;
506 if ( exp_sign
== L
'g' || exp_sign
== L
'G' )
509 if ( exponent
< -4 || fabs(exponent
) >= precision
)
510 exp_sign
-= 2; // g -> e and G -> E
515 if ( exp_sign
== L
'e' || exp_sign
== L
'E' )
517 frac
= modf(exponent
,&e
);
520 else if ( frac
< -0.5 )
523 result
= wnumberf(f
,__n
/pow(10.0L,(long double) e
),L
'f',size
-4, precision
, type
);
533 result
= wnumber(f
,ie
, 10,2, 2,type
);
539 if ( exp_sign
== L
'f' )
541 buf
= (wchar_t*)alloca(4096*sizeof(wchar_t));
545 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
555 else if (type
& PLUS
)
560 else if (type
& SPACE
)
567 frac
= modf(__n
,&intr
);
569 // # flags forces a . and prevents trucation of trailing zero's
571 if ( precision
> 0 ) {
572 //frac = modfl(__n,&intr);
576 frac
= modf(frac
, &p
);
577 buf
[i
] = (int)p
+ L
'0';
588 if ( precision
>= 1 || type
& SPECIAL
) {
599 while ( intr
> 0.0 ) {
606 buf
[i
++] = (int)p
+ L
'0';
612 while ( j
< i
&& ro
== 1) {
613 if ( buf
[j
] >= L
'0' && buf
[j
] <= L
'8' ) {
617 else if ( buf
[j
] == L
'9' ) {
628 if (!(type
&(ZEROPAD
+LEFT
)))
638 if (!(type
&(ZEROPAD
+LEFT
)))
643 if (type
& SPECIAL
) {
653 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
656 while ( j
< i
&& ( *tmp
== L
'0' || *tmp
== L
'.' ))
675 numberfl(std::string
& f
, long double __n
, char exp_sign
, int size
, int precision
, int type
)
677 long double exponent
= 0.0;
687 long double frac
, intr
;
698 ieee_long_double_t
* n
;
703 if ( exp_sign
== 'g' || exp_sign
== 'G' || exp_sign
== 'e' || exp_sign
== 'E' ) {
704 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3fff);
705 exponent
= ie
/3.321928;
708 if ( exp_sign
== 'g' || exp_sign
== 'G' ) {
710 if ( exponent
< -4 || fabs(exponent
) >= precision
)
711 exp_sign
-= 2; // g -> e and G -> E
716 if ( exp_sign
== 'e' || exp_sign
== 'E' ) {
717 frac
= modfl(exponent
,&e
);
720 else if ( frac
< -0.5 )
723 result
= numberf(f
,__n
/powl(10.0L,e
),'f',size
-4, precision
, type
);
733 result
= number(f
,ie
, 10,2, 2,type
);
739 if ( exp_sign
== 'f' )
742 buf
= (char*)alloca(4096);
748 c
= (type
& ZEROPAD
) ? '0' : ' ';
757 } else if (type
& PLUS
)
761 } else if (type
& SPACE
)
768 frac
= modfl(__n
,&intr
);
770 // # flags forces a . and prevents trucation of trailing zero's
773 //frac = modfl(__n,&intr);
779 frac
= modfl((long double)frac
, &p
);
780 buf
[i
] = (int)p
+ '0';
792 if ( precision
>= 1 || type
& SPECIAL
)
814 buf
[i
++] = (int)p
+ '0';
820 while ( j
< i
&& ro
== 1) {
821 if ( buf
[j
] >= '0' && buf
[j
] <= '8' )
826 else if ( buf
[j
] == '9' )
838 if (!(type
&(ZEROPAD
+LEFT
)))
848 if (!(type
&(ZEROPAD
+LEFT
)))
853 if (type
& SPECIAL
) {
862 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
865 while ( j
< i
&& ( *tmp
== '0' || *tmp
== '.' ))
884 wnumberfl(std::wstring
& f
, long double __n
, wchar_t exp_sign
, int size
, int precision
, int type
)
886 long double exponent
= 0.0;
890 wchar_t *buf
, *tmp
, sign
, c
, ro
= 0;
894 long double frac
, intr
;
902 ieee_long_double_t
* n
;
907 if ( exp_sign
== L
'g' || exp_sign
== L
'G' || exp_sign
== L
'e' || exp_sign
== L
'E' ) {
908 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3fff);
909 exponent
= ie
/3.321928;
912 if ( exp_sign
== L
'g' || exp_sign
== L
'G' ) {
914 if ( exponent
< -4 || fabs(exponent
) >= precision
)
915 exp_sign
-= 2; // g -> e and G -> E
920 if ( exp_sign
== L
'e' || exp_sign
== L
'E' ) {
921 frac
= modfl(exponent
,&e
);
924 else if ( frac
< -0.5 )
927 result
= wnumberf(f
,__n
/powl(10.0L,e
),L
'f',size
-4, precision
, type
);
937 result
= wnumber(f
,ie
, 10,2, 2,type
);
943 if ( exp_sign
== L
'f' )
946 buf
= (wchar_t*)alloca(4096*sizeof(wchar_t));
952 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
961 } else if (type
& PLUS
)
965 } else if (type
& SPACE
)
972 frac
= modfl(__n
,&intr
);
974 // # flags forces a . and prevents trucation of trailing zero's
977 //frac = modfl(__n,&intr);
983 frac
= modfl((long double)frac
, &p
);
984 buf
[i
] = (int)p
+ L
'0';
996 if ( precision
>= 1 || type
& SPECIAL
)
1010 while ( intr
> 0.0 )
1018 buf
[i
++] = (int)p
+ L
'0';
1024 while ( j
< i
&& ro
== 1) {
1025 if ( buf
[j
] >= L
'0' && buf
[j
] <= L
'8' )
1030 else if ( buf
[j
] == L
'9' )
1042 if (!(type
&(ZEROPAD
+LEFT
)))
1052 if (!(type
&(ZEROPAD
+LEFT
)))
1057 if (type
& SPECIAL
) {
1066 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
1069 while ( j
< i
&& ( *tmp
== L
'0' || *tmp
== L
'.' ))
1088 do_string(std::string
& f
, const char* s
, int len
, int field_width
, int precision
, int flags
)
1101 while ((unsigned int)len
< (unsigned int)precision
&& s
[len
])
1106 if ((unsigned int)len
> (unsigned int)precision
)
1110 if (!(flags
& LEFT
))
1111 while (len
< field_width
--)
1116 for (i
= 0; i
< len
; ++i
)
1121 while (len
< field_width
--)
1130 do_wstring(std::wstring
& f
, const wchar_t* s
, int len
, int field_width
, int precision
, int flags
)
1143 while ((unsigned int)len
< (unsigned int)precision
&& s
[len
])
1148 if ((unsigned int)len
> (unsigned int)precision
)
1152 if (!(flags
& LEFT
))
1153 while (len
< field_width
--)
1158 for (i
= 0; i
< len
; ++i
)
1163 while (len
< field_width
--)
1172 stringw(std::string
& f
, const wchar_t* sw
, int len
, int field_width
, int precision
, int flags
)
1185 while ((unsigned int)len
< (unsigned int)precision
&& sw
[len
])
1190 if ((unsigned int)len
> (unsigned int)precision
)
1194 if (!(flags
& LEFT
))
1195 while (len
< field_width
--)
1200 for (i
= 0; i
< len
; ++i
)
1202 #define MY_MB_CUR_MAX 1
1203 char mb
[MY_MB_CUR_MAX
];
1205 mbcount
= wctomb(mb
, *sw
++);
1210 for (j
= 0; j
< mbcount
; j
++)
1216 while (len
< field_width
--)
1225 wstringa(std::wstring
& f
, const char* sa
, int len
, int field_width
, int precision
, int flags
)
1238 while ((unsigned int)len
< (unsigned int)precision
&& sa
[len
])
1243 if ((unsigned int)len
> (unsigned int)precision
)
1247 if (!(flags
& LEFT
))
1248 while (len
< field_width
--)
1253 for (i
= 0; i
< len
;)
1257 mbcount
= mbtowc(&w
, sa
, len
-i
);
1264 while (len
< field_width
--)
1272 #define _isnanl _isnan
1273 #define _finitel _finite
1276 ssvprintf ( const char *fmt
, va_list args
)
1280 long double _ldouble
;
1287 int flags
; /* flags to number() */
1289 int field_width
; /* width of output field */
1290 int precision
; /* min. # of digits for integers; max
1291 number of chars for from string */
1292 int qualifier
= 0; /* 'h', 'l', 'L' or 'I64' for integer fields */
1294 for (; *fmt
; ++fmt
)
1305 ++fmt
; /* this also skips first '%' */
1307 case '-': flags
|= LEFT
; goto repeat
;
1308 case '+': flags
|= PLUS
; goto repeat
;
1309 case ' ': flags
|= SPACE
; goto repeat
;
1310 case '#': flags
|= SPECIAL
; goto repeat
;
1311 case '0': flags
|= ZEROPAD
; goto repeat
;
1314 /* get field width */
1317 field_width
= skip_atoi(&fmt
);
1318 else if (*fmt
== '*') {
1320 /* it's the next argument */
1321 field_width
= va_arg(args
, int);
1322 if (field_width
< 0) {
1323 field_width
= -field_width
;
1328 /* get the precision */
1333 precision
= skip_atoi(&fmt
);
1334 else if (*fmt
== '*') {
1336 /* it's the next argument */
1337 precision
= va_arg(args
, int);
1343 /* get the conversion qualifier */
1345 // %Z can be just stand alone or as size_t qualifier
1346 if ( *fmt
== 'Z' ) {
1348 switch ( *(fmt
+1)) {
1361 } else if (*fmt
== 'h' || *fmt
== 'l' || *fmt
== 'L' || *fmt
== 'w') {
1364 } else if (*fmt
== 'I' && *(fmt
+1) == '6' && *(fmt
+2) == '4') {
1369 // go fine with ll instead of L
1370 if ( *fmt
== 'l' ) {
1380 if (!(flags
& LEFT
))
1381 while (--field_width
> 0)
1385 if (qualifier
== 'l' || qualifier
== 'w')
1387 f
+= (char)(unsigned char)(wchar_t) va_arg(args
,int);
1391 f
+= (char)(unsigned char) va_arg(args
,int);
1393 while (--field_width
> 0)
1400 if (!(flags
& LEFT
))
1401 while (--field_width
> 0)
1405 if (qualifier
== 'h')
1407 f
+= (char)(unsigned char) va_arg(args
,int);
1411 f
+= (char)(unsigned char)(wchar_t) va_arg(args
,int);
1413 while (--field_width
> 0)
1420 if (qualifier
== 'l' || qualifier
== 'w') {
1421 /* print unicode string */
1422 sw
= va_arg(args
, wchar_t *);
1423 result
= stringw(f
, sw
, -1, field_width
, precision
, flags
);
1425 /* print ascii string */
1426 s
= va_arg(args
, char *);
1427 result
= do_string(f
, s
, -1, field_width
, precision
, flags
);
1431 assert(!"TODO FIXME handle error better");
1437 if (qualifier
== 'h') {
1438 /* print ascii string */
1439 s
= va_arg(args
, char *);
1440 result
= do_string(f
, s
, -1, field_width
, precision
, flags
);
1442 /* print unicode string */
1443 sw
= va_arg(args
, wchar_t *);
1444 result
= stringw(f
, sw
, -1, field_width
, precision
, flags
);
1448 assert(!"TODO FIXME handle error better");
1454 if (qualifier == 'w') {
1455 // print counted unicode string
1456 PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
1457 if ((pus == NULL) || (pus->Buffer == NULL)) {
1462 len = pus->Length / sizeof(WCHAR);
1464 result = stringw(f, sw, len, field_width, precision, flags);
1466 // print counted ascii string
1467 PANSI_STRING pas = va_arg(args, PANSI_STRING);
1468 if ((pas == NULL) || (pas->Buffer == NULL)) {
1475 result = string(f, s, -1, field_width, precision, flags);
1486 if (qualifier
== 'l' || qualifier
== 'L' ) {
1487 _ldouble
= va_arg(args
, long double);
1489 if ( _isnanl(_ldouble
) )
1493 else if ( !_finitel(_ldouble
) )
1500 if ( precision
== -1 )
1502 result
= numberfl(f
,_ldouble
,*fmt
,field_width
,precision
,flags
);
1505 assert(!"TODO FIXME handle error better");
1510 _double
= (double)va_arg(args
, double);
1512 if ( _isnan(_double
) )
1516 else if ( !_finite(_double
) )
1525 if ( precision
== -1 )
1527 result
= numberf(f
,_double
,*fmt
,field_width
,precision
,flags
);
1530 assert(!"TODO FIXME handle error better");
1538 if (field_width
== -1) {
1539 field_width
= 2*sizeof(void *);
1543 (unsigned long) va_arg(args
, void *), 16,
1544 field_width
, precision
, flags
);
1547 assert(!"TODO FIXME handle error better");
1553 if (qualifier
== 'l') {
1554 long * ip
= va_arg(args
, long *);
1557 int * ip
= va_arg(args
, int *);
1562 /* integer number formats - set up the flags and "break" */
1597 if (qualifier
== 'I')
1598 num
= va_arg(args
, ULONGLONG
);
1599 else if (qualifier
== 'l') {
1601 num
= va_arg(args
, long);
1603 num
= va_arg(args
, unsigned long);
1605 else if (qualifier
== 'h') {
1607 num
= va_arg(args
, int);
1609 num
= va_arg(args
, unsigned int);
1611 else if (flags
& SIGN
)
1612 num
= va_arg(args
, int);
1614 num
= va_arg(args
, unsigned int);
1615 result
= number(f
, num
, base
, field_width
, precision
, flags
);
1618 assert(!"TODO FIXME handle error better");
1627 sswvprintf ( const wchar_t* fmt
, va_list args
)
1631 long double _ldouble
;
1638 int flags
; /* flags to number() */
1640 int field_width
; /* width of output field */
1641 int precision
; /* min. # of digits for integers; max
1642 number of chars for from string */
1643 int qualifier
= 0; /* 'h', 'l', 'L' or 'I64' for integer fields */
1645 for (; *fmt
; ++fmt
)
1656 ++fmt
; /* this also skips first '%' */
1658 case L
'-': flags
|= LEFT
; goto repeat
;
1659 case L
'+': flags
|= PLUS
; goto repeat
;
1660 case L
' ': flags
|= SPACE
; goto repeat
;
1661 case L
'#': flags
|= SPECIAL
; goto repeat
;
1662 case L
'0': flags
|= ZEROPAD
; goto repeat
;
1665 /* get field width */
1668 field_width
= skip_wtoi(&fmt
);
1669 else if (*fmt
== L
'*') {
1671 /* it's the next argument */
1672 field_width
= va_arg(args
, int);
1673 if (field_width
< 0) {
1674 field_width
= -field_width
;
1679 /* get the precision */
1684 precision
= skip_wtoi(&fmt
);
1685 else if (*fmt
== L
'*') {
1687 /* it's the next argument */
1688 precision
= va_arg(args
, int);
1694 /* get the conversion qualifier */
1696 // %Z can be just stand alone or as size_t qualifier
1697 if ( *fmt
== L
'Z' ) {
1699 switch ( *(fmt
+1)) {
1712 } else if (*fmt
== L
'h' || *fmt
== L
'l' || *fmt
== L
'L' || *fmt
== L
'w') {
1715 } else if (*fmt
== L
'I' && *(fmt
+1) == L
'6' && *(fmt
+2) == L
'4') {
1720 // go fine with ll instead of L
1721 if ( *fmt
== L
'l' ) {
1731 if (!(flags
& LEFT
))
1732 while (--field_width
> 0)
1736 if ( qualifier
== L
'h' )
1738 f
+= (wchar_t)(char)(unsigned char) va_arg(args
,int);
1742 f
+= (wchar_t) va_arg(args
,int);
1744 while (--field_width
> 0)
1751 if (!(flags
& LEFT
))
1752 while (--field_width
> 0)
1756 if (qualifier
== L
'l' || qualifier
== L
'w')
1758 f
+= (wchar_t) va_arg(args
,int);
1762 f
+= (wchar_t)(char)(unsigned char) va_arg(args
,int);
1764 while (--field_width
> 0)
1771 if (qualifier
== L
'h') {
1772 /* print ascii string */
1773 sa
= va_arg(args
, char *);
1774 result
= wstringa(f
, sa
, -1, field_width
, precision
, flags
);
1776 /* print unicode string */
1777 s
= va_arg(args
, wchar_t *);
1778 result
= do_wstring(f
, s
, -1, field_width
, precision
, flags
);
1782 assert(!"TODO FIXME handle error better");
1788 if (qualifier
== L
'l' || qualifier
== L
'w') {
1789 /* print unicode string */
1790 s
= va_arg(args
, wchar_t *);
1791 result
= do_wstring(f
, s
, -1, field_width
, precision
, flags
);
1793 /* print ascii string */
1794 sa
= va_arg(args
, char *);
1795 result
= wstringa(f
, sa
, -1, field_width
, precision
, flags
);
1799 assert(!"TODO FIXME handle error better");
1809 if (qualifier
== L
'l' || qualifier
== L
'L' )
1811 _ldouble
= va_arg(args
, long double);
1813 if ( _isnanl(_ldouble
) )
1817 else if ( !_finitel(_ldouble
) )
1824 if ( precision
== -1 )
1826 result
= wnumberfl(f
,_ldouble
,*fmt
,field_width
,precision
,flags
);
1829 assert(!"TODO FIXME handle error better");
1834 _double
= (double)va_arg(args
, double);
1836 if ( _isnan(_double
) )
1840 else if ( !_finite(_double
) )
1849 if ( precision
== -1 )
1851 result
= wnumberf(f
,_double
,*fmt
,field_width
,precision
,flags
);
1854 assert(!"TODO FIXME handle error better");
1862 if (field_width
== -1) {
1863 field_width
= 2*sizeof(void *);
1867 (unsigned long) va_arg(args
, void *), 16,
1868 field_width
, precision
, flags
);
1871 assert(!"TODO FIXME handle error better");
1877 if (qualifier
== L
'l') {
1878 long * ip
= va_arg(args
, long *);
1881 int * ip
= va_arg(args
, int *);
1886 /* integer number formats - set up the flags and "break" */
1921 if (qualifier
== L
'I')
1922 num
= va_arg(args
, ULONGLONG
);
1923 else if (qualifier
== L
'l') {
1925 num
= va_arg(args
, long);
1927 num
= va_arg(args
, unsigned long);
1929 else if (qualifier
== L
'h') {
1931 num
= va_arg(args
, int);
1933 num
= va_arg(args
, unsigned int);
1935 else if (flags
& SIGN
)
1936 num
= va_arg(args
, int);
1938 num
= va_arg(args
, unsigned int);
1939 result
= wnumber(f
, num
, base
, field_width
, precision
, flags
);
1942 assert(!"TODO FIXME handle error better");