fix fullpath globs

This commit is contained in:
David Rose 2002-05-23 02:17:19 +00:00
parent af3861a402
commit 9db8ebaac7

View File

@ -67,18 +67,25 @@ has_glob_characters() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
int GlobPattern:: int GlobPattern::
match_files(vector_string &results, const Filename &cwd) { match_files(vector_string &results, const Filename &cwd) {
string next_pattern, next_suffix; string prefix, pattern, suffix;
size_t slash = _pattern.find('/'); string source = _pattern;
if (slash == string::npos) { if (!source.empty() && source[0] == '/') {
next_pattern = _pattern; // If the first character is a slash, that becomes the prefix.
} else { prefix = "/";
next_pattern = _pattern.substr(0, slash); source = source.substr(1);
next_suffix = _pattern.substr(slash + 1);
} }
GlobPattern next_glob(next_pattern); size_t slash = source.find('/');
return next_glob.r_match_files(Filename(), next_suffix, results, cwd); if (slash == string::npos) {
pattern = source;
} else {
pattern = source.substr(0, slash);
suffix = source.substr(slash + 1);
}
GlobPattern glob(pattern);
return glob.r_match_files(prefix, suffix, results, cwd);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////