From c273c065f5a46eb80539ad76e00a91561d7a1c23 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 29 Jan 2003 15:27:43 +0000 Subject: [PATCH] Jon Parise adds $[join] --- ppremake/ppScope.cxx | 28 ++++++++++++++++++++++++++++ ppremake/ppScope.h | 1 + 2 files changed, 29 insertions(+) diff --git a/ppremake/ppScope.cxx b/ppremake/ppScope.cxx index 9732b9af65..adb70e3991 100644 --- a/ppremake/ppScope.cxx +++ b/ppremake/ppScope.cxx @@ -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 ¶ms) { 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 ¶ms) { + // Split the string up into tokens based on the spaces. + vector 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 diff --git a/ppremake/ppScope.h b/ppremake/ppScope.h index e220062e4f..11c41b3234 100644 --- a/ppremake/ppScope.h +++ b/ppremake/ppScope.h @@ -113,6 +113,7 @@ private: string expand_filter_out(const string ¶ms); string expand_wordsubst(const string ¶ms); string expand_subst(const string ¶ms); + string expand_join(const string ¶ms); string expand_sort(const string ¶ms); string expand_unique(const string ¶ms); string expand_matrix(const string ¶ms);