Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52288 - trunk/boost/asio/ip
From: chris_at_[hidden]
Date: 2009-04-09 07:50:43


Author: chris_kohlhoff
Date: 2009-04-09 07:50:42 EDT (Thu, 09 Apr 2009)
New Revision: 52288
URL: http://svn.boost.org/trac/boost/changeset/52288

Log:
Prevent locales from affecting the formatting of endpoints. Fixes #2682.

Text files modified:
   trunk/boost/asio/ip/basic_endpoint.hpp | 19 +++++++++++++------
   1 files changed, 13 insertions(+), 6 deletions(-)

Modified: trunk/boost/asio/ip/basic_endpoint.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_endpoint.hpp (original)
+++ trunk/boost/asio/ip/basic_endpoint.hpp 2009-04-09 07:50:42 EDT (Thu, 09 Apr 2009)
@@ -24,6 +24,7 @@
 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
 # include <ostream>
 #endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+#include <sstream>
 #include <boost/asio/detail/pop_options.hpp>
 
 #include <boost/asio/error.hpp>
@@ -325,11 +326,14 @@
   }
   else
   {
+ std::ostringstream tmp_os;
+ tmp_os.imbue(std::locale::classic());
     if (addr.is_v4())
- os << a;
+ tmp_os << a;
     else
- os << '[' << a << ']';
- os << ':' << endpoint.port();
+ tmp_os << '[' << a << ']';
+ tmp_os << ':' << endpoint.port();
+ os << tmp_os.str();
   }
   return os;
 }
@@ -351,11 +355,14 @@
   }
   else
   {
+ std::ostringstream tmp_os;
+ tmp_os.imbue(std::locale::classic());
     if (addr.is_v4())
- os << a;
+ tmp_os << a;
     else
- os << '[' << a << ']';
- os << ':' << endpoint.port();
+ tmp_os << '[' << a << ']';
+ tmp_os << ':' << endpoint.port();
+ os << tmp_os.str();
   }
   return os;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk