This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] Correctly output internal-adjusted hexadecimals
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: bkoz at redhat dot com
- Date: Wed, 28 Nov 2001 21:45:42 +0100
- Subject: [PATCH] Correctly output internal-adjusted hexadecimals
Hi all,
this is a minor nit indeed, which I have encountered while having a look to
PR3655 (more about it after the exponential allocator ;-)
In short, currently, internal-hex numbers are not properly output. I have
changed the new helper function __pad (in locale_facets.tcc) to deal with the
__testhex case similarly to what is currently done for __testsign.
As usual, booted and tested on i686-pc-linux-gnu.
Cheers,
Paolo.
Paolo Carlini <pcarlini@unitus.it>
* include/bits/locale_facets.tcc (__pad): correctly output hex
numbers internally aligned.
* testsuite/27_io/ostream_inserter_arith.cc: Add testcase.
*** locale_facets.tcc.orig Wed Nov 28 20:35:43 2001
--- locale_facets.tcc Wed Nov 28 21:30:06 2001
*************** namespace std
*** 1957,1967 ****
{
__news[0] = __olds[0];
__news[1] = __olds[1];
! __mod += 2;
! __news += 2;
! __beg = const_cast<char_type*>(__olds + __mod);
! __beglen = __oldlen - __mod;
! __end = __pads;
}
else if (__testsign)
{
--- 1957,1967 ----
{
__news[0] = __olds[0];
__news[1] = __olds[1];
! __mod += 2;
! __news += 2;
! __beg = __pads;
! __beglen = __plen;
! __end = const_cast<char_type*>(__olds + __mod);
}
else if (__testsign)
{
*** ostream_inserter_arith.cc.orig Wed Nov 28 20:45:17 2001
--- ostream_inserter_arith.cc Wed Nov 28 21:11:56 2001
*************** test03()
*** 309,318 ****
--- 309,331 ----
}
int
+ test04()
+ {
+ stringbuf strbuf;
+ ostream o(&strbuf);
+
+ o << hex << showbase << setw(6) << internal << 255;
+ VERIFY( strbuf.str() == "0x ff" );
+
+ return 0;
+ }
+
+ int
main()
{
test01();
test02();
+ test04();
#ifdef TEST_NUMPUT_VERBOSE
cout << "Test passed!" << endl;
#endif