Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/makemandb Use deroff() from mandoc(3) to directly p...



details:   https://anonhg.NetBSD.org/src/rev/894355960910
branches:  trunk
changeset: 346530:894355960910
user:      abhinav <abhinav%NetBSD.org@localhost>
date:      Sun Jul 17 15:56:14 2016 +0000

description:
Use deroff() from mandoc(3) to directly parse the Nd macro rather
than parsing it by hand.

With the latest mandoc(3), the .Nd macro was getting parsed twice. This fixes
that problem and cleans up the code as well.

ok christos@

diffstat:

 usr.sbin/makemandb/makemandb.c |  40 ++++------------------------------------
 1 files changed, 4 insertions(+), 36 deletions(-)

diffs (62 lines):

diff -r f6d025877b79 -r 894355960910 usr.sbin/makemandb/makemandb.c
--- a/usr.sbin/makemandb/makemandb.c    Sun Jul 17 13:49:43 2016 +0000
+++ b/usr.sbin/makemandb/makemandb.c    Sun Jul 17 15:56:14 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: makemandb.c,v 1.41 2016/07/17 12:18:12 abhinav Exp $   */
+/*     $NetBSD: makemandb.c,v 1.42 2016/07/17 15:56:14 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.41 2016/07/17 12:18:12 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.42 2016/07/17 15:56:14 abhinav Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -999,41 +999,9 @@
 static void
 pmdoc_Nd(const struct roff_node *n, mandb_rec *rec)
 {
-       char *buf = NULL;
-       char *name;
-       char *nd_text;
-
-       if (n == NULL || (n->type != ROFFT_TEXT && n->tok == MDOC_MAX))
-               return;
+       if (n->type == ROFFT_BODY)
+               deroff(&rec->name_desc, n);
 
-       if (n->type == ROFFT_TEXT) {
-               if (rec->xr_found && n->next) {
-                       /*
-                        * An Xr macro was seen previously, so parse this
-                        * and the next node, as "Name(Section)".
-                        */
-                       name = n->string;
-                       n = n->next;
-                       assert(n->type == ROFFT_TEXT);
-                       easprintf(&buf, "%s(%s)", name, n->string);
-                       concat(&rec->name_desc, buf);
-                       free(buf);
-               } else {
-                       nd_text = parse_escape(n->string);
-                       concat(&rec->name_desc, nd_text);
-                       free(nd_text);
-               }
-               rec->xr_found = 0;
-       } else if (mdocs[n->tok] == pmdoc_Xr) {
-               /* Remember that we have encountered an Xr macro */
-               rec->xr_found = 1;
-       }
-
-       if (n->child)
-               pmdoc_Nd(n->child, rec);
-
-       if(n->next)
-               pmdoc_Nd(n->next, rec);
 }
 
 /*



Home | Main Index | Thread Index | Old Index