|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56778 - in branches/release: boost/filesystem libs/filesystem libs/filesystem/src libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2009-10-13 09:50:46
Author: bemandawes
Date: 2009-10-13 09:50:45 EDT (Tue, 13 Oct 2009)
New Revision: 56778
URL: http://svn.boost.org/trac/boost/changeset/56778
Log:
filesystem: merge trunk
Properties modified:
branches/release/boost/filesystem/ (props changed)
branches/release/libs/filesystem/ (props changed)
Text files modified:
branches/release/boost/filesystem/path.hpp | 45 ++++++++++++++++++++++++++-------------
branches/release/libs/filesystem/src/operations.cpp | 2
branches/release/libs/filesystem/test/path_test.cpp | 21 ++++++++++++++++++
3 files changed, 52 insertions(+), 16 deletions(-)
Modified: branches/release/boost/filesystem/path.hpp
==============================================================================
--- branches/release/boost/filesystem/path.hpp (original)
+++ branches/release/boost/filesystem/path.hpp 2009-10-13 09:50:45 EDT (Tue, 13 Oct 2009)
@@ -399,42 +399,57 @@
lhs.begin(), lhs.end(), tmp.begin(), tmp.end() );
}
- // operator == uses string compare rather than !(lhs < rhs) && !(rhs < lhs) because
- // the result is the same yet the direct string compare is much more efficient that
- // lexicographical_compare, and lexicographical_compare used twice at that.
+ // operator == uses hand-written compare rather than !(lhs < rhs) && !(rhs < lhs)
+ // because the result is the same yet the direct compare is much more efficient
+ // than lexicographical_compare, which would also be called twice.
template< class String, class Traits >
- inline bool operator==( const basic_path<String, Traits> & lhs, const basic_path<String, Traits> & rhs )
+ inline bool operator==( const basic_path<String, Traits> & lhs,
+ const typename basic_path<String, Traits>::string_type::value_type * rhs )
+ {
+ typedef typename
+ boost::BOOST_FILESYSTEM_NAMESPACE::basic_path<String, Traits> path_type;
+ const typename path_type::string_type::value_type * l (lhs.string().c_str());
+ while ( (*l == *rhs
+# ifdef BOOST_WINDOWS_PATH
+ || (*l == path_alt_separator<path_type>::value && *rhs == slash<path_type>::value)
+ || (*l == slash<path_type>::value && *rhs == path_alt_separator<path_type>::value)
+# endif
+ ) && *l ) { ++l; ++rhs; }
+ return *l == *rhs
+# ifdef BOOST_WINDOWS_PATH
+ || (*l == path_alt_separator<path_type>::value && *rhs == slash<path_type>::value)
+ || (*l == slash<path_type>::value && *rhs == path_alt_separator<path_type>::value)
+# endif
+ ;
+ }
+
+ template< class String, class Traits >
+ inline bool operator==( const basic_path<String, Traits> & lhs,
+ const basic_path<String, Traits> & rhs )
{
- return lhs.string() == rhs.string();
+ return lhs == rhs.string().c_str();
}
template< class String, class Traits >
inline bool operator==( const typename basic_path<String, Traits>::string_type::value_type * lhs,
const basic_path<String, Traits> & rhs )
{
- return lhs == rhs.string();
+ return rhs == lhs;
}
template< class String, class Traits >
inline bool operator==( const typename basic_path<String, Traits>::string_type & lhs,
const basic_path<String, Traits> & rhs )
{
- return lhs == rhs.string();
- }
-
- template< class String, class Traits >
- inline bool operator==( const basic_path<String, Traits> & lhs,
- const typename basic_path<String, Traits>::string_type::value_type * rhs )
- {
- return lhs.string() == rhs;
+ return rhs == lhs.c_str();
}
template< class String, class Traits >
inline bool operator==( const basic_path<String, Traits> & lhs,
const typename basic_path<String, Traits>::string_type & rhs )
{
- return lhs.string() == rhs;
+ return lhs == rhs.c_str();
}
template< class String, class Traits >
Modified: branches/release/libs/filesystem/src/operations.cpp
==============================================================================
--- branches/release/libs/filesystem/src/operations.cpp (original)
+++ branches/release/libs/filesystem/src/operations.cpp 2009-10-13 09:50:45 EDT (Tue, 13 Oct 2009)
@@ -1282,7 +1282,7 @@
target = std::string( "." ); // string was static but caused trouble
// when iteration called from dtor, after
// static had already been destroyed
- std::size_t path_size;
+ std::size_t path_size (0); // initialization quiets gcc warning
error_code ec = path_max( path_size );
if ( ec ) return ec;
dirent de;
Modified: branches/release/libs/filesystem/test/path_test.cpp
==============================================================================
--- branches/release/libs/filesystem/test/path_test.cpp (original)
+++ branches/release/libs/filesystem/test/path_test.cpp 2009-10-13 09:50:45 EDT (Tue, 13 Oct 2009)
@@ -226,6 +226,27 @@
p4 = p4; // self-assignment
BOOST_TEST( p4.string() == "foobar" );
+ if ( platform == "Windows" )
+ {
+ path p10 ("c:\\file");
+ path p11 ("c:/file");
+ // check each overload
+ BOOST_TEST( p10.string() == p11.string() );
+ BOOST_TEST( p10 == p11 );
+ BOOST_TEST( p10 == p11.string() );
+ BOOST_TEST( p10 == p11.string().c_str() );
+ BOOST_TEST( p10.string() == p11 );
+ BOOST_TEST( p10.string().c_str() == p11 );
+ BOOST_TEST( p10 == "c:\\file" );
+ BOOST_TEST( p10 == "c:/file" );
+ BOOST_TEST( p11 == "c:\\file" );
+ BOOST_TEST( p11 == "c:/file" );
+ BOOST_TEST( "c:\\file" == p10 );
+ BOOST_TEST( "c:/file" == p10 );
+ BOOST_TEST( "c:\\file" == p11 );
+ BOOST_TEST( "c:/file" == p11 );
+ }
+
exception_tests();
name_function_tests();
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