We're not, yet, at C++11 capable on all our plaforms.
Use a possibly slower, but C++98 compatibe way to iterate through the string. Noticed by: g++ 4.2.1 and Mark Millard
This commit is contained in:
parent
54aa407625
commit
95cbefb3bf
@ -640,6 +640,8 @@ string
|
|||||||
config::shell_quote(const string &s)
|
config::shell_quote(const string &s)
|
||||||
{
|
{
|
||||||
string buffer;
|
string buffer;
|
||||||
|
const char *cs, *ce;
|
||||||
|
char c;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enclose the string in $' ' with escapes for ' and / characters making
|
* Enclose the string in $' ' with escapes for ' and / characters making
|
||||||
@ -649,7 +651,10 @@ config::shell_quote(const string &s)
|
|||||||
buffer.reserve(s.length() * 3 / 2);
|
buffer.reserve(s.length() * 3 / 2);
|
||||||
buffer += '$';
|
buffer += '$';
|
||||||
buffer += '\'';
|
buffer += '\'';
|
||||||
for (const char &c : s) {
|
cs = s.c_str();
|
||||||
|
ce = cs + strlen(cs);
|
||||||
|
for (; cs < ce; cs++) {
|
||||||
|
c = *cs;
|
||||||
if (c == '\'' || c == '\\') {
|
if (c == '\'' || c == '\\') {
|
||||||
buffer += '\\';
|
buffer += '\\';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user