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:
Warner Losh 2018-06-28 01:45:53 +00:00
parent 54aa407625
commit 95cbefb3bf

View File

@ -640,6 +640,8 @@ string
config::shell_quote(const string &s)
{
string buffer;
const char *cs, *ce;
char c;
/*
* 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 += '$';
buffer += '\'';
for (const char &c : s) {
cs = s.c_str();
ce = cs + strlen(cs);
for (; cs < ce; cs++) {
c = *cs;
if (c == '\'' || c == '\\') {
buffer += '\\';
}