msvcp60: Fixed num_get class implementataion.

This commit is contained in:
Piotr Caban 2012-11-14 15:38:54 +01:00 committed by Alexandre Julliard
parent b999c3e307
commit 8048d04e59
3 changed files with 68 additions and 266 deletions

View File

@ -4054,6 +4054,7 @@ ios_base* __thiscall ios_base_ctor(ios_base *this)
{
TRACE("(%p)\n", this);
this->vtable = &MSVCP_ios_base_vtable;
locale_ctor_uninitialized(&this->loc, 0);
return this;
}
@ -4110,10 +4111,7 @@ void CDECL ios_base_Tidy(ios_base *this)
static void ios_base_Ios_base_dtor(ios_base *obj)
{
TRACE("(%p)\n", obj);
if(obj->loc) {
locale_dtor(obj->loc);
MSVCRT_operator_delete(obj->loc);
}
locale_dtor(&obj->loc);
ios_base_Tidy(obj);
}
@ -4296,7 +4294,7 @@ ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
this->fmtfl = rhs->fmtfl;
this->prec = rhs->prec;
this->wide = rhs->wide;
locale_operator_assign(this->loc, rhs->loc);
locale_operator_assign(&this->loc, &rhs->loc);
for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
@ -4371,8 +4369,7 @@ void __thiscall ios_base__Init(ios_base *this)
this->wide = 0;
this->arr = NULL;
this->calls = NULL;
this->loc = MSVCRT_operator_new(sizeof(locale));
locale_ctor(this->loc);
locale_ctor(&this->loc);
}
/* ?bad@ios_base@std@@QBE_NXZ */
@ -4421,7 +4418,7 @@ DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
{
TRACE("(%p)\n", this);
return locale_copy_ctor(ret, this->loc);
return locale_copy_ctor(ret, &this->loc);
}
/* ?good@ios_base@std@@QBE_NXZ */
@ -4439,8 +4436,8 @@ DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
{
TRACE("(%p %p)\n", this, loc);
*ret = *this->loc;
locale_copy_ctor(this->loc, loc);
*ret = this->loc;
locale_copy_ctor(&this->loc, loc);
return ret;
}

View File

@ -3954,12 +3954,9 @@ static inline wchar_t mb_to_wc(char ch, const _Cvtvec *cvt)
static int num_get__Getffld(const num_get *this, char *dest, istreambuf_iterator_wchar *first,
istreambuf_iterator_wchar *last, const locale *loc, numpunct_wchar *numpunct)
{
basic_string_char grouping_bstr;
basic_string_char groups_found;
int i, groups_no = 0, cur_group = 0, exp = 0;
int i, exp = 0;
char *dest_beg = dest, *num_end = dest+25, *exp_end = dest+31;
wchar_t sep, digits[11], *digits_pos;
const char *grouping, *groups;
wchar_t digits[11], *digits_pos;
BOOL error = FALSE, got_digit = FALSE, got_nonzero = FALSE;
TRACE("(%p %p %p %p)\n", dest, first, last, loc);
@ -3968,13 +3965,6 @@ static int num_get__Getffld(const num_get *this, char *dest, istreambuf_iterator
digits[i] = mb_to_wc('0'+i, &this->cvt);
digits[10] = 0;
numpunct_wchar_grouping(numpunct, &grouping_bstr);
grouping = basic_string_char_c_str(&grouping_bstr);
sep = grouping[0] ? numpunct_wchar_thousands_sep(numpunct) : (wchar_t)0;
if(sep)
basic_string_char_ctor(&groups_found);
istreambuf_iterator_wchar_val(first);
/* get sign */
if(first->strbuf && first->val==mb_to_wc('-', &this->cvt)) {
@ -3985,32 +3975,20 @@ static int num_get__Getffld(const num_get *this, char *dest, istreambuf_iterator
istreambuf_iterator_wchar_inc(first);
}
/* read possibly grouped numbers before decimal */
/* read numbers before decimal */
for(; first->strbuf; istreambuf_iterator_wchar_inc(first)) {
if(!(digits_pos = wcschr(digits, first->val))) {
if(sep && first->val==sep) {
if(!groups_no) break; /* empty group - stop parsing */
basic_string_char_append_ch(&groups_found, groups_no);
groups_no = 0;
++cur_group;
}else {
break;
}
break;
}else {
got_digit = TRUE; /* found a digit, zero or non-zero */
/* write digit to dest if not a leading zero (to not waste dest buffer) */
if(!got_nonzero && first->val == digits[0])
{
++groups_no;
continue;
}
got_nonzero = TRUE;
if(dest < num_end)
*dest++ = '0'+digits_pos-digits;
else
exp++; /* too many digits, just multiply by 10 */
if(sep && groups_no<CHAR_MAX)
++groups_no;
}
}
/* if all leading zeroes, we didn't write anything so put a zero we check for a decimal */
@ -4069,31 +4047,6 @@ static int num_get__Getffld(const num_get *this, char *dest, istreambuf_iterator
}
}
if(sep && groups_no)
basic_string_char_append_ch(&groups_found, groups_no);
if(!cur_group) /* no groups, skip loop */
cur_group--;
else if(!(groups = basic_string_char_c_str(&groups_found))[cur_group])
error = TRUE; /* trailing empty */
for(; cur_group>=0 && !error; cur_group--) {
if(*grouping == CHAR_MAX) {
if(cur_group)
error = TRUE;
break;
}else if((cur_group && *grouping!=groups[cur_group])
|| (!cur_group && *grouping<groups[cur_group])) {
error = TRUE;
break;
}else if(grouping[1]) {
grouping++;
}
}
basic_string_char_dtor(&grouping_bstr);
if(sep)
basic_string_char_dtor(&groups_found);
if(error) {
*dest_beg = '\0';
return 0;
@ -4105,12 +4058,9 @@ static int num_get__Getffld(const num_get *this, char *dest, istreambuf_iterator
static int num_get__Getifld(const num_get *this, char *dest, istreambuf_iterator_wchar *first,
istreambuf_iterator_wchar *last, int fmtflags, const locale *loc, numpunct_wchar *numpunct)
{
wchar_t digits[23], *digits_pos, sep;
basic_string_char grouping_bstr;
basic_string_char groups_found;
int i, basefield, base, groups_no = 0, cur_group = 0;
wchar_t digits[23], *digits_pos;
int i, basefield, base;
char *dest_beg = dest, *dest_end = dest+24;
const char *grouping, *groups;
BOOL error = TRUE, dest_empty = TRUE, found_zero = FALSE;
TRACE("(%p %p %p %04x %p)\n", dest, first, last, fmtflags, loc);
@ -4122,10 +4072,6 @@ static int num_get__Getifld(const num_get *this, char *dest, istreambuf_iterator
digits[16+i] = mb_to_wc('A'+i, &this->cvt);
}
numpunct_wchar_grouping(numpunct, &grouping_bstr);
grouping = basic_string_char_c_str(&grouping_bstr);
sep = grouping[0] ? numpunct_wchar_thousands_sep(numpunct) : '\0';
basefield = fmtflags & FMTFLAG_basefield;
if(basefield == FMTFLAG_oct)
base = 8;
@ -4165,26 +4111,13 @@ static int num_get__Getifld(const num_get *this, char *dest, istreambuf_iterator
}
digits[base] = 0;
if(sep) {
basic_string_char_ctor(&groups_found);
if(found_zero) ++groups_no;
}
for(; first->strbuf; istreambuf_iterator_wchar_inc(first)) {
if(!(digits_pos = wcschr(digits, first->val))) {
if(sep && first->val==sep) {
if(!groups_no) break; /* empty group - stop parsing */
basic_string_char_append_ch(&groups_found, groups_no);
groups_no = 0;
++cur_group;
}else {
break;
}
break;
}else {
error = FALSE;
if(dest_empty && first->val == digits[0]) {
found_zero = TRUE;
++groups_no;
continue;
}
dest_empty = FALSE;
@ -4194,39 +4127,9 @@ static int num_get__Getifld(const num_get *this, char *dest, istreambuf_iterator
*dest++ = (digits_pos-digits<10 ? '0'+digits_pos-digits :
(digits_pos-digits<16 ? 'a'+digits_pos-digits-10 :
'A'+digits_pos-digits-16));
if(sep && groups_no<CHAR_MAX)
++groups_no;
}
}
if(sep && groups_no)
basic_string_char_append_ch(&groups_found, groups_no);
if(!cur_group) { /* no groups, skip loop */
cur_group--;
}else if(!(groups = basic_string_char_c_str(&groups_found))[cur_group]) {
error = TRUE; /* trailing empty */
found_zero = FALSE;
}
for(; cur_group>=0 && !error; cur_group--) {
if(*grouping == CHAR_MAX) {
if(cur_group)
error = TRUE;
break;
}else if((cur_group && *grouping!=groups[cur_group])
|| (!cur_group && *grouping<groups[cur_group])) {
error = TRUE;
break;
}else if(grouping[1]) {
grouping++;
}
}
basic_string_char_dtor(&grouping_bstr);
if(sep)
basic_string_char_dtor(&groups_found);
if(error) {
if (found_zero)
*dest++ = '0';
@ -4260,7 +4163,7 @@ static istreambuf_iterator_wchar* num_get_do_get_void(const num_get *this,
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stoullx(tmp, &end, num_get__Getifld(this, tmp, &first,
&last, FMTFLAG_hex, base->loc, numpunct), &err);
&last, FMTFLAG_hex, &base->loc, numpunct), &err);
if(v!=(unsigned __int64)((INT_PTR)v))
*state |= IOSTATE_failbit;
else if(end!=tmp && !err)
@ -4285,7 +4188,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_void(const num_get *t
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, void **pval)
{
return num_get_do_get_void(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAAPAX@Z */
@ -4295,7 +4198,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_void(const num_get *t
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, void **pval)
{
return num_get_do_get_void(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAAPAX@Z */
@ -4321,7 +4224,7 @@ static istreambuf_iterator_wchar* num_get_do_get_double(const num_get *this,
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stodx(tmp, &end, num_get__Getffld(this, tmp, &first, &last, base->loc, numpunct), &err);
v = _Stodx(tmp, &end, num_get__Getffld(this, tmp, &first, &last, &base->loc, numpunct), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -4349,7 +4252,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_double(const num_get
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, double *pval)
{
return num_get_do_get_double(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAAO@Z */
@ -4361,7 +4264,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_double(const num_get
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, double *pval)
{
return num_get_do_get_double(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAAO@Z */
@ -4400,7 +4303,7 @@ static istreambuf_iterator_wchar* num_get_do_get_float(const num_get *this,
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stofx(tmp, &end, num_get__Getffld(this, tmp, &first,
&last, base->loc, numpunct), &err);
&last, &base->loc, numpunct), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -4423,7 +4326,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_float(const num_get *
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, float *pval)
{
return num_get_do_get_float(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAAM@Z */
@ -4433,7 +4336,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_float(const num_get *
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, float *pval)
{
return num_get_do_get_float(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAAM@Z */
@ -4460,7 +4363,7 @@ static istreambuf_iterator_wchar* num_get_do_get_uint64(const num_get *this,
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stoullx(tmp, &end, num_get__Getifld(this, tmp, &first,
&last, base->fmtfl, base->loc, numpunct), &err);
&last, base->fmtfl, &base->loc, numpunct), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -4483,7 +4386,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_uint64(const num_get
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, ULONGLONG *pval)
{
return num_get_do_get_uint64(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAA_K@Z */
@ -4493,7 +4396,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_uint64(const num_get
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, ULONGLONG *pval)
{
return num_get_do_get_uint64(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAA_K@Z */
@ -4520,7 +4423,7 @@ static istreambuf_iterator_wchar* num_get_do_get_int64(const num_get *this,
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stollx(tmp, &end, num_get__Getifld(this, tmp, &first,
&last, base->fmtfl, base->loc, numpunct), &err);
&last, base->fmtfl, &base->loc, numpunct), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -4543,7 +4446,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_int64(const num_get *
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, LONGLONG *pval)
{
return num_get_do_get_int64(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAA_J@Z */
@ -4553,7 +4456,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_int64(const num_get *
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, LONGLONG *pval)
{
return num_get_do_get_int64(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAA_J@Z */
@ -4580,7 +4483,7 @@ static istreambuf_iterator_wchar* num_get_do_get_ulong(const num_get *this,
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stoulx(tmp, &end, num_get__Getifld(this, tmp, &first,
&last, base->fmtfl, base->loc, numpunct), &err);
&last, base->fmtfl, &base->loc, numpunct), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -4603,7 +4506,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_ulong(const num_get *
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, ULONG *pval)
{
return num_get_do_get_ulong(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAAK@Z */
@ -4613,7 +4516,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_ulong(const num_get *
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, ULONG *pval)
{
return num_get_do_get_ulong(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAAK@Z */
@ -4640,7 +4543,7 @@ static istreambuf_iterator_wchar* num_get_do_get_long(const num_get *this,
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stolx(tmp, &end, num_get__Getifld(this, tmp, &first,
&last, base->fmtfl, base->loc, numpunct), &err);
&last, base->fmtfl, &base->loc, numpunct), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -4663,7 +4566,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_long(const num_get *t
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, LONG *pval)
{
return num_get_do_get_long(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAAJ@Z */
@ -4673,7 +4576,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_long(const num_get *t
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, LONG *pval)
{
return num_get_do_get_long(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAAJ@Z */
@ -4739,7 +4642,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_ushort(const num_get
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
b = num_get_wchar__Getifld(this, tmp,
&first, &last, base->fmtfl, base->loc);
&first, &last, base->fmtfl, &base->loc);
beg = tmp + (tmp[0]=='-' ? 1 : 0);
v = _Stoulx(beg, &end, b, &err);
@ -4829,7 +4732,7 @@ static istreambuf_iterator_wchar* num_get_do_get_bool(const num_get *this,
char tmp[25], *end;
int err;
LONG v = _Stolx(tmp, &end, num_get__Getifld(this, tmp, &first,
&last, base->fmtfl, base->loc, numpunct), &err);
&last, base->fmtfl, &base->loc, numpunct), &err);
if(end!=tmp && err==0 && (v==0 || v==1))
*pval = v;
@ -4853,7 +4756,7 @@ istreambuf_iterator_wchar *__thiscall num_get_wchar_do_get_bool(const num_get *t
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, MSVCP_bool *pval)
{
return num_get_do_get_bool(this, ret, first, last, base,
state, pval, numpunct_wchar_use_facet(base->loc));
state, pval, numpunct_wchar_use_facet(&base->loc));
}
/* ?do_get@?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@GU?$char_traits@G@std@@@2@V32@0AAVios_base@2@AAHAA_N@Z */
@ -4863,7 +4766,7 @@ istreambuf_iterator_wchar *__thiscall num_get_short_do_get_bool(const num_get *t
istreambuf_iterator_wchar first, istreambuf_iterator_wchar last, ios_base *base, int *state, MSVCP_bool *pval)
{
return num_get_do_get_bool(this, ret, first, last, base,
state, pval, numpunct_short_use_facet(base->loc));
state, pval, numpunct_short_use_facet(&base->loc));
}
/* ?get@?$num_get@_WV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@QBE?AV?$istreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@0AAVios_base@2@AAHAA_N@Z */
@ -5023,22 +4926,12 @@ static int num_get_char__Getffld(const num_get *this, char *dest, istreambuf_ite
istreambuf_iterator_char *last, const locale *loc)
{
numpunct_char *numpunct = numpunct_char_use_facet(loc);
basic_string_char grouping_bstr;
basic_string_char groups_found;
int groups_no = 0, cur_group = 0, exp = 0;
char *dest_beg = dest, *num_end = dest+25, *exp_end = dest+31, sep;
const char *grouping, *groups;
int exp = 0;
char *dest_beg = dest, *num_end = dest+25, *exp_end = dest+31;
BOOL error = FALSE, got_digit = FALSE, got_nonzero = FALSE;
TRACE("(%p %p %p %p)\n", dest, first, last, loc);
numpunct_char_grouping(numpunct, &grouping_bstr);
grouping = basic_string_char_c_str(&grouping_bstr);
sep = grouping[0] ? numpunct_char_thousands_sep(numpunct) : '\0';
if(sep)
basic_string_char_ctor(&groups_found);
istreambuf_iterator_char_val(first);
/* get sign */
if(first->strbuf && (first->val=='-' || first->val=='+')) {
@ -5047,32 +4940,20 @@ static int num_get_char__Getffld(const num_get *this, char *dest, istreambuf_ite
}
/* read possibly grouped numbers before decimal */
/* read numbers before decimal */
for(; first->strbuf; istreambuf_iterator_char_inc(first)) {
if(first->val<'0' || first->val>'9') {
if(sep && first->val==sep) {
if(!groups_no) break; /* empty group - stop parsing */
basic_string_char_append_ch(&groups_found, groups_no);
groups_no = 0;
++cur_group;
}else {
break;
}
break;
}else {
got_digit = TRUE; /* found a digit, zero or non-zero */
/* write digit to dest if not a leading zero (to not waste dest buffer) */
if(!got_nonzero && first->val == '0')
{
++groups_no;
continue;
}
got_nonzero = TRUE;
if(dest < num_end)
*dest++ = first->val;
else
exp++; /* too many digits, just multiply by 10 */
if(sep && groups_no<CHAR_MAX)
++groups_no;
}
}
/* if all leading zeroes, we didn't write anything so put a zero we check for a decimal */
@ -5128,31 +5009,6 @@ static int num_get_char__Getffld(const num_get *this, char *dest, istreambuf_ite
}
}
if(sep && groups_no)
basic_string_char_append_ch(&groups_found, groups_no);
if(!cur_group) /* no groups, skip loop */
cur_group--;
else if(!(groups = basic_string_char_c_str(&groups_found))[cur_group])
error = TRUE; /* trailing empty */
for(; cur_group>=0 && !error; cur_group--) {
if(*grouping == CHAR_MAX) {
if(cur_group)
error = TRUE;
break;
}else if((cur_group && *grouping!=groups[cur_group])
|| (!cur_group && *grouping<groups[cur_group])) {
error = TRUE;
break;
}else if(grouping[1]) {
grouping++;
}
}
basic_string_char_dtor(&grouping_bstr);
if(sep)
basic_string_char_dtor(&groups_found);
if(error) {
*dest_beg = '\0';
return 0;
@ -5174,20 +5030,12 @@ static int num_get_char__Getifld(const num_get *this, char *dest, istreambuf_ite
{
static const char digits[] = "0123456789abcdefABCDEF";
numpunct_char *numpunct = numpunct_char_use_facet(loc);
basic_string_char grouping_bstr;
basic_string_char groups_found;
int basefield, base, groups_no = 0, cur_group = 0;
char *dest_beg = dest, *dest_end = dest+24, sep;
const char *grouping, *groups;
int basefield, base;
char *dest_beg = dest, *dest_end = dest+24;
BOOL error = TRUE, dest_empty = TRUE, found_zero = FALSE;
TRACE("(%p %p %p %04x %p)\n", dest, first, last, fmtflags, loc);
numpunct_char_grouping(numpunct, &grouping_bstr);
grouping = basic_string_char_c_str(&grouping_bstr);
sep = grouping[0] ? numpunct_char_thousands_sep(numpunct) : '\0';
basefield = fmtflags & FMTFLAG_basefield;
if(basefield == FMTFLAG_oct)
base = 8;
@ -5223,28 +5071,14 @@ static int num_get_char__Getifld(const num_get *this, char *dest, istreambuf_ite
if (!base) base = 10;
}
if(sep)
{
basic_string_char_ctor(&groups_found);
if(found_zero) ++groups_no;
}
for(; first->strbuf; istreambuf_iterator_char_inc(first)) {
if(!memchr(digits, first->val, base)) {
if(sep && first->val==sep) {
if(!groups_no) break; /* empty group - stop parsing */
basic_string_char_append_ch(&groups_found, groups_no);
groups_no = 0;
++cur_group;
}else {
break;
}
break;
}else {
error = FALSE;
if(dest_empty && first->val == '0')
{
found_zero = TRUE;
++groups_no;
continue;
}
dest_empty = FALSE;
@ -5252,39 +5086,9 @@ static int num_get_char__Getifld(const num_get *this, char *dest, istreambuf_ite
* functions are responsible for detecting overflows */
if(dest < dest_end)
*dest++ = first->val;
if(sep && groups_no<CHAR_MAX)
++groups_no;
}
}
if(sep && groups_no)
basic_string_char_append_ch(&groups_found, groups_no);
if(!cur_group) { /* no groups, skip loop */
cur_group--;
}else if(!(groups = basic_string_char_c_str(&groups_found))[cur_group]) {
error = TRUE; /* trailing empty */
found_zero = FALSE;
}
for(; cur_group>=0 && !error; cur_group--) {
if(*grouping == CHAR_MAX) {
if(cur_group)
error = TRUE;
break;
}else if((cur_group && *grouping!=groups[cur_group])
|| (!cur_group && *grouping<groups[cur_group])) {
error = TRUE;
break;
}else if(grouping[1]) {
grouping++;
}
}
basic_string_char_dtor(&grouping_bstr);
if(sep)
basic_string_char_dtor(&groups_found);
if(error) {
if (found_zero)
*dest++ = '0';
@ -5313,7 +5117,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_void(const num_get *thi
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stoullx(tmp, &end, num_get_char__Getifld(this, tmp,
&first, &last, FMTFLAG_hex, base->loc), &err);
&first, &last, FMTFLAG_hex, &base->loc), &err);
if(v!=(unsigned __int64)((INT_PTR)v))
*state |= IOSTATE_failbit;
else if(end!=tmp && !err)
@ -5358,7 +5162,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_double(const num_get *t
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stodx(tmp, &end, num_get_char__Getffld(this, tmp, &first, &last, base->loc), &err);
v = _Stodx(tmp, &end, num_get_char__Getffld(this, tmp, &first, &last, &base->loc), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -5406,7 +5210,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_float(const num_get *th
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stofx(tmp, &end, num_get_char__Getffld(this, tmp, &first, &last, base->loc), &err);
v = _Stofx(tmp, &end, num_get_char__Getffld(this, tmp, &first, &last, &base->loc), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -5445,7 +5249,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_uint64(const num_get *t
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stoullx(tmp, &end, num_get_char__Getifld(this, tmp,
&first, &last, base->fmtfl, base->loc), &err);
&first, &last, base->fmtfl, &base->loc), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -5484,7 +5288,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_int64(const num_get *th
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stollx(tmp, &end, num_get_char__Getifld(this, tmp,
&first, &last, base->fmtfl, base->loc), &err);
&first, &last, base->fmtfl, &base->loc), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -5523,7 +5327,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_ulong(const num_get *th
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stoulx(tmp, &end, num_get_char__Getifld(this, tmp,
&first, &last, base->fmtfl, base->loc), &err);
&first, &last, base->fmtfl, &base->loc), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -5562,7 +5366,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_long(const num_get *thi
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
v = _Stolx(tmp, &end, num_get_char__Getifld(this, tmp,
&first, &last, base->fmtfl, base->loc), &err);
&first, &last, base->fmtfl, &base->loc), &err);
if(end!=tmp && !err)
*pval = v;
else
@ -5624,7 +5428,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_ushort(const num_get *t
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
b = num_get_char__Getifld(this, tmp,
&first, &last, base->fmtfl, base->loc);
&first, &last, base->fmtfl, &base->loc);
beg = tmp + (tmp[0]=='-' ? 1 : 0);
v = _Stoulx(beg, &end, b, &err);
@ -5664,7 +5468,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_bool(const num_get *thi
TRACE("(%p %p %p %p %p)\n", this, ret, base, state, pval);
if(base->fmtfl & FMTFLAG_boolalpha) {
numpunct_char *numpunct = numpunct_char_use_facet(base->loc);
numpunct_char *numpunct = numpunct_char_use_facet(&base->loc);
basic_string_char false_bstr, true_bstr;
const char *pfalse, *ptrue;
@ -5707,7 +5511,7 @@ istreambuf_iterator_char *__thiscall num_get_char_do_get_bool(const num_get *thi
char tmp[25], *end;
int err;
LONG v = _Stolx(tmp, &end, num_get_char__Getifld(this, tmp,
&first, &last, base->fmtfl, base->loc), &err);
&first, &last, base->fmtfl, &base->loc), &err);
if(end!=tmp && err==0 && (v==0 || v==1))
*pval = v;
@ -5927,7 +5731,7 @@ static char* num_put_char__Ffmt(const num_put *this, char *fmt, char spec, int f
static ostreambuf_iterator_char* num_put_char_fput(const num_put *this, ostreambuf_iterator_char *ret,
ostreambuf_iterator_char dest, ios_base *base, char fill, char *buf, MSVCP_size_t count)
{
numpunct_char *numpunct = numpunct_char_use_facet(base->loc);
numpunct_char *numpunct = numpunct_char_use_facet(&base->loc);
basic_string_char grouping_bstr;
const char *grouping;
char *p, sep = *localeconv()->decimal_point;
@ -6019,7 +5823,7 @@ static char* num_put_char__Ifmt(const num_put *this, char *fmt, const char *spec
static ostreambuf_iterator_char* num_put_char__Iput(const num_put *this, ostreambuf_iterator_char *ret,
ostreambuf_iterator_char dest, ios_base *base, char fill, char *buf, MSVCP_size_t count)
{
numpunct_char *numpunct = numpunct_char_use_facet(base->loc);
numpunct_char *numpunct = numpunct_char_use_facet(&base->loc);
basic_string_char grouping_bstr;
const char *grouping;
char *p, sep;
@ -6281,7 +6085,7 @@ ostreambuf_iterator_char* __thiscall num_put_char_do_put_bool(const num_put *thi
TRACE("(%p %p %p %d %d)\n", this, ret, base, fill, v);
if(base->fmtfl & FMTFLAG_boolalpha) {
numpunct_char *numpunct = numpunct_char_use_facet(base->loc);
numpunct_char *numpunct = numpunct_char_use_facet(&base->loc);
basic_string_char str;
MSVCP_size_t pad, len;
@ -6778,7 +6582,7 @@ static ostreambuf_iterator_wchar* num_put__Iput(const num_put *this, ostreambuf_
static ostreambuf_iterator_wchar* num_put_wchar__Iput(const num_put *this, ostreambuf_iterator_wchar *ret,
ostreambuf_iterator_wchar dest, ios_base *base, wchar_t fill, char *buf, MSVCP_size_t count)
{
return num_put__Iput(this, ret, dest, base, fill, buf, count, numpunct_wchar_use_facet(base->loc));
return num_put__Iput(this, ret, dest, base, fill, buf, count, numpunct_wchar_use_facet(&base->loc));
}
/* ?_Iput@?$num_put@GV?$ostreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@ABA?AV?$ostreambuf_iterator@GU?$char_traits@G@std@@@2@V32@AAVios_base@2@GPADI@Z */
@ -6786,7 +6590,7 @@ static ostreambuf_iterator_wchar* num_put_wchar__Iput(const num_put *this, ostre
static ostreambuf_iterator_wchar* num_put_short__Iput(const num_put *this, ostreambuf_iterator_wchar *ret,
ostreambuf_iterator_wchar dest, ios_base *base, wchar_t fill, char *buf, MSVCP_size_t count)
{
return num_put__Iput(this, ret, dest, base, fill, buf, count, numpunct_short_use_facet(base->loc));
return num_put__Iput(this, ret, dest, base, fill, buf, count, numpunct_short_use_facet(&base->loc));
}
/* ?do_put@?$num_put@_WV?$ostreambuf_iterator@_WU?$char_traits@_W@std@@@std@@@std@@MBE?AV?$ostreambuf_iterator@_WU?$char_traits@_W@std@@@2@V32@AAVios_base@2@_WJ@Z */
@ -6909,7 +6713,7 @@ ostreambuf_iterator_wchar* __thiscall num_put_wchar_do_put_double(const num_put
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
}
num_put__fput(this, ret, dest, base, fill, tmp, sprintf(tmp, fmt, base->prec, v),
numpunct_wchar_use_facet(base->loc));
numpunct_wchar_use_facet(&base->loc));
MSVCRT_operator_delete(tmp);
return ret;
}
@ -6940,7 +6744,7 @@ ostreambuf_iterator_wchar* __thiscall num_put_short_do_put_double(const num_put
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
}
num_put__fput(this, ret, dest, base, fill, tmp, sprintf(tmp, fmt, prec, v),
numpunct_short_use_facet(base->loc));
numpunct_short_use_facet(&base->loc));
MSVCRT_operator_delete(tmp);
return ret;
}
@ -7112,7 +6916,7 @@ ostreambuf_iterator_wchar* __thiscall num_put_wchar_do_put_bool(const num_put *t
TRACE("(%p %p %p %d %d)\n", this, ret, base, fill, v);
if(base->fmtfl & FMTFLAG_boolalpha) {
numpunct_wchar *numpunct = numpunct_wchar_use_facet(base->loc);
numpunct_wchar *numpunct = numpunct_wchar_use_facet(&base->loc);
basic_string_wchar str;
MSVCP_size_t pad, len;
@ -7146,7 +6950,7 @@ ostreambuf_iterator_wchar* __thiscall num_put_short_do_put_bool(const num_put *t
TRACE("(%p %p %p %d %d)\n", this, ret, base, fill, v);
if(base->fmtfl & FMTFLAG_boolalpha) {
numpunct_wchar *numpunct = numpunct_short_use_facet(base->loc);
numpunct_wchar *numpunct = numpunct_short_use_facet(&base->loc);
basic_string_wchar str;
MSVCP_size_t pad, len;

View File

@ -165,6 +165,7 @@ typedef struct
locale* __thiscall locale_ctor(locale*);
locale* __thiscall locale_copy_ctor(locale*, const locale*);
locale* __thiscall locale_ctor_uninitialized(locale *, int);
locale* __thiscall locale_operator_assign(locale*, const locale*);
void __thiscall locale_dtor(locale*);
void free_locale(void);
@ -274,7 +275,6 @@ typedef struct _fnarray {
/* class ios_base */
typedef struct _ios_base {
const vtable_ptr *vtable;
MSVCP_size_t stdstr;
IOSB_iostate state;
IOSB_iostate except;
IOSB_fmtflags fmtfl;
@ -282,7 +282,8 @@ typedef struct _ios_base {
streamsize wide;
IOS_BASE_iosarray *arr;
IOS_BASE_fnarray *calls;
locale *loc;
locale loc;
MSVCP_size_t stdstr;
} ios_base;
/* class basic_streambuf<char> */