diff options
author | 2014-03-22 00:56:07 +0000 | |
---|---|---|
committer | 2014-03-22 00:56:07 +0000 | |
commit | fd5b70b0860c48034dc827d06ba321989b59c8c4 (patch) | |
tree | 032ee7f63cf73168358a5a6abc0fcce020b980b7 /usr.bin/mandoc/man.c | |
parent | <sys/agpio.h> is gone; this compiles fine without it (diff) | |
download | wireguard-openbsd-fd5b70b0860c48034dc827d06ba321989b59c8c4.tar.xz wireguard-openbsd-fd5b70b0860c48034dc827d06ba321989b59c8c4.zip |
If a man(7) NAME section contains macros, avoid truncated or empty
entries for .Nd in mandocdb(8), instead use the macro content
recursively. This improves indexing of more than 200 manuals
in Xenocara, i.e. more than 15%, in particular GL and some Xkb.
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r-- | usr.bin/mandoc/man.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index a69c0e36b38..bd1cfd729d4 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.75 2014/03/21 22:17:01 schwarze Exp $ */ +/* $Id: man.c,v 1.76 2014/03/22 00:56:07 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <assert.h> +#include <ctype.h> #include <stdarg.h> #include <stdlib.h> #include <stdio.h> @@ -702,3 +703,42 @@ man_mparse(const struct man *man) assert(man && man->parse); return(man->parse); } + +void +man_deroff(char **dest, const struct man_node *n) +{ + char *cp; + size_t sz; + + if (MAN_TEXT != n->type) { + for (n = n->child; n; n = n->next) + man_deroff(dest, n); + return; + } + + /* Skip leading whitespace. */ + + for (cp = n->string; '\0' != *cp; cp++) + if (0 == isspace((unsigned char)*cp)) + break; + + /* Skip trailing whitespace. */ + + for (sz = strlen(cp); sz; sz--) + if (0 == isspace((unsigned char)cp[sz-1])) + break; + + /* Skip empty strings. */ + + if (0 == sz) + return; + + if (NULL == *dest) { + *dest = mandoc_strndup(cp, sz); + return; + } + + mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp); + free(*dest); + *dest = cp; +} |