forked from lix-project/lix
Improve String Handling
This commit is contained in:
parent
0bc66e529f
commit
1885d579db
|
@ -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 : s)
|
||||||
for (auto & c : r)
|
|
||||||
c = std::tolower(c);
|
c = std::tolower(c);
|
||||||
return r;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ std::string shellEscape(const std::string_view s)
|
||||||
{
|
{
|
||||||
std::string r;
|
std::string r;
|
||||||
r.reserve(s.size() + 2);
|
r.reserve(s.size() + 2);
|
||||||
r += "'";
|
r += '\'';
|
||||||
for (auto & i : s)
|
for (auto & i : s)
|
||||||
if (i == '\'') r += "'\\''"; else r += i;
|
if (i == '\'') r += "'\\''"; else r += i;
|
||||||
r += '\'';
|
r += '\'';
|
||||||
|
|
|
@ -180,7 +180,7 @@ bool hasSuffix(std::string_view s, std::string_view suffix);
|
||||||
/**
|
/**
|
||||||
* Convert a string to lower case.
|
* 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