diff options
Diffstat (limited to 'cli/parser.cxx')
-rw-r--r-- | cli/parser.cxx | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/cli/parser.cxx b/cli/parser.cxx index faac290..164a3c0 100644 --- a/cli/parser.cxx +++ b/cli/parser.cxx @@ -946,25 +946,34 @@ option_def (token& t) string parser:: doc_string (const char* l, size_t n) { - // Get rid of '"'. + // Get rid of '"', convert '\"' to just '"'. // string t1, t2, t3; char p ('\0'); for (size_t i (0); i < n; ++i) { - if (l[i] == '"' && p != '\\') + char c (l[i]); + + if (c == '"') + { + if (p == '\\') + { + t1[t1.size () - 1] = '"'; // Replace '\' with '"'. + p = c; + } continue; + } // We need to keep track of \\ escapings so we don't confuse // them with \", as in "\\". // - if (l[i] == '\\' && p == '\\') + if (c == '\\' && p == '\\') p = '\0'; else - p = l[i]; + p = c; - t1 += l[i]; + t1 += c; } // Get rid of leading and trailing spaces in each line. Also handle |