summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-09-02 13:37:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-09-02 13:37:26 +0200
commit90a548af2ca2688ccd40531a1b0359ab33ba1324 (patch)
tree146ad9aec0bf0326436b7ecfca10418e2067233b
parentce1681f2524e512f461a446ee5ca86adfe9116df (diff)
Add support for escaping pre-formatted fragment marker
For example: \ \\ \ Of course now we cannot specify the literal escape sequence. Perhaps we should recognize a line consisting of N (N > 1) back slashes and output all but the first.
-rw-r--r--cli/parser.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/cli/parser.cxx b/cli/parser.cxx
index ba20ab1..43b2764 100644
--- a/cli/parser.cxx
+++ b/cli/parser.cxx
@@ -1170,13 +1170,20 @@ doc_string (const char* l, size_t n)
while (e > b && (t1[e] == 0x20 || t1[e] == 0x0D || t1[e] == 0x09))
--e;
- if (b == e && t1[b] == '\\')
+ // Pre-formatted fragment marker or its escape.
+ //
+ if (t1[b] == '\\' && (b == e || (b + 1 == e && t1[e] == '\\')))
{
// Use Start of Text (0x02) and End of Text (0x03) special
// characters as pre-formatted fragment markers.
//
- pre = !pre;
- t2 += (pre ? 0x02 : 0x03);
+ if (b == e)
+ {
+ pre = !pre;
+ t2 += (pre ? 0x02 : 0x03);
+ }
+ else
+ t2 += '\\'; // Unescape.
}
else if (b <= e)
t2.append (t1, b, e - b + 1);