]> git.lyx.org Git - lyx.git/commitdiff
Account for the weird case where p2 is longer than p1, such as p1 == "path"
authorEnrico Forestieri <forenr@lyx.org>
Tue, 26 May 2009 18:27:29 +0000 (18:27 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 26 May 2009 18:27:29 +0000 (18:27 +0000)
and p2 == "Path/". This would be really weird, but one never knows...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29855 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/os_cygwin.cpp
src/support/os_unix.cpp
src/support/os_win32.cpp

index 1adfa5f973b3312105da974be5715175de3a18e5..8ffaef55e4cd69ae9e62b9fa17f0a0d9f0008a20 100644 (file)
@@ -187,8 +187,13 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
        if (common_len != p2_len)
                return false;
 
-       if (how == CASE_ADJUSTED && !prefixIs(path, pre))
-               path = to_utf8(p2 + p1.substr(common_len, p1_len - common_len));
+       if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
+               if (p1_len < common_len)
+                       path = to_utf8(p2.substr(0, p1_len));
+               else
+                       path = to_utf8(p2 + p1.substr(common_len,
+                                                       p1_len - common_len));
+       }
 
        return true;
 }
index ef13ff7f9ec69707afc6e2f8922ca3c2e5b88535..2e6f9ba309c84bc583b6b07ea1cf029f98034004 100644 (file)
@@ -100,8 +100,13 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
        if (common_len != p2_len)
                return false;
 
-       if (how == CASE_ADJUSTED && !prefixIs(path, pre))
-               path = to_utf8(p2 + p1.substr(common_len, p1_len - common_len));
+       if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
+               if (p1_len < common_len)
+                       path = to_utf8(p2.substr(0, p1_len));
+               else
+                       path = to_utf8(p2 + p1.substr(common_len,
+                                                       p1_len - common_len));
+       }
 
        return true;
 #else
index 743677833a601b55aac2725e21127ec200d84afc..018b5edd6e31f905bb7800471e07a7037e99396b 100644 (file)
@@ -218,8 +218,13 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
        if (common_len != p2_len)
                return false;
 
-       if (how == CASE_ADJUSTED && !prefixIs(path, pre))
-               path = to_utf8(p2 + p1.substr(common_len, p1_len - common_len));
+       if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
+               if (p1_len < common_len)
+                       path = to_utf8(p2.substr(0, p1_len));
+               else
+                       path = to_utf8(p2 + p1.substr(common_len,
+                                                       p1_len - common_len));
+       }
 
        return true;
 }