msvcp60: Fixed num_put::fput implementation.
This commit is contained in:
parent
8048d04e59
commit
1cd95d4f82
|
@ -5732,10 +5732,7 @@ static ostreambuf_iterator_char* num_put_char_fput(const num_put *this, ostreamb
|
||||||
ostreambuf_iterator_char dest, ios_base *base, char fill, char *buf, MSVCP_size_t count)
|
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;
|
char *p, sep = *localeconv()->decimal_point;
|
||||||
int cur_group = 0, group_size = 0;
|
|
||||||
int adjustfield = base->fmtfl & FMTFLAG_adjustfield;
|
int adjustfield = base->fmtfl & FMTFLAG_adjustfield;
|
||||||
MSVCP_size_t pad;
|
MSVCP_size_t pad;
|
||||||
|
|
||||||
|
@ -5750,25 +5747,6 @@ static ostreambuf_iterator_char* num_put_char_fput(const num_put *this, ostreamb
|
||||||
}
|
}
|
||||||
p--;
|
p--;
|
||||||
|
|
||||||
/* Add separators to number */
|
|
||||||
numpunct_char_grouping(numpunct, &grouping_bstr);
|
|
||||||
grouping = basic_string_char_c_str(&grouping_bstr);
|
|
||||||
sep = grouping[0] ? numpunct_char_thousands_sep(numpunct) : '\0';
|
|
||||||
|
|
||||||
for(; p>buf && sep && grouping[cur_group]!=CHAR_MAX; p--) {
|
|
||||||
group_size++;
|
|
||||||
if(group_size == grouping[cur_group]) {
|
|
||||||
group_size = 0;
|
|
||||||
if(grouping[cur_group+1])
|
|
||||||
cur_group++;
|
|
||||||
|
|
||||||
memmove(p+1, p, buf+count-p);
|
|
||||||
*p = sep;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
basic_string_char_dtor(&grouping_bstr);
|
|
||||||
|
|
||||||
/* Display number with padding */
|
/* Display number with padding */
|
||||||
if(count >= base->wide)
|
if(count >= base->wide)
|
||||||
pad = 0;
|
pad = 0;
|
||||||
|
@ -6420,11 +6398,7 @@ static ostreambuf_iterator_wchar* num_put__fput(const num_put *this, ostreambuf_
|
||||||
ostreambuf_iterator_wchar dest, ios_base *base, wchar_t fill, char *buf,
|
ostreambuf_iterator_wchar dest, ios_base *base, wchar_t fill, char *buf,
|
||||||
MSVCP_size_t count, numpunct_wchar *numpunct)
|
MSVCP_size_t count, numpunct_wchar *numpunct)
|
||||||
{
|
{
|
||||||
basic_string_char grouping_bstr;
|
|
||||||
const char *grouping;
|
|
||||||
char *p, dec_point = *localeconv()->decimal_point;
|
char *p, dec_point = *localeconv()->decimal_point;
|
||||||
wchar_t sep;
|
|
||||||
int cur_group = 0, group_size = 0;
|
|
||||||
int adjustfield = base->fmtfl & FMTFLAG_adjustfield;
|
int adjustfield = base->fmtfl & FMTFLAG_adjustfield;
|
||||||
MSVCP_size_t i, pad;
|
MSVCP_size_t i, pad;
|
||||||
|
|
||||||
|
@ -6436,25 +6410,6 @@ static ostreambuf_iterator_wchar* num_put__fput(const num_put *this, ostreambuf_
|
||||||
}
|
}
|
||||||
p--;
|
p--;
|
||||||
|
|
||||||
/* Add separators to number */
|
|
||||||
numpunct_wchar_grouping(numpunct, &grouping_bstr);
|
|
||||||
grouping = basic_string_char_c_str(&grouping_bstr);
|
|
||||||
sep = grouping[0] ? numpunct_wchar_thousands_sep(numpunct) : '\0';
|
|
||||||
|
|
||||||
for(; p>buf && sep && grouping[cur_group]!=CHAR_MAX; p--) {
|
|
||||||
group_size++;
|
|
||||||
if(group_size == grouping[cur_group]) {
|
|
||||||
group_size = 0;
|
|
||||||
if(grouping[cur_group+1])
|
|
||||||
cur_group++;
|
|
||||||
|
|
||||||
memmove(p+1, p, buf+count-p);
|
|
||||||
*p = '\0'; /* mark thousands separator positions */
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
basic_string_char_dtor(&grouping_bstr);
|
|
||||||
|
|
||||||
/* Display number with padding */
|
/* Display number with padding */
|
||||||
if(count >= base->wide)
|
if(count >= base->wide)
|
||||||
pad = 0;
|
pad = 0;
|
||||||
|
@ -6474,8 +6429,6 @@ static ostreambuf_iterator_wchar* num_put__fput(const num_put *this, ostreambuf_
|
||||||
for(i=0; i<count; i++) {
|
for(i=0; i<count; i++) {
|
||||||
if(buf[i] == dec_point)
|
if(buf[i] == dec_point)
|
||||||
num_put_wchar__Rep(this, &dest, dest, numpunct_wchar_decimal_point(numpunct), 1);
|
num_put_wchar__Rep(this, &dest, dest, numpunct_wchar_decimal_point(numpunct), 1);
|
||||||
else if(!buf[i])
|
|
||||||
num_put_wchar__Rep(this, &dest, dest, sep, 1);
|
|
||||||
else
|
else
|
||||||
num_put_wchar__Putc(this, &dest, dest, buf+i, 1);
|
num_put_wchar__Putc(this, &dest, dest, buf+i, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue