Module Name: src
Committed By: plunky
Date: Tue Apr 7 17:47:10 UTC 2015
Modified Files:
src/usr.sbin/makemandb: makemandb.c
Log Message:
largely apply patch from PR bin/47392 by Abhinav Upadhyay
change some comments to reflect reality, a variable name to enhance
readability, and adds an assert for safety.
To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.28 src/usr.sbin/makemandb/makemandb.c:1.29
--- src/usr.sbin/makemandb/makemandb.c:1.28 Thu Mar 12 14:57:18 2015
+++ src/usr.sbin/makemandb/makemandb.c Tue Apr 7 17:47:10 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: makemandb.c,v 1.28 2015/03/12 14:57:18 joerg Exp $ */
+/* $NetBSD: makemandb.c,v 1.29 2015/04/07 17:47:10 plunky 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.28 2015/03/12 14:57:18 joerg Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.29 2015/04/07 17:47:10 plunky Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -75,7 +75,7 @@ typedef struct mandb_rec {
secbuff errors; // ERRORS
char section[2];
- int xr_found;
+ int xr_found; // To track whether a .Xr was seen when parsing a section
/* Fields for mandb_meta table */
char *md5_hash;
@@ -973,12 +973,8 @@ pmdoc_Nm(const struct mdoc_node *n, mand
static void
pmdoc_Nd(const struct mdoc_node *n, mandb_rec *rec)
{
- /*
- * A static variable for keeping track of whether a Xr macro was seen
- * previously.
- */
char *buf = NULL;
- char *temp;
+ char *name;
char *nd_text;
if (n == NULL || (n->type != MDOC_TEXT && n->tok == MDOC_MAX))
@@ -988,11 +984,12 @@ pmdoc_Nd(const struct mdoc_node *n, mand
if (rec->xr_found && n->next) {
/*
* An Xr macro was seen previously, so parse this
- * and the next node.
+ * and the next node, as "Name(Section)".
*/
- temp = n->string;
+ name = n->string;
n = n->next;
- easprintf(&buf, "%s(%s)", temp, n->string);
+ assert(n->type == MDOC_TEXT);
+ easprintf(&buf, "%s(%s)", name, n->string);
concat(&rec->name_desc, buf);
free(buf);
} else {