diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2020-06-08 23:04:05 +0300 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2020-06-13 16:56:41 +0300 |
| commit | a9fab4abcc1e517f872def35a3c48538d259b9e7 (patch) | |
| tree | 5b10d5d0bb1d27538858c7a37157cae11728237e /lib/utils/mu-utils.cc | |
| parent | dd0cb3112a7a5e1f9f95aeefc33fb14e0c0cb17d (diff) | |
mu: convert command-line tools to c++
Diffstat (limited to 'lib/utils/mu-utils.cc')
| -rw-r--r-- | lib/utils/mu-utils.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/utils/mu-utils.cc b/lib/utils/mu-utils.cc index 2354c0c..32a1785 100644 --- a/lib/utils/mu-utils.cc +++ b/lib/utils/mu-utils.cc @@ -165,14 +165,17 @@ Mu::split (const std::string& str, const std::string& sepa) std::string Mu::quote (const std::string& str) { - char *s = g_strescape (str.c_str(), NULL); - if (!s) - return {}; - - std::string res (s); - g_free (s); + std::string res{"\""}; + + for (auto&& k: str) { + switch (k) { + case '"' : res += "\\\""; break; + case '\\': res += "\\\\"; break; + default: res += k; + } + } - return "\"" + res + "\""; + return res + "\""; } std::string |
