source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Let mandoc-db also collect -man descriptions.
Date: Tue, 12 Apr 2011 10:48:42 -0400 (EDT)	[thread overview]
Message-ID: <201104121448.p3CEmgkC013667@krisdoz.my.domain> (raw)

Log Message:
-----------
Let mandoc-db also collect -man descriptions.

Modified Files:
--------------
    mdocml:
        mandoc-db.c

Revision Data
-------------
Index: mandoc-db.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc-db.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lmandoc-db.c -Lmandoc-db.c -u -p -r1.11 -r1.12
--- mandoc-db.c
+++ mandoc-db.c
@@ -731,7 +731,7 @@ static int
 pman_node(MAN_ARGS)
 {
 	const struct man_node *head, *body;
-	const char	*start;
+	const char	*start, *sv;
 	const char	 nil = '\0';
 	size_t		 sz;
 	uint32_t	 fl;
@@ -760,7 +760,8 @@ pman_node(MAN_ARGS)
 			fl = MANDOC_NAME;
 			memcpy(val->data, &fl, 4);
 
-			start = body->string;
+			assert(body->string);
+			start = sv = body->string;
 
 			/* 
 			 * Go through a special heuristic dance here.
@@ -771,7 +772,7 @@ pman_node(MAN_ARGS)
 			 * the name parts here.
 			 */
 
-			while (start) {
+			for ( ;; ) {
 				sz = strcspn(start, " ,");
 				if ('\0' == start[(int)sz])
 					break;
@@ -782,8 +783,10 @@ pman_node(MAN_ARGS)
 
 				dbt_put(db, dbn, key, val);
 
-				if (' ' == start[(int)sz])
+				if (' ' == start[(int)sz]) {
+					start += (int)sz + 1;
 					break;
+				}
 
 				assert(',' == start[(int)sz]);
 				start += (int)sz + 1;
@@ -791,7 +794,24 @@ pman_node(MAN_ARGS)
 					start++;
 			}
 
-			return(1);
+			if (sv == start) {
+				dbt_init(key, ksz);
+				dbt_append(key, ksz, start);
+				return(1);
+			}
+
+			while (' ' == *start)
+				start++;
+
+			if ('\\' == *start && '-' == *(start + 1))
+				start += 2;
+			else if ('-' == *start)
+				start++;
+
+			while (' ' == *start)
+				start++;
+
+			dbt_appendb(rval, rsz, start, strlen(start) + 1);
 		}
 	}
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2011-04-12 14:48 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=201104121448.p3CEmgkC013667@krisdoz.my.domain \
    --to=kristaps@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).