Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb Fix extraction of section number and mach...



details:   https://anonhg.NetBSD.org/src/rev/21ad0c7b057e
branches:  trunk
changeset: 816669:21ad0c7b057e
user:      abhinav <abhinav%NetBSD.org@localhost>
date:      Sun Jul 17 12:18:12 2016 +0000

description:
Fix extraction of section number and machine architecture from man pages.
With the latest API, mdoc_validate()/man_validate() needs to be called before
reading the roff_man.meta field, otherwise it is NULL.

Also, if a man page doesn't specify machine architecture, don't default to '?'
, let it be stored as null in the db. Otherwise, the output of apropos(1) shows
the names of the results as \?/<title>

diffstat:

 usr.sbin/makemandb/makemandb.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (50 lines):

diff -r 4660e4a2c3c3 -r 21ad0c7b057e usr.sbin/makemandb/makemandb.c
--- a/usr.sbin/makemandb/makemandb.c    Sun Jul 17 10:46:43 2016 +0000
+++ b/usr.sbin/makemandb/makemandb.c    Sun Jul 17 12:18:12 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: makemandb.c,v 1.40 2016/07/15 19:41:33 christos Exp $  */
+/*     $NetBSD: makemandb.c,v 1.41 2016/07/17 12:18:12 abhinav Exp $   */
 /*
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.40 2016/07/15 19:41:33 christos Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.41 2016/07/17 12:18:12 abhinav Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -928,16 +928,18 @@
                return;
        }
 
-       set_machine(roff, rec);
-       set_section(roff, rec);
        if (roff->macroset == MACROSET_MDOC) {
+               mdoc_validate(roff);
                rec->page_type = MDOC;
                proff_node(roff->first->child, rec, mdocs);
        } else if (roff->macroset == MACROSET_MAN) {
+               man_validate(roff);
                rec->page_type = MAN;
                proff_node(roff->first->child, rec, mans);
        } else
                warnx("Unknown macroset %d", roff->macroset);
+       set_machine(roff, rec);
+       set_section(roff, rec);
 }
 
 /*
@@ -967,8 +969,8 @@
        if (rm == NULL)
                return;
        const struct roff_meta *rm_meta = &rm->meta;
-       const char *a = rm_meta->arch == NULL ? "?" : rm_meta->arch;
-       rec->machine = estrdup(a);
+       if (rm_meta->arch)
+               rec->machine = estrdup(rm_meta->arch);
 }
 
 /*



Home | Main Index | Thread Index | Old Index