diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-13 15:30:55 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-13 15:30:55 +0200 |
commit | 418792e491764cc0e11e86522d43835a3da82fa6 (patch) | |
tree | 779116bc14395673e4029da48321ea9bc9e58a08 /cli/parser.cxx | |
parent | 124341e83bb9e8959508fac8c798506f82f21938 (diff) |
Add support for man formatting
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 |