Simpler things are almost always better.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29843 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-05-25 17:30:02 +00:00
parent c3d457a143
commit 2fb21c28b5
4 changed files with 21 additions and 30 deletions

View File

@ -60,9 +60,9 @@ std::string const python();
bool isFilesystemCaseSensitive();
/// Extract the path common to both @c p1 and @c p2. DBCS aware!
/// \p p1 and \p p2 are encoded in ucs4, \returns the index to the
/// end of the last matching path component (the index may be pointing
/// to the path separator, if it is the last char in @c p2).
/// \p p1 and \p p2 are encoded in ucs4, \returns the index to the end of
/// the last matching path component (the index may be pointing after the
/// end of @c p1 or @c p2 if their last char is not the path separator).
std::size_t common_path(docstring const & p1, docstring const & p2);
/// Converts a unix style path to host OS style.

View File

@ -162,9 +162,7 @@ docstring::size_type common_path(docstring const & p1, docstring const & p2)
--i; // here was the last match
while (i && p1[i] != '/')
--i;
} else
--i;
}
return i;
}
@ -181,13 +179,12 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
docstring const p2 = from_utf8(pre);
docstring::size_type const p1_len = p1.length();
docstring::size_type const p2_len = p2.length();
docstring::size_type const common_len = common_path(p1, p2) + 1;
docstring::size_type common_len = common_path(p1, p2);
if (common_len == 1) {
if (p2_len != 1 || p1_len == 0 || p1[0] != p2[0]
|| (p1_len != 1 && p1[1] != '/'))
return false;
} else if (common_len != p2_len)
if (p2[p2_len - 1] == '/')
++common_len;
if (common_len != p2_len)
return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre))

View File

@ -70,9 +70,7 @@ docstring::size_type common_path(docstring const & p1, docstring const & p2)
--i; // here was the last match
while (i && p1[i] != '/')
--i;
} else
--i;
}
return i;
}
@ -94,13 +92,12 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
docstring const p2 = from_utf8(pre);
docstring::size_type const p1_len = p1.length();
docstring::size_type const p2_len = p2.length();
docstring::size_type const common_len = common_path(p1, p2) + 1;
docstring::size_type common_len = common_path(p1, p2);
if (common_len == 1) {
if (p2_len != 1 || p1_len == 0 || p1[0] != p2[0]
|| (p1_len != 1 && p1[1] != '/'))
return false;
} else if (common_len != p2_len)
if (p2[p2_len - 1] == '/')
++common_len;
if (common_len != p2_len)
return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre))

View File

@ -193,9 +193,7 @@ docstring::size_type common_path(docstring const & p1, docstring const & p2)
--i; // here was the last match
while (i && p1[i] != '/')
--i;
} else
--i;
}
return i;
}
@ -212,13 +210,12 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
docstring const p2 = from_utf8(pre);
docstring::size_type const p1_len = p1.length();
docstring::size_type const p2_len = p2.length();
docstring::size_type const common_len = common_path(p1, p2) + 1;
docstring::size_type common_len = common_path(p1, p2);
if (common_len == 1) {
if (p2_len != 1 || p1_len == 0 || p1[0] != p2[0]
|| (p1_len != 1 && p1[1] != '/'))
return false;
} else if (common_len != p2_len)
if (p2[p2_len - 1] == '/')
++common_len;
if (common_len != p2_len)
return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre))