[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mandoc-source
Subject:    mdocml: If parsing a page reveals that it is neither mdoc(7) nor man(7),
From:       schwarze () mdocml ! bsd ! lv
Date:       2017-01-27 1:09:45
Message-ID: 14409124100370159404.enqueue () fantadrom ! bsd ! lv
[Download RAW message or body]

Log Message:
-----------
If parsing a page reveals that it is neither mdoc(7) nor man(7),
fall back to treating it as preformatted rather than treating
it as man(7) anyway.

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

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.239
retrieving revision 1.240
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.239 -r1.240
--- mandocdb.c
+++ mandocdb.c
@@ -1153,6 +1153,7 @@ mpages_merge(struct dba *dba, struct mpa
 		if (mlink->dform != FORM_CAT || mlink->fform != FORM_CAT) {
 			mparse_readfd(mp, fd, mlink->file);
 			close(fd);
+			fd = -1;
 			mparse_result(mp, &man, &sodest);
 		}
 
@@ -1209,24 +1210,27 @@ mpages_merge(struct dba *dba, struct mpa
 			mpage->title = mandoc_strdup(man->meta.title);
 		} else if (man != NULL && man->macroset == MACROSET_MAN) {
 			man_validate(man);
-			mpage->form = FORM_SRC;
-			mpage->sec = mandoc_strdup(man->meta.msec);
-			mpage->arch = mandoc_strdup(mlink->arch);
-			mpage->title = mandoc_strdup(man->meta.title);
-		} else {
+			if (*man->meta.msec != '\0' ||
+			    *man->meta.msec != '\0') {
+				mpage->form = FORM_SRC;
+				mpage->sec = mandoc_strdup(man->meta.msec);
+				mpage->arch = mandoc_strdup(mlink->arch);
+				mpage->title = mandoc_strdup(man->meta.title);
+			} else
+				man = NULL;
+		}
+
+		assert(mpage->desc == NULL);
+		if (man == NULL) {
 			mpage->form = FORM_CAT;
 			mpage->sec = mandoc_strdup(mlink->dsec);
 			mpage->arch = mandoc_strdup(mlink->arch);
 			mpage->title = mandoc_strdup(mlink->name);
-		}
-
-		assert(mpage->desc == NULL);
-		if (man != NULL && man->macroset == MACROSET_MDOC)
+			parse_cat(mpage, fd);
+		} else if (man->macroset == MACROSET_MDOC)
 			parse_mdoc(mpage, &man->meta, man->first);
-		else if (man != NULL)
-			parse_man(mpage, &man->meta, man->first);
 		else
-			parse_cat(mpage, fd);
+			parse_man(mpage, &man->meta, man->first);
 		if (mpage->desc == NULL)
 			mpage->desc = mandoc_strdup(mpage->mlinks->name);
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic