[niepce] Fix a bug where the extension isn't found on a path that does not contain slashes...



commit bcee1a96f503d2560d843a7983d32d2c78a4a0f8
Author: Hub Figuiere <hub figuiere net>
Date:   Sat Oct 29 17:41:40 2011 -0700

    Fix a bug where the extension isn't found on a path that does not
    contain slashes...

 src/fwk/utils/pathutils.cpp       |    2 +-
 src/fwk/utils/t/testpathutils.cpp |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/fwk/utils/pathutils.cpp b/src/fwk/utils/pathutils.cpp
index 357282e..00a101e 100644
--- a/src/fwk/utils/pathutils.cpp
+++ b/src/fwk/utils/pathutils.cpp
@@ -45,7 +45,7 @@ std::string::size_type _path_extension_pos(const std::string &path)
     }
     std::string::size_type slash_idx = path.find_last_of("/");
     // if the '.' is not part of the last component
-    if(idx < slash_idx) {
+    if((slash_idx != std::string::npos) && (idx < slash_idx)) {
         return std::string::npos;
     }
 
diff --git a/src/fwk/utils/t/testpathutils.cpp b/src/fwk/utils/t/testpathutils.cpp
index ee0ca71..b018e2f 100644
--- a/src/fwk/utils/t/testpathutils.cpp
+++ b/src/fwk/utils/t/testpathutils.cpp
@@ -33,6 +33,7 @@ int test_main( int, char *[] )             // note the name!
   BOOST_CHECK(fwk::path_stem("/foo/bar/baz.txt") == "/foo/bar/baz");
   
   BOOST_CHECK(fwk::path_extension("/foo/bar/baz.txt") == ".txt");
+  BOOST_CHECK(fwk::path_extension("img_2114.xmp") == ".xmp");
 
   BOOST_CHECK(fwk::path_replace_extension("/foo/bar/baz.txt", ".xmp") == "/foo/bar/baz.xmp");
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]