summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-01-16 12:28:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-01-16 12:28:50 +0200
commit650ea3bd3bac1fa50f9c8566d5def774c5eb2fee (patch)
tree7a6eaa6011698022e5a9f49bbfa275c52fb86021
parent49cf9e4c5f3ac561eaa5716d41601006ebb9b8e8 (diff)
Handle newline-only lines in documentation string parser
-rw-r--r--cli/parser.cxx49
1 files changed, 26 insertions, 23 deletions
diff --git a/cli/parser.cxx b/cli/parser.cxx
index b63efcb..b10cb0e 100644
--- a/cli/parser.cxx
+++ b/cli/parser.cxx
@@ -1016,36 +1016,39 @@ doc_string (const char* l, size_t n)
more = false;
}
- // In the pre mode we only remove up to m leading whitespaces.
- //
+ if (b != e) // Unless this is just a single newline.
{
- size_t i (0);
- while (b < e &&
- (t1[b] == 0x20 || t1[b] == 0x0D || t1[b] == 0x09) &&
- (!pre || i != m))
+ // In the pre mode we only remove up to m leading whitespaces.
+ //
{
- ++b;
- ++i;
- }
+ size_t i (0);
+ while (b < e &&
+ (t1[b] == 0x20 || t1[b] == 0x0D || t1[b] == 0x09) &&
+ (!pre || i != m))
+ {
+ ++b;
+ ++i;
+ }
- if (!pre)
- m = i;
- }
+ if (!pre)
+ m = i;
+ }
- --e;
- while (e > b && (t1[e] == 0x20 || t1[e] == 0x0D || t1[e] == 0x09))
--e;
+ while (e > b && (t1[e] == 0x20 || t1[e] == 0x0D || t1[e] == 0x09))
+ --e;
- if (b == e && t1[b] == '\\')
- {
- // 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 && t1[b] == '\\')
+ {
+ // Use Start of Text (0x02) and End of Text (0x03) special
+ // characters as pre-formatted fragment markers.
+ //
+ pre = !pre;
+ t2 += (pre ? 0x02 : 0x03);
+ }
+ else if (b <= e)
+ t2.append (t1, b, e - b + 1);
}
- else if (b <= e)
- t2.append (t1, b, e - b + 1);
if (more)
{