source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: No need to populate the TYPE_arch and TYPE_sec bits, the
Date: Fri, 29 Jul 2016 10:24:28 -0500 (EST)	[thread overview]
Message-ID: <17764883023921395554.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
No need to populate the TYPE_arch and TYPE_sec bits, the information
is provided directly to dba_page_add() in dbadd_mlink()
and to dba_page_new() in dbadd().
    
No need for a dedicated loop for NAME_FILE.
It's done in dbadd_mlink() anyway.
    
In this context, also record section numbers taken from filenames
and from .Dt and .TH macros, architectures taken from .Dt macros,
and fix the filtering of duplicate filename entries.

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

Revision Data
-------------
Index: dba.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/dba.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -Ldba.c -Ldba.c -u -p -r1.1 -r1.2
--- dba.c
+++ dba.c
@@ -175,9 +175,12 @@ dba_page_add(struct dba_array *page, int
 	}
 	if (*str == '\0')
 		return;
-	dba_array_FOREACH(entries, entry)
+	dba_array_FOREACH(entries, entry) {
+		if (ie == DBP_FILE && *entry < ' ')
+			entry++;
 		if (strcmp(entry, str) == 0)
 			return;
+	}
 	dba_array_add(entries, (void *)str);
 }
 
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.222
retrieving revision 1.223
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.222 -r1.223
--- mandocdb.c
+++ mandocdb.c
@@ -1084,7 +1084,6 @@ mlink_check(struct mpage *mpage, struct 
 static void
 mpages_merge(struct dba *dba, struct mparse *mp)
 {
-	char			 any[] = "any";
 	struct mpage		*mpage, *mpage_dest;
 	struct mlink		*mlink, *mlink_dest;
 	struct roff_man		*man;
@@ -1186,19 +1185,6 @@ mpages_merge(struct dba *dba, struct mpa
 			mpage->arch = mandoc_strdup(mlink->arch);
 			mpage->title = mandoc_strdup(mlink->name);
 		}
-		putkey(mpage, mpage->sec, TYPE_sec);
-		if (*mpage->arch != '\0')
-			putkey(mpage, mpage->arch, TYPE_arch);
-
-		for ( ; mlink != NULL; mlink = mlink->next) {
-			if ('\0' != *mlink->dsec)
-				putkey(mpage, mlink->dsec, TYPE_sec);
-			if ('\0' != *mlink->fsec)
-				putkey(mpage, mlink->fsec, TYPE_sec);
-			putkey(mpage, '\0' == *mlink->arch ?
-			    any : mlink->arch, TYPE_arch);
-			putkey(mpage, mlink->name, NAME_FILE);
-		}
 
 		assert(mpage->desc == NULL);
 		if (man != NULL && man->macroset == MACROSET_MDOC)
@@ -1347,13 +1333,6 @@ parse_cat(struct mpage *mpage, int fd)
 static void
 putkey(const struct mpage *mpage, char *value, uint64_t type)
 {
-	char	 *cp;
-
-	assert(NULL != value);
-	if (TYPE_arch == type)
-		for (cp = value; *cp; cp++)
-			if (isupper((unsigned char)*cp))
-				*cp = _tolower((unsigned char)*cp);
 	putkeys(mpage, value, strlen(value), type);
 }
 
@@ -1954,6 +1933,7 @@ dbadd_mlink(const struct mlink *mlink)
 {
 	dba_page_alias(mlink->mpage->dba, mlink->name, NAME_FILE);
 	dba_page_add(mlink->mpage->dba, DBP_SECT, mlink->dsec);
+	dba_page_add(mlink->mpage->dba, DBP_SECT, mlink->fsec);
 	dba_page_add(mlink->mpage->dba, DBP_ARCH, mlink->arch);
 	dba_page_add(mlink->mpage->dba, DBP_FILE, mlink->file);
 }
@@ -2013,13 +1993,16 @@ dbadd(struct dba *dba, struct mpage *mpa
 	cp = mpage->desc;
 	i = strlen(cp);
 	mustfree = render_string(&cp, &i);
-	mpage->dba = dba_page_new(dba->pages, mlink->name,
-	    mlink->dsec, mlink->arch, cp, mlink->file, mpage->form);
+	mpage->dba = dba_page_new(dba->pages, mlink->name, mpage->sec,
+	    *mpage->arch == '\0' ? mlink->arch : mpage->arch,
+	    cp, mlink->file, mpage->form);
 	if (mustfree)
 		free(cp);
 
-	while ((mlink = mlink->next) != NULL)
+	while (mlink != NULL) {
 		dbadd_mlink(mlink);
+		mlink = mlink->next;
+	}
 
 	for (key = ohash_first(&names, &slot); NULL != key;
 	     key = ohash_next(&names, &slot)) {
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2016-07-29 15:24 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=17764883023921395554.enqueue@fantadrom.bsd.lv \
    --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).