Author: cwittich Date: Mon Dec 27 09:07:27 2010 New Revision: 50153
URL: http://svn.reactos.org/svn/reactos?rev=50153&view=rev Log: [CRT] import MSVCRT_I10_OUTPUT from wine
Added: trunk/reactos/lib/sdk/crt/misc/i10output.c (with props) Modified: trunk/reactos/lib/sdk/crt/crt.rbuild trunk/reactos/lib/sdk/crt/misc/stubs.c
Modified: trunk/reactos/lib/sdk/crt/crt.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/crt.rbuild?rev=... ============================================================================== --- trunk/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] Mon Dec 27 09:07:27 2010 @@ -314,6 +314,7 @@ <file>assert.c</file> <file>environ.c</file> <file>getargs.c</file> + <file>i10output.c</file> <file>initterm.c</file> <file>lock.c</file> <file>purecall.c</file>
Added: trunk/reactos/lib/sdk/crt/misc/i10output.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/misc/i10output.... ============================================================================== --- trunk/reactos/lib/sdk/crt/misc/i10output.c (added) +++ trunk/reactos/lib/sdk/crt/misc/i10output.c [iso-8859-1] Mon Dec 27 09:07:27 2010 @@ -1,0 +1,99 @@ +#include <precomp.h> + +#define I10_OUTPUT_MAX_PREC 21 +/* Internal structure used by $I10_OUTPUT */ +struct _I10_OUTPUT_DATA { + short pos; + char sign; + BYTE len; + char str[I10_OUTPUT_MAX_PREC+1]; /* add space for '\0' */ +}; + +/********************************************************************* + * $I10_OUTPUT (MSVCRT.@) + * ld - long double to be printed to data + * prec - precision of part, we're interested in + * flag - 0 for first prec digits, 1 for fractional part + * data - data to be populated + * + * return value + * 0 if given double is NaN or INF + * 1 otherwise + * + * FIXME + * Native sets last byte of data->str to '0' or '9', I don't know what + * it means. Current implementation sets it always to '0'. + */ +int CDECL MSVCRT_I10_OUTPUT(long double ld, int prec, int flag, struct _I10_OUTPUT_DATA *data) +{ + static const char inf_str[] = "1#INF"; + static const char nan_str[] = "1#QNAN"; + + double d = ld; + char format[8]; + char buf[I10_OUTPUT_MAX_PREC+9]; /* 9 = strlen("0.e+0000") + '\0' */ + char *p; + + TRACE("(%lf %d %x %p)\n", d, prec, flag, data); + + if(d<0) { + data->sign = '-'; + d = -d; + } else + data->sign = ' '; + + if(isinf(d)) { + data->pos = 1; + data->len = 5; + memcpy(data->str, inf_str, sizeof(inf_str)); + + return 0; + } + + if(isnan(d)) { + data->pos = 1; + data->len = 6; + memcpy(data->str, nan_str, sizeof(nan_str)); + + return 0; + } + + if(flag&1) { + int exp = 1+floor(log10(d)); + + prec += exp; + if(exp < 0) + prec--; + } + prec--; + + if(prec+1 > I10_OUTPUT_MAX_PREC) + prec = I10_OUTPUT_MAX_PREC-1; + else if(prec < 0) { + d = 0.0; + prec = 0; + } + + sprintf(format, "%%.%dle", prec); + sprintf(buf, format, d); + + buf[1] = buf[0]; + data->pos = atoi(buf+prec+3); + if(buf[1] != '0') + data->pos++; + + for(p = buf+prec+1; p>buf+1 && *p=='0'; p--); + data->len = p-buf; + + memcpy(data->str, buf+1, data->len); + data->str[data->len] = '\0'; + + if(buf[1]!='0' && prec-data->len+1>0) + memcpy(data->str+data->len+1, buf+data->len+1, prec-data->len+1); + + return 1; +} +#undef I10_OUTPUT_MAX_PREC + + +
Propchange: trunk/reactos/lib/sdk/crt/misc/i10output.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/lib/sdk/crt/misc/stubs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/misc/stubs.c?re... ============================================================================== --- trunk/reactos/lib/sdk/crt/misc/stubs.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/misc/stubs.c [iso-8859-1] Mon Dec 27 09:07:27 2010 @@ -4,15 +4,6 @@ { FIXME("%p %p %s %x stub\n", value, endptr, str, flags ); return 0; -} - -/********************************************************************* - * $I10_OUTPUT (MSVCRT.@) - * Function not really understood but needed to make the DLL work - */ -void MSVCRT_I10_OUTPUT(void) -{ - /* FIXME: This is probably data, not a function */ }
void __fileinfo(void)