svn commit: r335756 - head/sbin/devd

Warner Losh imp at FreeBSD.org
Thu Jun 28 01:45:54 UTC 2018


Author: imp
Date: Thu Jun 28 01:45:53 2018
New Revision: 335756
URL: https://svnweb.freebsd.org/changeset/base/335756

Log:
  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

Modified:
  head/sbin/devd/devd.cc

Modified: head/sbin/devd/devd.cc
==============================================================================
--- head/sbin/devd/devd.cc	Thu Jun 28 01:32:37 2018	(r335755)
+++ head/sbin/devd/devd.cc	Thu Jun 28 01:45:53 2018	(r335756)
@@ -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 += '\\';
 		}


More information about the svn-src-head mailing list