Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65748 - in trunk/libs/filesystem: v2/test v3/src v3/test
From: bdawes_at_[hidden]
Date: 2010-10-04 09:21:43


Author: bemandawes
Date: 2010-10-04 09:21:35 EDT (Mon, 04 Oct 2010)
New Revision: 65748
URL: http://svn.boost.org/trac/boost/changeset/65748

Log:
Fix #4702
Text files modified:
   trunk/libs/filesystem/v2/test/path_test.cpp | 2 ++
   trunk/libs/filesystem/v3/src/path.cpp | 2 +-
   trunk/libs/filesystem/v3/test/path_test.cpp | 5 ++++-
   3 files changed, 7 insertions(+), 2 deletions(-)

Modified: trunk/libs/filesystem/v2/test/path_test.cpp
==============================================================================
--- trunk/libs/filesystem/v2/test/path_test.cpp (original)
+++ trunk/libs/filesystem/v2/test/path_test.cpp 2010-10-04 09:21:35 EDT (Mon, 04 Oct 2010)
@@ -1329,6 +1329,7 @@
 // extension() tests
 
   BOOST_TEST( path("a/b").extension() == "" );
+ BOOST_TEST( path("a.b/c").extension() == "" );
   BOOST_TEST( path("a/b.txt").extension() == ".txt" );
   BOOST_TEST( path("a/b.").extension() == "." );
   BOOST_TEST( path("a.b.c").extension() == ".c" );
@@ -1359,6 +1360,7 @@
   BOOST_TEST( path("a.b.txt" ).replace_extension("tex").string() == "a.b.tex" );
   // see the rationale in html docs for explanation why this works
   BOOST_TEST( path("").replace_extension(".png").string() == ".png" );
+ BOOST_TEST_EQ(path("a.txt/b").replace_extension(".c"), "a.txt/b.c"); // ticket 4702
 
   // inserter and extractor tests
 # if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // bypass VC++ 7.0 and earlier

Modified: trunk/libs/filesystem/v3/src/path.cpp
==============================================================================
--- trunk/libs/filesystem/v3/src/path.cpp (original)
+++ trunk/libs/filesystem/v3/src/path.cpp 2010-10-04 09:21:35 EDT (Mon, 04 Oct 2010)
@@ -236,7 +236,7 @@
   {
     // erase existing extension if any
     size_type pos(m_pathname.rfind(dot));
- if (pos != string_type::npos)
+ if (pos != string_type::npos && pos >= filename_pos(m_pathname, m_pathname.size()))
       m_pathname.erase(pos);
 
     // append source extension if any

Modified: trunk/libs/filesystem/v3/test/path_test.cpp
==============================================================================
--- trunk/libs/filesystem/v3/test/path_test.cpp (original)
+++ trunk/libs/filesystem/v3/test/path_test.cpp 2010-10-04 09:21:35 EDT (Mon, 04 Oct 2010)
@@ -692,6 +692,7 @@
 
     // extension() tests not otherwise covered
     BOOST_TEST(path("a/b").extension() == "");
+ BOOST_TEST(path("a.b/c").extension() == "");
     BOOST_TEST(path("a/b.txt").extension() == ".txt");
     BOOST_TEST(path("a/b.").extension() == ".");
     BOOST_TEST(path("a.b.c").extension() == ".c");
@@ -1561,7 +1562,9 @@
     BOOST_TEST(path("a").replace_extension(".txt") == "a.txt");
     BOOST_TEST(path("a").replace_extension("txt") == "a");
     BOOST_TEST(path("a.b.txt").replace_extension(".tex") == "a.b.tex");
- BOOST_TEST(path("a.b.txt").replace_extension("tex") == "a.b");
+ BOOST_TEST(path("a.b.txt").replace_extension("tex") == "a.b");
+ BOOST_TEST(path("a/b").replace_extension(".c") == "a/b.c");
+ BOOST_TEST_EQ(path("a.txt/b").replace_extension(".c"), "a.txt/b.c"); // ticket 4702
   }
 
 } // unnamed namespace


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