From 9b38cbd9069ed0dc215f7029e03b3af63ee0f699 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 23 Mar 2014 12:26:58 +0000 Subject: 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. --- man.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'man.c') diff --git a/man.c b/man.c index 113c72da..1e7e341c 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.125 2014/03/23 11:25:26 schwarze Exp $ */ +/* $Id: man.c,v 1.126 2014/03/23 12:26:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -706,3 +707,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; +} -- cgit v1.2.3