From a5cf99ba0ce655c79f97727aa85c3afd804f98c9 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 22 Jan 2014 20:58:39 +0000 Subject: 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 . --- mandocdb.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'mandocdb.c') 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 * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -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. */ -- cgit v1.2.3-56-ge451