Add a toLower utility function
This commit is contained in:
parent
e07c0dcf5c
commit
a75d11a7e6
2 changed files with 14 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -1087,6 +1088,15 @@ bool hasSuffix(const string & s, const string & suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string toLower(const std::string & s)
|
||||||
|
{
|
||||||
|
std::string r(s);
|
||||||
|
for (auto & c : r)
|
||||||
|
c = std::tolower(c);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string decodeOctalEscaped(const string & s)
|
string decodeOctalEscaped(const string & s)
|
||||||
{
|
{
|
||||||
string r;
|
string r;
|
||||||
|
|
|
@ -334,6 +334,10 @@ bool hasPrefix(const string & s, const string & prefix);
|
||||||
bool hasSuffix(const string & s, const string & suffix);
|
bool hasSuffix(const string & s, const string & suffix);
|
||||||
|
|
||||||
|
|
||||||
|
/* Convert a string to lower case. */
|
||||||
|
std::string toLower(const std::string & s);
|
||||||
|
|
||||||
|
|
||||||
/* Escape a string that contains octal-encoded escape codes such as
|
/* Escape a string that contains octal-encoded escape codes such as
|
||||||
used in /etc/fstab and /proc/mounts (e.g. "foo\040bar" decodes to
|
used in /etc/fstab and /proc/mounts (e.g. "foo\040bar" decodes to
|
||||||
"foo bar"). */
|
"foo bar"). */
|
||||||
|
|
Loading…
Reference in a new issue