aboutsummaryrefslogtreecommitdiff
path: root/sbin/devd/devd.cc
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2017-03-24 13:46:26 +0000
committerWarner Losh <imp@FreeBSD.org>2017-03-24 13:46:26 +0000
commit416823b103f80582ff94bef748b3abca470f8386 (patch)
treec4648a5b5e2c4e3800a471c7de3afbbe9990b806 /sbin/devd/devd.cc
parentdfe5f22fd710dd06dfb3d792274a505e5960d422 (diff)
Notes
Diffstat (limited to 'sbin/devd/devd.cc')
-rw-r--r--sbin/devd/devd.cc22
1 files changed, 7 insertions, 15 deletions
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index d37f0ee66c9e..a69c38c4a5a3 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -417,24 +417,16 @@ var_list::is_set(const string &var) const
* 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;
+ std::string rv(val);
+ std::string::size_type pos(0);
- 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;
+ while ((pos = rv.find("\\\"", pos)) != rv.npos) {
+ rv.erase(pos, 1);
+ }
+ return (rv);
}
void