OSDN Git Service

2001-11-01 Paolo Carlini <pcarlini@unitus.it>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Nov 2001 03:48:09 +0000 (03:48 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Nov 2001 03:48:09 +0000 (03:48 +0000)
    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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46709 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/testsuite/27_io/ios_manip_fmtflags.cc

index f29936c..988bfbf 100644 (file)
@@ -1,3 +1,10 @@
+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>
 
        * config/os/newlib/bits/ctype_noninline.h
index 4b2de13..0fe180b 100644 (file)
@@ -662,9 +662,25 @@ namespace std
               __first = __fmt->_M_falsename.data();
               __last = __first + __fmt->_M_falsename.size();
             }
-          copy(__first, __last, __s);
-        }
-      return __s;
+        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 5fe1194..a8391d2 100644 (file)
@@ -1,6 +1,6 @@
 // 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
 // software; you can redistribute it and/or modify it under the
@@ -27,7 +27,6 @@
 // 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>
@@ -39,41 +38,52 @@ struct MyNP : std::numpunct<char>
   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; }
+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
+void
 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;
+  bool test = true;
+  const char lit[] = "1 0\ntrue false\n:  true:\n:true  :\n: false:\n:  1:"
+                    "\n:1  :\n:  0:\nyea nay\n:   yea:\n:yea   :\n:   nay:\n";
+  std::ostringstream oss;
+  oss << true << " " << false << std::endl;
+  oss << std::boolalpha;
+  oss << true << " " << false << std::endl;
+
+  oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl;
+  oss << ":" << std::setw(6) << std::left << true << ":" << 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::cout.imbue(loc);
+  oss.imbue(loc);
 
-  std::cout << std::boolalpha;
-  std::cout << true << " " << false << std::endl;
+  oss << std::boolalpha;
+  oss << 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;
+  oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl;
+  oss << ":" << std::setw(6) << std::left << true << ":" << std::endl;
+  oss << ":" << std::setw(6) << std::right << false << ":" << std::endl;
 
-#ifdef DEBUG_ASSERT
-  assert (std::cout.good());
-#endif
-  return 0;
+  VERIFY( oss.good() );
+  VERIFY( oss.str() == lit );
 }
 
-int
+void
 test02()
 {
   bool test = true;
@@ -96,14 +106,12 @@ test02()
   str02 = ostr01.str();
   VERIFY( str02 == sfalse );
 
-#ifdef DEBUG_ASSERT
-  assert(test);
-#endif
-  return 0;
+  VERIFY( test );
 }
 
 int 
-main() {
+main() 
+{
   test01();
   test02();
   return 0;