source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: When the -n or -t flag is given to makewhatis(8),  write names
Date: Thu, 3 Apr 2014 22:31:07 -0400 (EDT)	[thread overview]
Message-ID: <201404040231.s342V7F6013366@krisdoz.my.domain> (raw)

Log Message:
-----------
When the -n or -t flag is given to makewhatis(8), 
write names and decriptions to stdout,
in a format similar to apropos(1) output.
Inspired by espie@'s makewhatis.

Modified Files:
--------------
    mdocml:
        mandocdb.8
        mandocdb.c

Revision Data
-------------
Index: mandocdb.8
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.8,v
retrieving revision 1.24
retrieving revision 1.25
diff -Lmandocdb.8 -Lmandocdb.8 -u -p -r1.24 -r1.25
--- mandocdb.8
+++ mandocdb.8
@@ -105,8 +105,8 @@ Merge (remove and re-add)
 to the database in
 .Ar dir .
 .It Fl n
-Do not create or modify any database;
-scan and parse only.
+Do not create or modify any database; scan and parse only,
+and print manual page names and descriptions to standard output.
 .It Fl p
 Print warnings about potential problems with manual pages
 to the standard error output.
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.127 -r1.128
--- mandocdb.c
+++ mandocdb.c
@@ -1858,11 +1858,43 @@ dbadd(struct mpage *mpage, struct mchars
 	size_t		 i;
 	unsigned int	 slot;
 
-	if (debug)
-		say(mpage->mlinks->file, "Adding to database");
+	mlink = mpage->mlinks;
 
-	if (nodb)
+	if (nodb) {
+		while (NULL != mlink) {
+			fputs(mlink->name, stdout);
+			if (NULL == mlink->next ||
+			    strcmp(mlink->dsec, mlink->next->dsec) ||
+			    strcmp(mlink->fsec, mlink->next->fsec) ||
+			    strcmp(mlink->arch, mlink->next->arch)) {
+				putchar('(');
+				if ('\0' == *mlink->dsec)
+					fputs(mlink->fsec, stdout);
+				else
+					fputs(mlink->dsec, stdout);
+				if ('\0' != *mlink->arch)
+					printf("/%s", mlink->arch);
+				putchar(')');
+			}
+			mlink = mlink->next;
+			if (NULL != mlink)
+				fputs(", ", stdout);
+		}
+		for (key = ohash_first(&strings, &slot); NULL != key;
+		     key = ohash_next(&strings, &slot)) {
+			if (TYPE_Nd & key->mask) {
+				if (NULL == key->rendered)
+					render_key(mc, key);
+				printf(" - %s", key->rendered);
+				break;
+			}
+		}
+		putchar('\n');
 		return;
+	}
+
+	if (debug)
+		say(mlink->file, "Adding to database");
 
 	i = 1;
 	SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form);
@@ -1870,8 +1902,10 @@ dbadd(struct mpage *mpage, struct mchars
 	mpage->recno = sqlite3_last_insert_rowid(db);
 	sqlite3_reset(stmts[STMT_INSERT_PAGE]);
 
-	for (mlink = mpage->mlinks; mlink; mlink = mlink->next)
+	while (NULL != mlink) {
 		dbadd_mlink(mlink);
+		mlink = mlink->next;
+	}
 
 	for (key = ohash_first(&strings, &slot); NULL != key;
 	     key = ohash_next(&strings, &slot)) {
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-04-04  2:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201404040231.s342V7F6013366@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).