add findstring

This commit is contained in:
georges 2001-01-03 19:24:29 +00:00
parent 79a876bcb1
commit d6340a6941
2 changed files with 30 additions and 0 deletions

View File

@ -838,6 +838,8 @@ r_expand_variable(const string &str, size_t &vp,
return expand_length(params);
} else if (funcname == "substr") {
return expand_substr(params);
} else if (funcname == "findstring") {
return expand_findstring(params);
} else if (funcname == "dir") {
return expand_dir(params);
} else if (funcname == "notdir") {
@ -1515,6 +1517,8 @@ expand_shell(const string &params) {
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_standardize
// Access: Private
@ -2099,6 +2103,31 @@ expand_subst(const string &params) {
return str;
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_findstrnig
// Access: Private
// Description: Expands the "findstring" function variable.
////////////////////////////////////////////////////////////////////
string PPScope::
expand_findstring(const string &params) {
// Split the string up into tokens based on the commas.
vector<string> tokens;
tokenize_params(params, tokens, true);
if (tokens.size() != 2) {
cerr << "findstring requires two parameters.\n";
return string();
}
string str = tokens.back();
const string &srchstr = tokens[0];
size_t q = 0;
size_t p = str.find(srchstr, q);
if(p == string::npos)
str = "";
return str;
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_wordsubst
// Access: Private

View File

@ -94,6 +94,7 @@ private:
string expand_standardize(const string &params);
string expand_length(const string &params);
string expand_substr(const string &params);
string expand_findstring(const string &params);
string expand_dir(const string &params);
string expand_notdir(const string &params);
string expand_suffix(const string &params);