[Stlport-devel] Monetary do_get() problems
Brought to you by:
complement
|
From: Kees de B. <kee...@al...> - 2010-12-07 10:12:09
|
Hi,
With the following test program I get the "Unexpected result" message:
#include <locale>
#include <iterator>
#include <sstream>
#include <string>
#include <cstdio>
#define IOS_BASE std::ios_base
#define MONEY_GET std::money_get<char>
#define ITERATOR std::istreambuf_iterator<char>
struct D : public MONEY_GET {
D() : MONEY_GET() {}
iter_type do_get(iter_type s, iter_type end, bool intl,
IOS_BASE& str, IOS_BASE::iostate& err,
long double& units) const {
return MONEY_GET::do_get(s, end, intl, str, err, units);
}
iter_type do_get(iter_type s, iter_type end, bool intl,
IOS_BASE& str, IOS_BASE::iostate& err,
string_type& digits) const {
return MONEY_GET::do_get(s, end, intl, str, err, digits);
}
} d;
int main(void)
{
std::istringstream in00("1 ");
in00.imbue(std::locale::classic());
in00.exceptions(IOS_BASE::goodbit);
long double val00;
ITERATOR end00;
ITERATOR beg00(in00);
IOS_BASE::iostate prior_err00 = in00.rdstate();
IOS_BASE::iostate err00 = in00.rdstate();
d.do_get(beg00, end00, true, in00, err00, val00);
if (err00 != prior_err00)
std::printf("Unexpected result.\n");
return 0;
}
Using latest GIT repository I have traced this back to the function
__get_monetary_value(), line 106. The "++__first;" statement will advance
an additional character after the actual characters of the monetary value
(in the example the trailing space) and this causes the eofbit flag to be set.
--
Kees.
|