diff --git a/ppremake/ppScope.cxx b/ppremake/ppScope.cxx index 688b04a300..3acacf49a4 100644 --- a/ppremake/ppScope.cxx +++ b/ppremake/ppScope.cxx @@ -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 ¶ms) { } + + //////////////////////////////////////////////////////////////////// // Function: PPScope::expand_standardize // Access: Private @@ -2099,6 +2103,31 @@ expand_subst(const string ¶ms) { return str; } +//////////////////////////////////////////////////////////////////// +// Function: PPScope::expand_findstrnig +// Access: Private +// Description: Expands the "findstring" function variable. +//////////////////////////////////////////////////////////////////// +string PPScope:: +expand_findstring(const string ¶ms) { + // Split the string up into tokens based on the commas. + vector 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 diff --git a/ppremake/ppScope.h b/ppremake/ppScope.h index a5bc396c06..1a4e2d6e35 100644 --- a/ppremake/ppScope.h +++ b/ppremake/ppScope.h @@ -94,6 +94,7 @@ private: string expand_standardize(const string ¶ms); string expand_length(const string ¶ms); string expand_substr(const string ¶ms); + string expand_findstring(const string ¶ms); string expand_dir(const string ¶ms); string expand_notdir(const string ¶ms); string expand_suffix(const string ¶ms);