mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Improve String Handling
This commit is contained in:
parent
0bc66e529f
commit
1885d579db
3 changed files with 10 additions and 7 deletions
|
@ -116,7 +116,11 @@ Path canonPath(PathView path, bool resolveSymlinks)
|
|||
}
|
||||
}
|
||||
|
||||
return s.empty() ? "/" : std::move(s);
|
||||
if (s.empty()) {
|
||||
s = "/";
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -122,12 +122,11 @@ bool hasSuffix(std::string_view s, std::string_view suffix)
|
|||
}
|
||||
|
||||
|
||||
std::string toLower(const std::string & s)
|
||||
std::string toLower(std::string s)
|
||||
{
|
||||
std::string r(s);
|
||||
for (auto & c : r)
|
||||
for (auto & c : s)
|
||||
c = std::tolower(c);
|
||||
return r;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,7 +134,7 @@ std::string shellEscape(const std::string_view s)
|
|||
{
|
||||
std::string r;
|
||||
r.reserve(s.size() + 2);
|
||||
r += "'";
|
||||
r += '\'';
|
||||
for (auto & i : s)
|
||||
if (i == '\'') r += "'\\''"; else r += i;
|
||||
r += '\'';
|
||||
|
|
|
@ -180,7 +180,7 @@ bool hasSuffix(std::string_view s, std::string_view suffix);
|
|||
/**
|
||||
* Convert a string to lower case.
|
||||
*/
|
||||
std::string toLower(const std::string & s);
|
||||
std::string toLower(std::string s);
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue