OSDN Git Service

2011-11-28 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / std / iomanip
index ea2c44a..e725b25 100644 (file)
@@ -1,7 +1,7 @@
 // Standard stream manipulators -*- C++ -*-
 
 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-// 2006, 2007, 2008, 2009, 2010
+// 2006, 2007, 2008, 2009, 2010, 2011
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -262,18 +262,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     basic_istream<_CharT, _Traits>&
     operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f)
     {
-      typedef istreambuf_iterator<_CharT, _Traits> _Iter;
-      typedef money_get<_CharT, _Iter> _MoneyGet;
-      
-      ios_base::iostate __err = ios_base::goodbit;
-      const _MoneyGet& __mg = use_facet<_MoneyGet>(__is.getloc());
-
-      __mg.get(_Iter(__is.rdbuf()), _Iter(), __f._M_intl,
-              __is, __err, __f._M_mon);
-
-      if (ios_base::goodbit != __err)
-       __is.setstate(__err);
-
+      typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false);
+      if (__cerb)
+       {
+         ios_base::iostate __err = ios_base::goodbit;
+         __try
+           {
+             typedef istreambuf_iterator<_CharT, _Traits>   _Iter;
+             typedef money_get<_CharT, _Iter>               _MoneyGet;
+
+             const _MoneyGet& __mg = use_facet<_MoneyGet>(__is.getloc());
+             __mg.get(_Iter(__is.rdbuf()), _Iter(), __f._M_intl,
+                      __is, __err, __f._M_mon);
+           }
+         __catch(__cxxabiv1::__forced_unwind&)
+           {
+             __is._M_setstate(ios_base::badbit);
+             __throw_exception_again;
+           }
+         __catch(...)
+           { __is._M_setstate(ios_base::badbit); }
+         if (ios_base::goodbit != __err)
+           __is.setstate(__err);
+       }
       return __is; 
     }
 
@@ -298,16 +309,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     basic_ostream<_CharT, _Traits>& 
     operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f)
     {
-      typedef ostreambuf_iterator<_CharT, _Traits> _Iter;
-      typedef money_put<_CharT, _Iter> _MoneyPut;
-      
-      const _MoneyPut& __mp = use_facet<_MoneyPut>(__os.getloc());
-      const _Iter __end = __mp.put(_Iter(__os.rdbuf()), __f._M_intl,
-                                  __os, __os.fill(), __f._M_mon);
-
-      if (__end.failed())
-       __os.setstate(ios_base::badbit);
-
+      typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os);
+      if (__cerb)
+       {
+         __try
+           {
+             typedef ostreambuf_iterator<_CharT, _Traits>   _Iter;
+             typedef money_put<_CharT, _Iter>               _MoneyPut;
+             const _MoneyPut& __mp = use_facet<_MoneyPut>(__os.getloc());
+             const _Iter __end = __mp.put(_Iter(__os.rdbuf()), __f._M_intl,
+                                          __os, __os.fill(), __f._M_mon);
+             if (__end.failed())
+               __os.setstate(ios_base::badbit);
+           }
+         __catch(__cxxabiv1::__forced_unwind&)
+           {
+             __os._M_setstate(ios_base::badbit);
+             __throw_exception_again;
+           }
+         __catch(...)
+           { __os._M_setstate(ios_base::badbit); }
+       }
       return __os; 
     }