Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78000 - in trunk: boost/filesystem libs/filesystem/doc libs/filesystem/src libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2012-04-15 16:34:19


Author: bemandawes
Date: 2012-04-15 16:34:19 EDT (Sun, 15 Apr 2012)
New Revision: 78000
URL: http://svn.boost.org/trac/boost/changeset/78000

Log:
Fix #6690 and #6737, resolving static linking related problems with VC++ 8 through 11. Note that this fix may reintroduce codecvt thread safety problems #4889, #6320, for these compilers if static linking is used.
Text files modified:
   trunk/boost/filesystem/path.hpp | 7 ---
   trunk/libs/filesystem/doc/release_history.html | 14 +++++++-
   trunk/libs/filesystem/src/path.cpp | 62 ++++++++++++++++++++++++++++++++++-----
   trunk/libs/filesystem/test/path_test.cpp | 3 +
   4 files changed, 70 insertions(+), 16 deletions(-)

Modified: trunk/boost/filesystem/path.hpp
==============================================================================
--- trunk/boost/filesystem/path.hpp (original)
+++ trunk/boost/filesystem/path.hpp 2012-04-15 16:34:19 EDT (Sun, 15 Apr 2012)
@@ -418,10 +418,7 @@
     // ----- static member functions -----
 
     static std::locale imbue(const std::locale& loc);
- static const codecvt_type& codecvt()
- {
- return *wchar_t_codecvt_facet();
- }
+ static const codecvt_type& codecvt();
 
     // ----- deprecated functions -----
 
@@ -502,8 +499,6 @@
     static void m_path_iterator_increment(path::iterator & it);
     static void m_path_iterator_decrement(path::iterator & it);
 
- static const codecvt_type *& wchar_t_codecvt_facet();
-
   }; // class path
 
   namespace detail

Modified: trunk/libs/filesystem/doc/release_history.html
==============================================================================
--- trunk/libs/filesystem/doc/release_history.html (original)
+++ trunk/libs/filesystem/doc/release_history.html 2012-04-15 16:34:19 EDT (Sun, 15 Apr 2012)
@@ -49,7 +49,7 @@
   The behavior for simple cases has been reverted to the Version 2 behavior, but
   with corrections so that complex replacements now work. Two test cases from
   #5118 have been added.</li>
- <li>Fix #3737,
+ <li>Fix #3737,
   Boost.Filesystem does not compile on Windows Mobile. On Windows, &lt;sys/stat.h&gt;
   is no longer included.</li>
   <li>Fix #4065,
@@ -58,6 +58,16 @@
   related to lexicographical issues.</li>
   <li>Add class path member function <code>compare</code> for consistency with
   std::string.</li>
+ <li>Tighten BOOST_FILESYSTEM_DYN_LINK and BOOST_FILESYSTEM_STATIC_LINK logic
+ in filesystem/config.hpp so that one or the other is always defined, and both
+ being defined is a #error.</li>
+ <li>Fix #6690 and
+ #6737, resolving
+ static linking related problems with VC++ 8 through 11. Note that this fix may
+ reintroduce codecvt thread safety problems
+ #4889,
+ #6320, for these
+ compilers if static linking is used.</li>
 </ul>
 
 <h2>1.49.0</h2>
@@ -142,7 +152,7 @@
 </ul>
 <hr>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->31 March, 2012<!--webbot bot="Timestamp" endspan i-checksum="28817" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->15 April, 2012<!--webbot bot="Timestamp" endspan i-checksum="29863" --></p>
 <p>© Copyright Beman Dawes, 2011</p>
 <p> Use, modification, and distribution are subject to the Boost Software
 License, Version 1.0. See <a href="http://www.boost.org/LICENSE_1_0.txt">

Modified: trunk/libs/filesystem/src/path.cpp
==============================================================================
--- trunk/libs/filesystem/src/path.cpp (original)
+++ trunk/libs/filesystem/src/path.cpp 2012-04-15 16:34:19 EDT (Sun, 15 Apr 2012)
@@ -791,12 +791,36 @@
   // locale helpers //
   //------------------------------------------------------------------------------------//
 
-#ifdef BOOST_WINDOWS_API
+#if defined(BOOST_WINDOWS_API) && defined(BOOST_FILESYSTEM_STATIC_LINK)
+
+ inline std::locale default_locale()
+ {
+ std::locale global_loc = std::locale();
+ std::locale loc(global_loc, new windows_file_codecvt);
+ return loc;
+ }
+
+ inline std::locale& path_locale()
+ {
+ static std::locale loc(default_locale());
+ return loc;
+ }
+
+ inline const path::codecvt_type*& codecvt_facet_ptr()
+ {
+ static const std::codecvt<wchar_t, char, std::mbstate_t>*
+ facet(
+ &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
+ (path_locale()));
+ return facet;
+ }
+
+#elif defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_STATIC_LINK)
 
   std::locale path_locale(std::locale(), new windows_file_codecvt);
 
   const std::codecvt<wchar_t, char, std::mbstate_t>*
- codecvt_facet(&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
+ codecvt_facet_ptr(&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
       (path_locale));
 
 #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
@@ -824,7 +848,7 @@
                           new boost::filesystem::detail::utf8_codecvt_facet);
 
   const std::codecvt<wchar_t, char, std::mbstate_t>*
- codecvt_facet(&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
+ codecvt_facet_ptr(&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
       (path_locale));
 
 #else // Other POSIX
@@ -836,8 +860,8 @@
   // or LANG are wrong, for example), so lazy initialization is used to ensure
   // that exceptions occur after main() starts and so can be caught.
 
- std::locale path_locale; // initialized by path::wchar_t_codecvt_facet() below
- const std::codecvt<wchar_t, char, std::mbstate_t>* codecvt_facet; // ditto
+ std::locale path_locale; // initialized by path::codecvt() below
+ const std::codecvt<wchar_t, char, std::mbstate_t>* codecvt_facet_ptr; // ditto
 
 # endif
 
@@ -852,7 +876,26 @@
 namespace filesystem
 {
 
- const path::codecvt_type*& path::wchar_t_codecvt_facet()
+#if defined(BOOST_WINDOWS_API) && defined(BOOST_FILESYSTEM_STATIC_LINK)
+
+ const path::codecvt_type& path::codecvt()
+ {
+ BOOST_ASSERT_MSG(codecvt_facet_ptr(), "codecvt_facet_ptr() facet hasn't been properly initialized");
+ return *codecvt_facet_ptr();
+ }
+
+ std::locale path::imbue(const std::locale & loc)
+ {
+ std::locale temp(path_locale());
+ path_locale() = loc;
+ codecvt_facet_ptr() =
+ &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(path_locale());
+ return temp;
+ }
+
+#else
+
+ const path::codecvt_type& path::codecvt()
   {
 # if defined(BOOST_POSIX_API) && \
       !(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
@@ -862,17 +905,20 @@
       // exception if a valid std::locale("") is actually needed.
       static std::locale posix_lazy_initialization(path::imbue(std::locale("")));
 # endif
- return codecvt_facet;
+ return *codecvt_facet_ptr;
   }
 
   std::locale path::imbue(const std::locale& loc)
   {
     std::locale temp(path_locale);
     path_locale = loc;
- codecvt_facet =
+ codecvt_facet_ptr =
       &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(path_locale);
     return temp;
   }
 
+
+#endif
+
 } // namespace filesystem
 } // namespace boost

Modified: trunk/libs/filesystem/test/path_test.cpp
==============================================================================
--- trunk/libs/filesystem/test/path_test.cpp (original)
+++ trunk/libs/filesystem/test/path_test.cpp 2012-04-15 16:34:19 EDT (Sun, 15 Apr 2012)
@@ -1741,6 +1741,9 @@
 
 } // unnamed namespace
 
+static boost::filesystem::path FilePath = "FilePath"; // #6737 reported this crashed
+ // on VC++ debug mode build
+
 //--------------------------------------------------------------------------------------//
 // //
 // main //


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