This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Properly align boolalpha-ized booleans
- To: Paolo Carlini <pcarlini at unitus dot it>
- Subject: Re: [PATCH] Properly align boolalpha-ized booleans
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Thu, 1 Nov 2001 19:46:46 -0800 (PST)
- cc: libstdc++ at gcc dot gnu dot org
This is now in.
tested x86-linux.
> Therefore, I implemented it, closely following the style and conventions of
> the other members functions having to do with alignment and data padding.
Great. There are a number of outstanding issues with the numeric facets:
I'm going to begin working on them presently.
This was one of them: thanks for beating me to it.
> At this point, perhaps it would be useful to check in
> 27_io/ios_manip_fmtflags.cc that the actual output matches the expected. What
> do you suggest about this? (I'm not so much into DejaGnu, unfortunately ;-)
See below. The testcases are designed to be able to be self-contained, so
assert is all that is really required.
2001-11-01 Paolo Carlini <pcarlini@unitus.it>
Benjamin Kosnik <bkoz@redhat.com>
* testsuite/27_io/ios_manip_fmtflags.cc: Fix for non-interactive
output.
* include/bits/locale_facets.tcc (num_put::do_put(bool)): Fix.
Index: include/bits/locale_facets.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.tcc,v
retrieving revision 1.32
diff -c -p -r1.32 locale_facets.tcc
*** locale_facets.tcc 2001/10/26 06:23:47 1.32
--- locale_facets.tcc 2001/11/02 03:41:45
*************** namespace std
*** 662,670 ****
__first = __fmt->_M_falsename.data();
__last = __first + __fmt->_M_falsename.size();
}
! copy(__first, __last, __s);
! }
! return __s;
}
template<typename _CharT, typename _OutIter, typename _ValueT>
--- 662,686 ----
__first = __fmt->_M_falsename.data();
__last = __first + __fmt->_M_falsename.size();
}
! streamsize __width = __io.width(0);
! if (__last - __first >= __width)
! return copy(__first, __last, __s);
! else
! {
! int __padding = __width - (__last - __first);
! ios_base::fmtflags __aflags = __flags & ios_base::adjustfield;
! if (__aflags != ios_base::left)
! {
! __pad(__s, __fill, __padding);
! return copy(__first, __last, __s);
! }
! else
! {
! copy(__first, __last, __s);
! return __pad(__s, __fill, __padding);
! }
! }
! }
}
template<typename _CharT, typename _OutIter, typename _ValueT>
Index: testsuite/27_io/ios_manip_fmtflags.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/ios_manip_fmtflags.cc,v
retrieving revision 1.3
diff -c -p -r1.3 ios_manip_fmtflags.cc
*** ios_manip_fmtflags.cc 2001/08/07 03:38:33 1.3
--- ios_manip_fmtflags.cc 2001/11/02 03:41:48
***************
*** 1,6 ****
// 981027 ncm work with libstdc++v3
! // Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
--- 1,6 ----
// 981027 ncm work with libstdc++v3
! // Copyright (C) 1997-2001 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
***************
*** 27,33 ****
// invalidate any other reasons why the executable file might be
covered by
// the GNU General Public License.
- #include <iostream>
#include <sstream>
#include <locale>
#include <iomanip>
--- 27,32 ----
*************** struct MyNP : std::numpunct<char>
*** 39,79 ****
std::string do_falsename() const;
};
! std::string MyNP::do_truename() const { static std::string s("yea");
return s; }
! std::string MyNP::do_falsename() const { static std::string s("nay");
return s; }
! int
test01()
{
! std::cout << true << " " << false << std::endl;
! std::cout << std::boolalpha;
! std::cout << true << " " << false << std::endl;
!
! std::cout << ":" << std::setw(6) << std::internal << true << ":" <<
std::endl;
! std::cout << ":" << std::setw(6) << std::left << true << ":" <<
std::endl;
! std::cout << ":" << std::setw(6) << std::right << false << ":" <<
std::endl;
! std::cout << std::noboolalpha;
! std::cout << ":" << std::setw(3) << std::internal << true << ":" <<
std::endl;
! std::cout << ":" << std::setw(3) << std::left << true << ":" <<
std::endl;
! std::cout << ":" << std::setw(3) << std::right << false << ":" <<
std::endl;
std::locale loc = std::locale (std::locale(), new MyNP);
! std::cout.imbue(loc);
! std::cout << std::boolalpha;
! std::cout << true << " " << false << std::endl;
!