/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <stdarg.h>
-#include <stdio.h>
-#include <malloc.h>
-#include <internal/file.h>
-
-#ifdef __USE_W32API
-#include <ntdef.h>
-#endif
-
-
+#include <precomp.h>
extern int __mb_cur_max;
-
-
-
int __vfprintf(FILE*, const char*, va_list);
-
/*
* @implemented
*/
if (f->_flag & _IONBF) {
f->_flag &= ~_IONBF;
f->_ptr = f->_base = localbuf;
- f->_bufsiz = BUFSIZ;
+ f->_bufsiz = f->_cnt = BUFSIZ;
len = __vfprintf(f, fmt, ap);
(void)fflush(f);
f->_flag |= _IONBF;
#include <ctype.h>
#include <string.h>
-#include <stdio.h>
#include <math.h>
#include <internal/ieee.h>
double* __n;
double_t* n;
} n;
-
+
n.__n = &__n;
+
+ if ( exp_sign == L'g' || exp_sign == L'G' || exp_sign == L'e' || exp_sign == L'E' )
+ {
+ if ( 0 == n.n->mantissal && 0 == n.n->mantissah && 0 == n.n->exponent )
+ {
+ ie = 0;
+ }
+ else
+ {
+ ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff);
+ }
+
+ exponent = ie/3.321928;
+ }
- if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) {
- ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff);
- exponent = ie/3.321928;
- }
if ( exp_sign == 'g' || exp_sign == 'G' ) {
type |= ZEROTRUNC;
if ( exponent < -4 || fabs(exponent) >= precision )
exp_sign -= 2; // g -> e and G -> E
+ else
+ exp_sign = 'f';
}
if ( exp_sign == 'e' || exp_sign == 'E' ) {
}
tmp = buf;
+
if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) ) {
j = 0;
- while ( j < i && ( *tmp == '0' || *tmp == '.' )) {
+ while ( j < i && *tmp == L'0' ) {
+ tmp++;
+ i--;
+ }
+ if ( j < i && *tmp == L'.' ) {
tmp++;
i--;
}
}
+
+
// else
// while (i < precision--)
// putc('0', f);
static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int precision, int flags)
{
int i, done = 0;
+ char * mb;
if (sw == NULL)
{
sw = L"<NULL>";
return -1;
done++;
}
+ mb = malloc(MB_CUR_MAX * sizeof(char));
+ if(!mb)
+ return -1;
for (i = 0; i < len; ++i)
{
-//#define MB_CUR_MAX 1
- char mb[MB_CUR_MAX];
int mbcount, j;
mbcount = wctomb(mb, *sw++);
if (mbcount <= 0)
for (j = 0; j < mbcount; j++)
{
if (putc(mb[j], f) == EOF)
+ {
+ free(mb);
return -1;
+ }
done++;
}
}
while (len < field_width--)
{
if (putc(' ', f) == EOF)
+ {
+ free(mb);
return -1;
+ }
done++;
}
+ free(mb);
return done;
}