summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-19 20:41:52 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-19 20:41:52 -0800
commit775cf28a2f6045caf652108092ab79ead3bc0056 (patch)
tree4d9c69c20ab9bb89adb7d0b8f6a06de86f046b8a /src
parent70d53619797fa91d1d8ea597ae21c84e64175c4c (diff)
Man writer: ensure we properly escape multiline strings.
Diffstat (limited to 'src')
-rw-r--r--src/man.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/man.c b/src/man.c
index 2c8a3a5..aa81b2b 100644
--- a/src/man.c
+++ b/src/man.c
@@ -14,12 +14,13 @@ static void escape_man(cmark_strbuf *dest, const unsigned char *source, int leng
{
int i;
unsigned char c;
+ bool beginLine = true;
for (i = 0; i < length; i++) {
c = source[i];
- if (c == '.' && i == 0) {
+ if (c == '.' && beginLine) {
cmark_strbuf_puts(dest, "\\&.");
- } else if (c == '\'' && i == 0) {
+ } else if (c == '\'' && beginLine) {
cmark_strbuf_puts(dest, "\\&'");
} else if (c == '-') {
cmark_strbuf_puts(dest, "\\-");
@@ -28,6 +29,7 @@ static void escape_man(cmark_strbuf *dest, const unsigned char *source, int leng
} else {
cmark_strbuf_putc(dest, source[i]);
}
+ beginLine = (c == '\n');
}
}