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 along
13 * with this program; if not, write to the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 // For character conversion functions like "wctomb" and "alloca" under Unix
21 // Under Win32 hosts, "alloca" is not defined by stdlib.h, but by malloc.h
22 // On the other hand, malloc.h is deprecated under some Unix hosts, so only include it for Win32 hosts.
33 #define _finite __finite
34 #define _isnan __isnan
38 inline int iswdigit ( wchar_t c
)
40 return ( c
>= L
'0' && c
<= L
'9' );
49 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__sun__) || defined(__CYGWIN__)
50 # define __isnan isnan
51 # define __finite finite
52 # define powl __builtin_powl
53 # define modfl __builtin_modfl
57 #define alloca _alloca
61 typedef __int64 LONGLONG
;
62 typedef unsigned __int64 ULONGLONG
;
64 typedef long long LONGLONG
;
65 typedef unsigned long long ULONGLONG
;
69 unsigned int mantissa
:23;
70 unsigned int exponent
:8;
75 unsigned int mantissal
:32;
76 unsigned int mantissah
:20;
77 unsigned int exponent
:11;
82 unsigned int mantissal
:32;
83 unsigned int mantissah
:32;
84 unsigned int exponent
:15;
86 unsigned int empty
:16;
90 ssprintf ( const char* fmt
, ... )
94 std::string f
= ssvprintf ( fmt
, arg
);
100 sswprintf ( const wchar_t* fmt
, ... )
104 std::wstring f
= sswvprintf ( fmt
, arg
);
109 #define ZEROPAD 1 /* pad with zero */
110 #define SIGN 2 /* unsigned/signed long */
111 #define PLUS 4 /* show plus */
112 #define SPACE 8 /* space if plus */
113 #define LEFT 16 /* left justified */
114 #define SPECIAL 32 /* 0x */
115 #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
116 #define ZEROTRUNC 128 /* truncate zero 's */
120 skip_atoi(const char **s
)
125 i
= i
*10 + *((*s
)++) - '0';
130 skip_wtoi(const wchar_t **s
)
134 while (iswdigit(**s
))
135 i
= i
*10 + *((*s
)++) - L
'0';
141 do_div(LONGLONG
*n
,int base
)
143 int __res
= ((ULONGLONG
) *n
) % (unsigned) base
;
144 *n
= ((ULONGLONG
) *n
) / (unsigned) base
;
150 number(std::string
& f
, LONGLONG num
, int base
, int size
, int precision
,int type
)
153 const char *digits
="0123456789abcdefghijklmnopqrstuvwxyz";
157 digits
= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
160 if (base
< 2 || base
> 36)
162 c
= (type
& ZEROPAD
) ? '0' : ' ';
169 } else if (type
& PLUS
) {
172 } else if (type
& SPACE
) {
177 if (type
& SPECIAL
) {
186 else while (num
!= 0)
187 tmp
[i
++] = digits
[do_div(&num
,base
)];
191 if (!(type
&(ZEROPAD
+LEFT
)))
211 while (i
< precision
--)
227 wnumber(std::wstring
& f
, LONGLONG num
, int base
, int size
, int precision
,int type
)
229 wchar_t c
,sign
,tmp
[66];
230 const wchar_t *digits
= L
"0123456789abcdefghijklmnopqrstuvwxyz";
234 digits
= L
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
237 if (base
< 2 || base
> 36)
239 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
246 } else if (type
& PLUS
) {
249 } else if (type
& SPACE
) {
254 if (type
& SPECIAL
) {
263 else while (num
!= 0)
264 tmp
[i
++] = digits
[do_div(&num
,base
)];
268 if (!(type
&(ZEROPAD
+LEFT
)))
288 while (i
< precision
--)
305 numberf(std::string
& f
, double __n
, char exp_sign
, int size
, int precision
, int type
)
307 double exponent
= 0.0;
317 char *buf
, *tmp
, sign
, c
;
328 if ( exp_sign
== 'g' || exp_sign
== 'G' || exp_sign
== 'e' || exp_sign
== 'E' )
330 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3ff);
331 exponent
= ie
/3.321928;
334 if ( exp_sign
== 'g' || exp_sign
== 'G' )
337 if ( exponent
< -4 || fabs(exponent
) >= precision
)
338 exp_sign
-= 2; // g -> e and G -> E
343 if ( exp_sign
== 'e' || exp_sign
== 'E' )
345 frac
= modf(exponent
,&e
);
348 else if ( frac
< -0.5 )
351 result
= numberf(f
,__n
/pow(10.0L,(long double)e
),'f',size
-4, precision
, type
);
361 result
= number(f
,ie
, 10,2, 2,type
);
367 if ( exp_sign
== 'f' )
369 buf
= (char*)alloca(4096);
373 c
= (type
& ZEROPAD
) ? '0' : ' ';
383 else if (type
& PLUS
)
388 else if (type
& SPACE
)
395 frac
= modf(__n
,&intr
);
397 // # flags forces a . and prevents trucation of trailing zero's
404 frac
= modf(frac
, &p
);
405 buf
[i
] = (int)p
+ '0';
415 if ( precision
>= 1 || type
& SPECIAL
)
437 buf
[i
++] = (int)p
+ '0';
443 while ( j
< i
&& ro
== 1)
445 if ( buf
[j
] >= '0' && buf
[j
] <= '8' )
450 else if ( buf
[j
] == '9' )
461 if (!(type
&(ZEROPAD
+LEFT
)))
471 if (!(type
&(ZEROPAD
+LEFT
)))
484 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
487 while ( j
< i
&& ( *tmp
== '0' || *tmp
== '.' ))
506 wnumberf(std::wstring
& f
, double __n
, wchar_t exp_sign
, int size
, int precision
, int type
)
508 double exponent
= 0.0;
518 wchar_t *buf
, *tmp
, sign
, c
;
529 if ( exp_sign
== L
'g' || exp_sign
== L
'G' || exp_sign
== L
'e' || exp_sign
== L
'E' )
531 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3ff);
532 exponent
= ie
/3.321928;
535 if ( exp_sign
== L
'g' || exp_sign
== L
'G' )
538 if ( exponent
< -4 || fabs(exponent
) >= precision
)
539 exp_sign
-= 2; // g -> e and G -> E
544 if ( exp_sign
== L
'e' || exp_sign
== L
'E' )
546 frac
= modf(exponent
,&e
);
549 else if ( frac
< -0.5 )
552 result
= wnumberf(f
,__n
/pow(10.0L,(long double) e
),L
'f',size
-4, precision
, type
);
562 result
= wnumber(f
,ie
, 10,2, 2,type
);
568 if ( exp_sign
== L
'f' )
570 buf
= (wchar_t*)alloca(4096*sizeof(wchar_t));
574 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
584 else if (type
& PLUS
)
589 else if (type
& SPACE
)
596 frac
= modf(__n
,&intr
);
598 // # flags forces a . and prevents trucation of trailing zero's
605 frac
= modf(frac
, &p
);
606 buf
[i
] = (int)p
+ L
'0';
616 if ( precision
>= 1 || type
& SPECIAL
)
638 buf
[i
++] = (int)p
+ L
'0';
644 while ( j
< i
&& ro
== 1)
646 if ( buf
[j
] >= L
'0' && buf
[j
] <= L
'8' )
651 else if ( buf
[j
] == L
'9' )
662 if (!(type
&(ZEROPAD
+LEFT
)))
672 if (!(type
&(ZEROPAD
+LEFT
)))
685 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
688 while ( j
< i
&& ( *tmp
== L
'0' || *tmp
== L
'.' ))
707 numberfl(std::string
& f
, long double __n
, char exp_sign
, int size
, int precision
, int type
)
709 long double exponent
= 0.0;
717 long double frac
, intr
;
719 char *buf
, *tmp
, sign
, c
;
725 ieee_long_double_t
* n
;
730 if ( exp_sign
== 'g' || exp_sign
== 'G' || exp_sign
== 'e' || exp_sign
== 'E' )
732 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3fff);
733 exponent
= ie
/3.321928;
736 if ( exp_sign
== 'g' || exp_sign
== 'G' )
739 if ( exponent
< -4 || fabs(exponent
) >= precision
)
740 exp_sign
-= 2; // g -> e and G -> E
745 if ( exp_sign
== 'e' || exp_sign
== 'E' )
747 frac
= modfl(exponent
,&e
);
750 else if ( frac
< -0.5 )
753 result
= numberf(f
,__n
/powl(10.0L,e
),'f',size
-4, precision
, type
);
763 result
= number(f
,ie
, 10,2, 2,type
);
769 if ( exp_sign
== 'f' )
771 buf
= (char*)alloca(4096);
775 c
= (type
& ZEROPAD
) ? '0' : ' ';
785 else if (type
& PLUS
)
790 else if (type
& SPACE
)
797 frac
= modfl(__n
,&intr
);
799 // # flags forces a . and prevents trucation of trailing zero's
806 frac
= modfl((long double)frac
, &p
);
807 buf
[i
] = (int)p
+ '0';
817 if ( precision
>= 1 || type
& SPECIAL
)
839 buf
[i
++] = (int)p
+ '0';
845 while ( j
< i
&& ro
== 1)
847 if ( buf
[j
] >= '0' && buf
[j
] <= '8' )
852 else if ( buf
[j
] == '9' )
863 if (!(type
&(ZEROPAD
+LEFT
)))
873 if (!(type
&(ZEROPAD
+LEFT
)))
886 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
889 while ( j
< i
&& ( *tmp
== '0' || *tmp
== '.' ))
908 wnumberfl(std::wstring
& f
, long double __n
, wchar_t exp_sign
, int size
, int precision
, int type
)
910 long double exponent
= 0.0;
918 long double frac
, intr
;
920 wchar_t *buf
, *tmp
, sign
, c
;
926 ieee_long_double_t
* n
;
931 if ( exp_sign
== L
'g' || exp_sign
== L
'G' || exp_sign
== L
'e' || exp_sign
== L
'E' )
933 ie
= ((unsigned int)n
.n
->exponent
- (unsigned int)0x3fff);
934 exponent
= ie
/3.321928;
937 if ( exp_sign
== L
'g' || exp_sign
== L
'G' )
940 if ( exponent
< -4 || fabs(exponent
) >= precision
)
941 exp_sign
-= 2; // g -> e and G -> E
946 if ( exp_sign
== L
'e' || exp_sign
== L
'E' )
948 frac
= modfl(exponent
,&e
);
951 else if ( frac
< -0.5 )
954 result
= wnumberf(f
,__n
/powl(10.0L,e
),L
'f',size
-4, precision
, type
);
964 result
= wnumber(f
,ie
, 10,2, 2,type
);
970 if ( exp_sign
== L
'f' )
972 buf
= (wchar_t*)alloca(4096*sizeof(wchar_t));
976 c
= (type
& ZEROPAD
) ? L
'0' : L
' ';
986 else if (type
& PLUS
)
991 else if (type
& SPACE
)
998 frac
= modfl(__n
,&intr
);
1000 // # flags forces a . and prevents trucation of trailing zero's
1001 if ( precision
> 0 )
1007 frac
= modfl((long double)frac
, &p
);
1008 buf
[i
] = (int)p
+ L
'0';
1018 if ( precision
>= 1 || type
& SPECIAL
)
1032 while ( intr
> 0.0 )
1040 buf
[i
++] = (int)p
+ L
'0';
1046 while ( j
< i
&& ro
== 1)
1048 if ( buf
[j
] >= L
'0' && buf
[j
] <= L
'8' )
1053 else if ( buf
[j
] == L
'9' )
1064 if (!(type
&(ZEROPAD
+LEFT
)))
1074 if (!(type
&(ZEROPAD
+LEFT
)))
1087 if ( type
& ZEROTRUNC
&& ((type
& SPECIAL
) != SPECIAL
) )
1090 while ( j
< i
&& ( *tmp
== L
'0' || *tmp
== L
'.' ))
1109 do_string(std::string
& f
, const char* s
, int len
, int field_width
, int precision
, int flags
)
1122 while ((unsigned int)len
< (unsigned int)precision
&& s
[len
])
1127 if ((unsigned int)len
> (unsigned int)precision
)
1131 if (!(flags
& LEFT
))
1132 while (len
< field_width
--)
1137 for (i
= 0; i
< len
; ++i
)
1142 while (len
< field_width
--)
1151 do_wstring(std::wstring
& f
, const wchar_t* s
, int len
, int field_width
, int precision
, int flags
)
1164 while ((unsigned int)len
< (unsigned int)precision
&& s
[len
])
1169 if ((unsigned int)len
> (unsigned int)precision
)
1173 if (!(flags
& LEFT
))
1174 while (len
< field_width
--)
1179 for (i
= 0; i
< len
; ++i
)
1184 while (len
< field_width
--)
1193 stringw(std::string
& f
, const wchar_t* sw
, int len
, int field_width
, int precision
, int flags
)
1206 while ((unsigned int)len
< (unsigned int)precision
&& sw
[len
])
1211 if ((unsigned int)len
> (unsigned int)precision
)
1215 if (!(flags
& LEFT
))
1216 while (len
< field_width
--)
1221 for (i
= 0; i
< len
; ++i
)
1223 #define MY_MB_CUR_MAX 1
1224 char mb
[MY_MB_CUR_MAX
];
1226 mbcount
= wctomb(mb
, *sw
++);
1231 for (j
= 0; j
< mbcount
; j
++)
1237 while (len
< field_width
--)
1246 wstringa(std::wstring
& f
, const char* sa
, int len
, int field_width
, int precision
, int flags
)
1259 while ((unsigned int)len
< (unsigned int)precision
&& sa
[len
])
1264 if ((unsigned int)len
> (unsigned int)precision
)
1268 if (!(flags
& LEFT
))
1269 while (len
< field_width
--)
1274 for (i
= 0; i
< len
;)
1278 mbcount
= mbtowc(&w
, sa
+i
, len
-i
);
1285 while (len
< field_width
--)
1293 #define _isnanl _isnan
1294 #define _finitel _finite
1297 ssvprintf ( const char *fmt
, va_list args
)
1301 long double _ldouble
;
1308 int flags
; /* flags to number() */
1310 int field_width
; /* width of output field */
1311 int precision
; /* min. # of digits for integers; max
1312 number of chars for from string */
1313 int qualifier
= 0; /* 'h', 'l', 'L' or 'I64' for integer fields */
1315 for (; *fmt
; ++fmt
)
1326 ++fmt
; /* this also skips first '%' */
1328 case '-': flags
|= LEFT
; goto repeat
;
1329 case '+': flags
|= PLUS
; goto repeat
;
1330 case ' ': flags
|= SPACE
; goto repeat
;
1331 case '#': flags
|= SPECIAL
; goto repeat
;
1332 case '0': flags
|= ZEROPAD
; goto repeat
;
1335 /* get field width */
1338 field_width
= skip_atoi(&fmt
);
1339 else if (*fmt
== '*') {
1341 /* it's the next argument */
1342 field_width
= va_arg(args
, int);
1343 if (field_width
< 0) {
1344 field_width
= -field_width
;
1349 /* get the precision */
1354 precision
= skip_atoi(&fmt
);
1355 else if (*fmt
== '*') {
1357 /* it's the next argument */
1358 precision
= va_arg(args
, int);
1364 /* get the conversion qualifier */
1366 // %Z can be just stand alone or as size_t qualifier
1367 if ( *fmt
== 'Z' ) {
1369 switch ( *(fmt
+1)) {
1382 } else if (*fmt
== 'h' || *fmt
== 'l' || *fmt
== 'L' || *fmt
== 'w') {
1385 } else if (*fmt
== 'I' && *(fmt
+1) == '6' && *(fmt
+2) == '4') {
1390 // go fine with ll instead of L
1391 if ( *fmt
== 'l' ) {
1401 if (!(flags
& LEFT
))
1402 while (--field_width
> 0)
1406 if (qualifier
== 'l' || qualifier
== 'w')
1408 f
+= (char)(unsigned char)(wchar_t) va_arg(args
,int);
1412 f
+= (char)(unsigned char) va_arg(args
,int);
1414 while (--field_width
> 0)
1421 if (!(flags
& LEFT
))
1422 while (--field_width
> 0)
1426 if (qualifier
== 'h')
1428 f
+= (char)(unsigned char) va_arg(args
,int);
1432 f
+= (char)(unsigned char)(wchar_t) va_arg(args
,int);
1434 while (--field_width
> 0)
1441 if (qualifier
== 'l' || qualifier
== 'w') {
1442 /* print unicode string */
1443 sw
= va_arg(args
, wchar_t *);
1444 result
= stringw(f
, sw
, -1, field_width
, precision
, flags
);
1446 /* print ascii string */
1447 s
= va_arg(args
, char *);
1448 result
= do_string(f
, s
, -1, field_width
, precision
, flags
);
1452 assert(!"TODO FIXME handle error better");
1458 if (qualifier
== 'h') {
1459 /* print ascii string */
1460 s
= va_arg(args
, char *);
1461 result
= do_string(f
, s
, -1, field_width
, precision
, flags
);
1463 /* print unicode string */
1464 sw
= va_arg(args
, wchar_t *);
1465 result
= stringw(f
, sw
, -1, field_width
, precision
, flags
);
1469 assert(!"TODO FIXME handle error better");
1475 if (qualifier == 'w') {
1476 // print counted unicode string
1477 PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
1478 if ((pus == NULL) || (pus->Buffer == NULL)) {
1483 len = pus->Length / sizeof(WCHAR);
1485 result = stringw(f, sw, len, field_width, precision, flags);
1487 // print counted ascii string
1488 PANSI_STRING pas = va_arg(args, PANSI_STRING);
1489 if ((pas == NULL) || (pas->Buffer == NULL)) {
1496 result = string(f, s, -1, field_width, precision, flags);
1507 if (qualifier
== 'l' || qualifier
== 'L' ) {
1508 _ldouble
= va_arg(args
, long double);
1510 if ( _isnanl(_ldouble
) )
1514 else if ( !_finitel(_ldouble
) )
1521 if ( precision
== -1 )
1523 result
= numberfl(f
,_ldouble
,*fmt
,field_width
,precision
,flags
);
1526 assert(!"TODO FIXME handle error better");
1531 _double
= (double)va_arg(args
, double);
1533 if ( _isnan(_double
) )
1537 else if ( !_finite(_double
) )
1546 if ( precision
== -1 )
1548 result
= numberf(f
,_double
,*fmt
,field_width
,precision
,flags
);
1551 assert(!"TODO FIXME handle error better");
1559 if (field_width
== -1) {
1560 field_width
= 2*sizeof(void *);
1564 (size_t) va_arg(args
, void *), 16,
1565 field_width
, precision
, flags
);
1568 assert(!"TODO FIXME handle error better");
1574 if (qualifier
== 'l') {
1575 long * ip
= va_arg(args
, long *);
1578 int * ip
= va_arg(args
, int *);
1583 /* integer number formats - set up the flags and "break" */
1618 if (qualifier
== 'I')
1619 num
= va_arg(args
, ULONGLONG
);
1620 else if (qualifier
== 'l') {
1622 num
= va_arg(args
, long);
1624 num
= va_arg(args
, unsigned long);
1626 else if (qualifier
== 'h') {
1628 num
= va_arg(args
, int);
1630 num
= va_arg(args
, unsigned int);
1632 else if (flags
& SIGN
)
1633 num
= va_arg(args
, int);
1635 num
= va_arg(args
, unsigned int);
1636 result
= number(f
, num
, base
, field_width
, precision
, flags
);
1639 assert(!"TODO FIXME handle error better");
1648 sswvprintf ( const wchar_t* fmt
, va_list args
)
1652 long double _ldouble
;
1659 int flags
; /* flags to number() */
1661 int field_width
; /* width of output field */
1662 int precision
; /* min. # of digits for integers; max
1663 number of chars for from string */
1664 int qualifier
= 0; /* 'h', 'l', 'L' or 'I64' for integer fields */
1666 for (; *fmt
; ++fmt
)
1677 ++fmt
; /* this also skips first '%' */
1679 case L
'-': flags
|= LEFT
; goto repeat
;
1680 case L
'+': flags
|= PLUS
; goto repeat
;
1681 case L
' ': flags
|= SPACE
; goto repeat
;
1682 case L
'#': flags
|= SPECIAL
; goto repeat
;
1683 case L
'0': flags
|= ZEROPAD
; goto repeat
;
1686 /* get field width */
1689 field_width
= skip_wtoi(&fmt
);
1690 else if (*fmt
== L
'*') {
1692 /* it's the next argument */
1693 field_width
= va_arg(args
, int);
1694 if (field_width
< 0) {
1695 field_width
= -field_width
;
1700 /* get the precision */
1705 precision
= skip_wtoi(&fmt
);
1706 else if (*fmt
== L
'*') {
1708 /* it's the next argument */
1709 precision
= va_arg(args
, int);
1715 /* get the conversion qualifier */
1717 // %Z can be just stand alone or as size_t qualifier
1718 if ( *fmt
== L
'Z' ) {
1720 switch ( *(fmt
+1)) {
1733 } else if (*fmt
== L
'h' || *fmt
== L
'l' || *fmt
== L
'L' || *fmt
== L
'w') {
1736 } else if (*fmt
== L
'I' && *(fmt
+1) == L
'6' && *(fmt
+2) == L
'4') {
1741 // go fine with ll instead of L
1742 if ( *fmt
== L
'l' ) {
1752 if (!(flags
& LEFT
))
1753 while (--field_width
> 0)
1757 if ( qualifier
== L
'h' )
1759 f
+= (wchar_t)(char)(unsigned char) va_arg(args
,int);
1763 f
+= (wchar_t) va_arg(args
,int);
1765 while (--field_width
> 0)
1772 if (!(flags
& LEFT
))
1773 while (--field_width
> 0)
1777 if (qualifier
== L
'l' || qualifier
== L
'w')
1779 f
+= (wchar_t) va_arg(args
,int);
1783 f
+= (wchar_t)(char)(unsigned char) va_arg(args
,int);
1785 while (--field_width
> 0)
1792 if (qualifier
== L
'h') {
1793 /* print ascii string */
1794 sa
= va_arg(args
, char *);
1795 result
= wstringa(f
, sa
, -1, field_width
, precision
, flags
);
1797 /* print unicode string */
1798 s
= va_arg(args
, wchar_t *);
1799 result
= do_wstring(f
, s
, -1, field_width
, precision
, flags
);
1803 assert(!"TODO FIXME handle error better");
1809 if (qualifier
== L
'l' || qualifier
== L
'w') {
1810 /* print unicode string */
1811 s
= va_arg(args
, wchar_t *);
1812 result
= do_wstring(f
, s
, -1, field_width
, precision
, flags
);
1814 /* print ascii string */
1815 sa
= va_arg(args
, char *);
1816 result
= wstringa(f
, sa
, -1, field_width
, precision
, flags
);
1820 assert(!"TODO FIXME handle error better");
1830 if (qualifier
== L
'l' || qualifier
== L
'L' )
1832 _ldouble
= va_arg(args
, long double);
1834 if ( _isnanl(_ldouble
) )
1838 else if ( !_finitel(_ldouble
) )
1845 if ( precision
== -1 )
1847 result
= wnumberfl(f
,_ldouble
,*fmt
,field_width
,precision
,flags
);
1850 assert(!"TODO FIXME handle error better");
1855 _double
= (double)va_arg(args
, double);
1857 if ( _isnan(_double
) )
1861 else if ( !_finite(_double
) )
1870 if ( precision
== -1 )
1872 result
= wnumberf(f
,_double
,*fmt
,field_width
,precision
,flags
);
1875 assert(!"TODO FIXME handle error better");
1883 if (field_width
== -1) {
1884 field_width
= 2*sizeof(void *);
1888 (size_t) va_arg(args
, void *), 16,
1889 field_width
, precision
, flags
);
1892 assert(!"TODO FIXME handle error better");
1898 if (qualifier
== L
'l') {
1899 long * ip
= va_arg(args
, long *);
1902 int * ip
= va_arg(args
, int *);
1907 /* integer number formats - set up the flags and "break" */
1942 if (qualifier
== L
'I')
1943 num
= va_arg(args
, ULONGLONG
);
1944 else if (qualifier
== L
'l') {
1946 num
= va_arg(args
, long);
1948 num
= va_arg(args
, unsigned long);
1950 else if (qualifier
== L
'h') {
1952 num
= va_arg(args
, int);
1954 num
= va_arg(args
, unsigned int);
1956 else if (flags
& SIGN
)
1957 num
= va_arg(args
, int);
1959 num
= va_arg(args
, unsigned int);
1960 result
= wnumber(f
, num
, base
, field_width
, precision
, flags
);
1963 assert(!"TODO FIXME handle error better");