Add function for quoting strings
(cherry picked from commit 7dcf5b011a
)
This commit is contained in:
parent
5a7e7fc35f
commit
edc34cc1a2
|
@ -1904,7 +1904,7 @@ void DerivationGoal::startBuilder()
|
||||||
concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
|
concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
|
||||||
worker.store.printStorePath(drvPath),
|
worker.store.printStorePath(drvPath),
|
||||||
settings.thisSystem,
|
settings.thisSystem,
|
||||||
concatStringsSep(", ", settings.systemFeatures));
|
concatStringsSep<StringSet>(", ", settings.systemFeatures));
|
||||||
|
|
||||||
if (drv->isBuiltin())
|
if (drv->isBuiltin())
|
||||||
preloadNSS();
|
preloadNSS();
|
||||||
|
|
|
@ -741,12 +741,7 @@ std::string Store::showPaths(const StorePathSet & paths)
|
||||||
|
|
||||||
string showPaths(const PathSet & paths)
|
string showPaths(const PathSet & paths)
|
||||||
{
|
{
|
||||||
string s;
|
return concatStringsSep(", ", quoteStrings(paths));
|
||||||
for (auto & i : paths) {
|
|
||||||
if (s.size() != 0) s += ", ";
|
|
||||||
s += "'" + i + "'";
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1205,28 +1205,6 @@ template StringSet tokenizeString(std::string_view s, const string & separators)
|
||||||
template vector<string> tokenizeString(std::string_view s, const string & separators);
|
template vector<string> tokenizeString(std::string_view 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)
|
string chomp(const string & s)
|
||||||
{
|
{
|
||||||
size_t i = s.find_last_not_of(" \n\r\t");
|
size_t i = s.find_last_not_of(" \n\r\t");
|
||||||
|
|
|
@ -345,8 +345,26 @@ template<class C> C tokenizeString(std::string_view s, const string & separators
|
||||||
|
|
||||||
/* Concatenate the given strings with a separator between the
|
/* Concatenate the given strings with a separator between the
|
||||||
elements. */
|
elements. */
|
||||||
string concatStringsSep(const string & sep, const Strings & ss);
|
template<class C>
|
||||||
string concatStringsSep(const string & sep, const StringSet & ss);
|
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. */
|
/* Remove trailing whitespace from a string. */
|
||||||
|
|
Loading…
Reference in a new issue