From owner-svn-src-head@freebsd.org Fri Mar 24 13:46:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28AA9D149CE; Fri, 24 Mar 2017 13:46:28 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC6803A4; Fri, 24 Mar 2017 13:46:27 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2ODkR1j019399; Fri, 24 Mar 2017 13:46:27 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2ODkQtJ019397; Fri, 24 Mar 2017 13:46:26 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201703241346.v2ODkQtJ019397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 24 Mar 2017 13:46:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315901 - head/sbin/devd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 13:46:28 -0000 Author: imp Date: Fri Mar 24 13:46:26 2017 New Revision: 315901 URL: https://svnweb.freebsd.org/changeset/base/315901 Log: Use a more stream-lined version of fix_value. Submitted by: ian@ Modified: head/sbin/devd/devd.cc head/sbin/devd/devd.hh Modified: head/sbin/devd/devd.cc ============================================================================== --- head/sbin/devd/devd.cc Fri Mar 24 11:46:49 2017 (r315900) +++ head/sbin/devd/devd.cc Fri Mar 24 13:46:26 2017 (r315901) @@ -417,24 +417,16 @@ var_list::is_set(const string &var) cons * converted to ". For all other characters, both \ and following * character. So the string 'fre\:\"' is translated to 'fred\:"'. */ -const std::string & +std::string var_list::fix_value(const std::string &val) const { - char *tmp, *dst; - const char *src; - std::string *rv; - - dst = tmp = new char[val.length()]; - src = val.c_str(); - while (*src) { - if (*src == '\\' && src[1] == '"') - src++; - else - *dst++ = *src++; - } - rv = new string(tmp); - delete tmp; - return *rv; + std::string rv(val); + std::string::size_type pos(0); + + while ((pos = rv.find("\\\"", pos)) != rv.npos) { + rv.erase(pos, 1); + } + return (rv); } void Modified: head/sbin/devd/devd.hh ============================================================================== --- head/sbin/devd/devd.hh Fri Mar 24 11:46:49 2017 (r315900) +++ head/sbin/devd/devd.hh Fri Mar 24 13:46:26 2017 (r315901) @@ -57,7 +57,7 @@ public: static const std::string nothing; private: - const std::string &fix_value(const std::string &val) const; + std::string fix_value(const std::string &val) const; std::map _vars; };