Jon Parise adds $[join]

This commit is contained in:
Jon Parise 2003-01-29 15:27:43 +00:00 committed by David Rose
parent 4c0ae9793d
commit c273c065f5
2 changed files with 29 additions and 0 deletions

View File

@ -1047,6 +1047,8 @@ r_expand_variable(const string &str, size_t &vp,
return expand_filter(params);
} else if (funcname == "filter_out" || funcname == "filter-out") {
return expand_filter_out(params);
} else if (funcname == "join") {
return expand_join(params);
} else if (funcname == "sort") {
return expand_sort(params);
} else if (funcname == "unique") {
@ -2390,6 +2392,32 @@ expand_wordsubst(const string &params) {
return result;
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_join
// Access: Private
// Description: Expands the "join" function variable: joins the list
// of words using the specified separator.
////////////////////////////////////////////////////////////////////
string PPScope::
expand_join(const string &params) {
// Split the string up into tokens based on the spaces.
vector<string> words;
tokenize_whitespace(expand_string(params), words);
if (words.size() < 2) {
cerr << "joins requires at least two parameters.\n";
return string();
}
const string sep(words[0]);
// Remove the first word in the list (which we use as the separator).
words.erase(words.begin());
string result = repaste(words, sep);
return result;
}
////////////////////////////////////////////////////////////////////
// Function: PPScope::expand_sort
// Access: Private

View File

@ -113,6 +113,7 @@ private:
string expand_filter_out(const string &params);
string expand_wordsubst(const string &params);
string expand_subst(const string &params);
string expand_join(const string &params);
string expand_sort(const string &params);
string expand_unique(const string &params);
string expand_matrix(const string &params);