aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-01-22 20:58:39 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-01-22 20:58:39 +0000
commita5cf99ba0ce655c79f97727aa85c3afd804f98c9 (patch)
treee92a3c2a62fc2c363af2ca9c2aa16c0bcb34c80f /mandocdb.c
parentfbfac7f409fc3e746d03f0beb37e36723d353e48 (diff)
downloadmandoc-a5cf99ba0ce655c79f97727aa85c3afd804f98c9.tar.gz
mandoc-a5cf99ba0ce655c79f97727aa85c3afd804f98c9.tar.zst
mandoc-a5cf99ba0ce655c79f97727aa85c3afd804f98c9.zip
Implement the \: (optional line break) escape sequence,
documented in the Ossanna-Kernighan-Ritter troff manual and also supported by groff. Missing feature reported by Steffen Nurpmeso <sdaoden at gmail dot com>.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/mandocdb.c b/mandocdb.c
index e7963859..eea9ab1c 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.113 2014/01/19 22:48:16 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.114 2014/01/22 20:58:39 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1664,7 +1664,7 @@ static void
render_key(struct mchars *mc, struct str *key)
{
size_t sz, bsz, pos;
- char utfbuf[7], res[5];
+ char utfbuf[7], res[6];
char *buf;
const char *seq, *cpp, *val;
int len, u;
@@ -1676,7 +1676,8 @@ render_key(struct mchars *mc, struct str *key)
res[1] = '\t';
res[2] = ASCII_NBRSP;
res[3] = ASCII_HYPH;
- res[4] = '\0';
+ res[4] = ASCII_BREAK;
+ res[5] = '\0';
val = key->key;
bsz = strlen(val);
@@ -1707,15 +1708,23 @@ render_key(struct mchars *mc, struct str *key)
val += sz;
}
- if (ASCII_HYPH == *val) {
+ switch (*val) {
+ case (ASCII_HYPH):
buf[pos++] = '-';
val++;
continue;
- } else if ('\t' == *val || ASCII_NBRSP == *val) {
+ case ('\t'):
+ /* FALLTHROUGH */
+ case (ASCII_NBRSP):
buf[pos++] = ' ';
val++;
+ /* FALLTHROUGH */
+ case (ASCII_BREAK):
continue;
- } else if ('\\' != *val)
+ default:
+ break;
+ }
+ if ('\\' != *val)
break;
/* Read past the slash. */