From 95cbefb3bfda0e6d10fc5a4d1a5646ad97a0a1b3 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 28 Jun 2018 01:45:53 +0000 Subject: [PATCH] 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 --- sbin/devd/devd.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index bb7195cafee6..9aa402494618 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -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 += '\\'; }