This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Re: iostream changes locale to format a number


Takeshi Kobayakawa wrote:

>pcarlini> > Are you willing to contribute a patch against the current mainline 
>pcarlini> > libstdc++-v3 sources for public discussion (that setlocale ... 
>pcarlini> > setlocale pattern is present in quite a few different places) ?
>
>  I wrote the patch listed below, which seems to work fine for the test case.
>Your sugesstion helped me a lot.
>Actually, without strdup(), the patch did not work.
>(Sometimes it works without strdup(), but I could not figure out
>what is happening.)
>
>  Anyway, the following patch uses strdup() and free().
>
Hi.

Your patch seems fine to me. Did you run the testsuite, I suppose.

As, for a testcase to go in the testsuite I have prepared the below; I'm 
not sure, however, in which testfile it properly belongs.

Benjamin?

Ciao,
Paolo.

///////////////////

#include <clocale>
#include <sstream>
#include <cassert>

void
test0x()
{
  using namespace std;

  bool test = true;

  ostringstream oss;
  string loc1 = setlocale(LC_ALL, "de_DE");
  oss << 1;
  string loc2 = setlocale(LC_ALL, NULL);
  assert( loc1 == loc2 );
}

int main()
{
#ifdef _GLIBCPP_HAVE_SETENV
  test0x();
#endif
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]