diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-22 20:58:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-22 20:58:39 +0000 |
commit | 654e28baaa103a868af40d8ce155ddd09fe76f98 (patch) | |
tree | 061e60883aded25bdcf06071df7bf3b4e00c8548 /mandocdb.c | |
parent | 3d40007c4e92346d3e69337fa770e26de69c6ffe (diff) | |
download | mandoc-654e28baaa103a868af40d8ce155ddd09fe76f98.tar.gz |
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.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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. */ |