source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Simplify, no functional change: Delete the outmdoc, outman, and
Date: Mon, 19 Oct 2015 14:51:52 -0500 (EST)	[thread overview]
Message-ID: <2169573647074393365.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Simplify, no functional change:
Delete the outmdoc, outman, and outfree function pointers.

Modified Files:
--------------
    mdocml:
        main.c

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -Lmain.c -Lmain.c -u -p -r1.249 -r1.250
--- main.c
+++ main.c
@@ -59,10 +59,6 @@ enum	outmode {
 	OUTMODE_ONE
 };
 
-typedef	void		(*out_mdoc)(void *, const struct roff_man *);
-typedef	void		(*out_man)(void *, const struct roff_man *);
-typedef	void		(*out_free)(void *);
-
 enum	outt {
 	OUTT_ASCII = 0,	/* -Tascii */
 	OUTT_LOCALE,	/* -Tlocale */
@@ -80,9 +76,6 @@ struct	curparse {
 	enum mandoclevel  wlevel;	/* ignore messages below this */
 	int		  wstop;	/* stop after a file with a warning */
 	enum outt	  outtype;	/* which output to use */
-	out_mdoc	  outmdoc;	/* mdoc output ptr */
-	out_man		  outman;	/* man output ptr */
-	out_free	  outfree;	/* free output ptr */
 	void		 *outdata;	/* data for output */
 	struct manoutput *outopts;	/* output options */
 };
@@ -473,8 +466,22 @@ main(int argc, char *argv[])
 			mparse_reset(curp.mp);
 	}
 
-	if (curp.outfree)
-		(*curp.outfree)(curp.outdata);
+	switch (curp.outtype) {
+	case OUTT_HTML:
+		html_free(curp.outdata);
+		break;
+	case OUTT_UTF8:
+	case OUTT_LOCALE:
+	case OUTT_ASCII:
+		ascii_free(curp.outdata);
+		break;
+	case OUTT_PDF:
+	case OUTT_PS:
+		pspdf_free(curp.outdata);
+		break;
+	default:
+		break;
+	}
 	mparse_free(curp.mp);
 	mchars_free();
 
@@ -657,72 +664,81 @@ parse(struct curparse *curp, int fd, con
 
 	/* If unset, allocate output dev now (if applicable). */
 
-	if ( ! (curp->outman && curp->outmdoc)) {
+	if (curp->outdata == NULL) {
 		switch (curp->outtype) {
 		case OUTT_HTML:
 			curp->outdata = html_alloc(curp->outopts);
-			curp->outfree = html_free;
 			break;
 		case OUTT_UTF8:
 			curp->outdata = utf8_alloc(curp->outopts);
-			curp->outfree = ascii_free;
 			break;
 		case OUTT_LOCALE:
 			curp->outdata = locale_alloc(curp->outopts);
-			curp->outfree = ascii_free;
 			break;
 		case OUTT_ASCII:
 			curp->outdata = ascii_alloc(curp->outopts);
-			curp->outfree = ascii_free;
 			break;
 		case OUTT_PDF:
 			curp->outdata = pdf_alloc(curp->outopts);
-			curp->outfree = pspdf_free;
 			break;
 		case OUTT_PS:
 			curp->outdata = ps_alloc(curp->outopts);
-			curp->outfree = pspdf_free;
 			break;
 		default:
 			break;
 		}
+	}
 
+	mparse_result(curp->mp, &man, NULL);
+
+	/* Execute the out device, if it exists. */
+
+	if (man == NULL)
+		return;
+	if (man->macroset == MACROSET_MDOC) {
 		switch (curp->outtype) {
 		case OUTT_HTML:
-			curp->outman = html_man;
-			curp->outmdoc = html_mdoc;
+			html_mdoc(curp->outdata, man);
 			break;
 		case OUTT_TREE:
-			curp->outman = tree_man;
-			curp->outmdoc = tree_mdoc;
+			tree_mdoc(curp->outdata, man);
 			break;
 		case OUTT_MAN:
-			curp->outmdoc = man_mdoc;
-			curp->outman = man_man;
+			man_mdoc(curp->outdata, man);
 			break;
 		case OUTT_PDF:
 		case OUTT_ASCII:
 		case OUTT_UTF8:
 		case OUTT_LOCALE:
 		case OUTT_PS:
-			curp->outman = terminal_man;
-			curp->outmdoc = terminal_mdoc;
+			terminal_mdoc(curp->outdata, man);
+			break;
+		default:
+			break;
+		}
+	}
+	if (man->macroset == MACROSET_MAN) {
+		switch (curp->outtype) {
+		case OUTT_HTML:
+			html_man(curp->outdata, man);
+			break;
+		case OUTT_TREE:
+			tree_man(curp->outdata, man);
+			break;
+		case OUTT_MAN:
+			man_man(curp->outdata, man);
+			break;
+		case OUTT_PDF:
+		case OUTT_ASCII:
+		case OUTT_UTF8:
+		case OUTT_LOCALE:
+		case OUTT_PS:
+			terminal_man(curp->outdata, man);
 			break;
 		default:
 			break;
 		}
 	}
-
-	mparse_result(curp->mp, &man, NULL);
-
-	/* Execute the out device, if it exists. */
-
-	if (man == NULL)
-		return;
-	if (curp->outmdoc != NULL && man->macroset == MACROSET_MDOC)
-		(*curp->outmdoc)(curp->outdata, man);
-	if (curp->outman != NULL && man->macroset == MACROSET_MAN)
-		(*curp->outman)(curp->outdata, man);
 }
 
 static void
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-10-19 19:51 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=2169573647074393365.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).