Commit 2dc8835a by Paolo Carlini Committed by Benjamin Kosnik

ios_manip_fmtflags.cc: Fix for non-interactive output.


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.

Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>

From-SVN: r46709
parent b8a2a84b
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.
2001-11-01 Egor Duda <deo@logos-m.ru> 2001-11-01 Egor Duda <deo@logos-m.ru>
* config/os/newlib/bits/ctype_noninline.h * config/os/newlib/bits/ctype_noninline.h
......
...@@ -662,9 +662,25 @@ namespace std ...@@ -662,9 +662,25 @@ namespace std
__first = __fmt->_M_falsename.data(); __first = __fmt->_M_falsename.data();
__last = __first + __fmt->_M_falsename.size(); __last = __first + __fmt->_M_falsename.size();
} }
copy(__first, __last, __s); streamsize __width = __io.width(0);
} if (__last - __first >= __width)
return __s; 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> template<typename _CharT, typename _OutIter, typename _ValueT>
......
// 981027 ncm work with libstdc++v3 // 981027 ncm work with libstdc++v3
// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. // Copyright (C) 1997-2001 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// invalidate any other reasons why the executable file might be covered by // invalidate any other reasons why the executable file might be covered by
// the GNU General Public License. // the GNU General Public License.
#include <iostream>
#include <sstream> #include <sstream>
#include <locale> #include <locale>
#include <iomanip> #include <iomanip>
...@@ -39,41 +38,52 @@ struct MyNP : std::numpunct<char> ...@@ -39,41 +38,52 @@ struct MyNP : std::numpunct<char>
std::string do_falsename() const; std::string do_falsename() const;
}; };
std::string MyNP::do_truename() const { static std::string s("yea"); return s; } std::string MyNP::do_truename() const
std::string MyNP::do_falsename() const { static std::string s("nay"); return s; } {
static std::string s("yea");
return s;
}
std::string MyNP::do_falsename() const
{
static std::string s("nay");
return s;
}
int void
test01() test01()
{ {
std::cout << true << " " << false << std::endl; bool test = true;
std::cout << std::boolalpha; const char lit[] = "1 0\ntrue false\n: true:\n:true :\n: false:\n: 1:"
std::cout << true << " " << false << std::endl; "\n:1 :\n: 0:\nyea nay\n: yea:\n:yea :\n: nay:\n";
std::ostringstream oss;
std::cout << ":" << std::setw(6) << std::internal << true << ":" << std::endl; oss << true << " " << false << std::endl;
std::cout << ":" << std::setw(6) << std::left << true << ":" << std::endl; oss << std::boolalpha;
std::cout << ":" << std::setw(6) << std::right << false << ":" << std::endl; oss << true << " " << false << std::endl;
std::cout << std::noboolalpha;
std::cout << ":" << std::setw(3) << std::internal << true << ":" << std::endl; oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl;
std::cout << ":" << std::setw(3) << std::left << true << ":" << std::endl; oss << ":" << std::setw(6) << std::left << true << ":" << std::endl;
std::cout << ":" << std::setw(3) << std::right << false << ":" << std::endl; oss << ":" << std::setw(6) << std::right << false << ":" << std::endl;
oss << std::noboolalpha;
oss << ":" << std::setw(3) << std::internal << true << ":" << std::endl;
oss << ":" << std::setw(3) << std::left << true << ":" << std::endl;
oss << ":" << std::setw(3) << std::right << false << ":" << std::endl;
std::locale loc = std::locale (std::locale(), new MyNP); std::locale loc = std::locale (std::locale(), new MyNP);
std::cout.imbue(loc); oss.imbue(loc);
std::cout << std::boolalpha; oss << std::boolalpha;
std::cout << true << " " << false << std::endl; oss << true << " " << false << std::endl;
std::cout << ":" << std::setw(6) << std::internal << true << ":" << std::endl; oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl;
std::cout << ":" << std::setw(6) << std::left << true << ":" << std::endl; oss << ":" << std::setw(6) << std::left << true << ":" << std::endl;
std::cout << ":" << std::setw(6) << std::right << false << ":" << std::endl; oss << ":" << std::setw(6) << std::right << false << ":" << std::endl;
#ifdef DEBUG_ASSERT VERIFY( oss.good() );
assert (std::cout.good()); VERIFY( oss.str() == lit );
#endif
return 0;
} }
int void
test02() test02()
{ {
bool test = true; bool test = true;
...@@ -96,14 +106,12 @@ test02() ...@@ -96,14 +106,12 @@ test02()
str02 = ostr01.str(); str02 = ostr01.str();
VERIFY( str02 == sfalse ); VERIFY( str02 == sfalse );
#ifdef DEBUG_ASSERT VERIFY( test );
assert(test);
#endif
return 0;
} }
int int
main() { main()
{
test01(); test01();
test02(); test02();
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment