Module Name: src
Committed By: abhinav
Date: Sun Jul 17 12:18:12 UTC 2016
Modified Files:
src/usr.sbin/makemandb: makemandb.c
Log Message:
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>
To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/makemandb/makemandb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.40 src/usr.sbin/makemandb/makemandb.c:1.41
--- src/usr.sbin/makemandb/makemandb.c:1.40 Fri Jul 15 19:41:33 2016
+++ src/usr.sbin/makemandb/makemandb.c Sun Jul 17 12:18:12 2016
@@ -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 <[email protected]>
* Copyright (c) 2011 Kristaps Dzonsons <[email protected]>
@@ -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 @@ begin_parse(const char *file, struct mpa
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 @@ set_machine(const struct roff_man *rm, m
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);
}
/*