1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 22:51:47 +02:00

Improve String Handling

This commit is contained in:
Jacek Galowicz 2023-11-02 15:49:22 +01:00
parent 0bc66e529f
commit 1885d579db
3 changed files with 10 additions and 7 deletions

View file

@ -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 += '\'';