Account for the weird case where p2 is longer than p1, such as p1 == "path"

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
This commit is contained in:
Enrico Forestieri 2009-05-26 18:27:29 +00:00
parent b3fe7330de
commit 5fb0ed491c
3 changed files with 21 additions and 6 deletions

View File

@ -187,8 +187,13 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
if (common_len != p2_len) if (common_len != p2_len)
return false; return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre)) if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
path = to_utf8(p2 + p1.substr(common_len, p1_len - common_len)); 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; return true;
} }

View File

@ -100,8 +100,13 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
if (common_len != p2_len) if (common_len != p2_len)
return false; return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre)) if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
path = to_utf8(p2 + p1.substr(common_len, p1_len - common_len)); 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; return true;
#else #else

View File

@ -218,8 +218,13 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
if (common_len != p2_len) if (common_len != p2_len)
return false; return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre)) if (how == CASE_ADJUSTED && !prefixIs(path, pre)) {
path = to_utf8(p2 + p1.substr(common_len, p1_len - common_len)); 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; return true;
} }