Add function for quoting strings
This commit is contained in:
parent
2b8c63f303
commit
7dcf5b011a
4 changed files with 22 additions and 31 deletions
|
@ -1805,7 +1805,7 @@ void DerivationGoal::startBuilder()
|
|||
concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
|
||||
drvPath,
|
||||
settings.thisSystem,
|
||||
concatStringsSep(", ", settings.systemFeatures));
|
||||
concatStringsSep<StringSet>(", ", settings.systemFeatures));
|
||||
|
||||
if (drv->isBuiltin())
|
||||
preloadNSS();
|
||||
|
|
|
@ -726,12 +726,7 @@ ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven)
|
|||
|
||||
string showPaths(const PathSet & paths)
|
||||
{
|
||||
string s;
|
||||
for (auto & i : paths) {
|
||||
if (s.size() != 0) s += ", ";
|
||||
s += "'" + i + "'";
|
||||
}
|
||||
return s;
|
||||
return concatStringsSep(", ", quoteStrings(paths));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1167,28 +1167,6 @@ template StringSet tokenizeString(const string & s, const string & separators);
|
|||
template vector<string> tokenizeString(const string & s, const string & separators);
|
||||
|
||||
|
||||
string concatStringsSep(const string & sep, const Strings & ss)
|
||||
{
|
||||
string s;
|
||||
for (auto & i : ss) {
|
||||
if (s.size() != 0) s += sep;
|
||||
s += i;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
string concatStringsSep(const string & sep, const StringSet & ss)
|
||||
{
|
||||
string s;
|
||||
for (auto & i : ss) {
|
||||
if (s.size() != 0) s += sep;
|
||||
s += i;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
string chomp(const string & s)
|
||||
{
|
||||
size_t i = s.find_last_not_of(" \n\r\t");
|
||||
|
|
|
@ -334,8 +334,26 @@ template<class C> C tokenizeString(const string & s, const string & separators =
|
|||
|
||||
/* Concatenate the given strings with a separator between the
|
||||
elements. */
|
||||
string concatStringsSep(const string & sep, const Strings & ss);
|
||||
string concatStringsSep(const string & sep, const StringSet & ss);
|
||||
template<class C>
|
||||
string concatStringsSep(const string & sep, const C & ss)
|
||||
{
|
||||
string s;
|
||||
for (auto & i : ss) {
|
||||
if (s.size() != 0) s += sep;
|
||||
s += i;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/* Add quotes around a collection of strings. */
|
||||
template<class C> Strings quoteStrings(const C & c)
|
||||
{
|
||||
Strings res;
|
||||
for (auto & s : c)
|
||||
res.push_back("'" + s + "'");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* Remove trailing whitespace from a string. */
|
||||
|
|
Loading…
Reference in a new issue