source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Delete the wrapper functions mdoc_meta(), man_meta(),
@ 2015-04-18 17:53 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-04-18 17:53 UTC (permalink / raw)
  To: source

Log Message:
-----------
Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),
man_node() from the mandoc(3) semi-public interface and the internal
wrapper functions print_mdoc() and print_man() from the HTML formatters.
Minus 60 lines of code, no functional change.

Modified Files:
--------------
    mdocml:
        demandoc.c
        man.c
        man.h
        man_html.c
        man_term.c
        mandocdb.c
        mdoc.c
        mdoc.h
        mdoc_html.c
        mdoc_man.c
        mdoc_term.c
        tree.c

Revision Data
-------------
Index: mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.c,v
retrieving revision 1.245
retrieving revision 1.246
diff -Lmdoc.c -Lmdoc.c -u -p -r1.245 -r1.246
--- mdoc.c
+++ mdoc.c
@@ -93,20 +93,6 @@ static	int		  mdoc_ptext(struct roff_man
 static	int		  mdoc_pmacro(struct roff_man *, int, char *, int);
 
 
-const struct roff_node *
-mdoc_node(const struct roff_man *mdoc)
-{
-
-	return(mdoc->first);
-}
-
-const struct roff_meta *
-mdoc_meta(const struct roff_man *mdoc)
-{
-
-	return(&mdoc->meta);
-}
-
 void
 mdoc_endparse(struct roff_man *mdoc)
 {
Index: mdoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.h,v
retrieving revision 1.140
retrieving revision 1.141
diff -Lmdoc.h -Lmdoc.h -u -p -r1.140 -r1.141
--- mdoc.h
+++ mdoc.h
@@ -284,8 +284,6 @@ __BEGIN_DECLS
 
 struct	roff_man;
 
-const struct roff_node *mdoc_node(const struct roff_man *);
-const struct roff_meta *mdoc_meta(const struct roff_man *);
 void mdoc_deroff(char **, const struct roff_node *);
 
 __END_DECLS
Index: man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -Lman.c -Lman.c -u -p -r1.156 -r1.157
--- man.c
+++ man.c
@@ -62,20 +62,6 @@ static	int		 man_ptext(struct roff_man *
 static	int		 man_pmacro(struct roff_man *, int, char *, int);
 
 
-const struct roff_node *
-man_node(const struct roff_man *man)
-{
-
-	return(man->first);
-}
-
-const struct roff_meta *
-man_meta(const struct roff_man *man)
-{
-
-	return(&man->meta);
-}
-
 void
 man_endparse(struct roff_man *man)
 {
Index: man_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_html.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -Lman_html.c -Lman_html.c -u -p -r1.116 -r1.117
--- man_html.c
+++ man_html.c
@@ -54,7 +54,6 @@ struct	htmlman {
 
 static	void		  print_bvspace(struct html *,
 				const struct roff_node *);
-static	void		  print_man(MAN_ARGS);
 static	void		  print_man_head(MAN_ARGS);
 static	void		  print_man_nodelist(MAN_ARGS);
 static	void		  print_man_node(MAN_ARGS);
@@ -148,33 +147,28 @@ void
 html_man(void *arg, const struct roff_man *man)
 {
 	struct mhtml	 mh;
-
-	memset(&mh, 0, sizeof(struct mhtml));
-	print_man(man_meta(man), man_node(man), &mh, (struct html *)arg);
-	putchar('\n');
-}
-
-static void
-print_man(MAN_ARGS)
-{
-	struct tag	*t, *tt;
 	struct htmlpair	 tag;
+	struct html	*h;
+	struct tag	*t, *tt;
 
+	memset(&mh, 0, sizeof(mh));
 	PAIR_CLASS_INIT(&tag, "mandoc");
+	h = (struct html *)arg;
 
 	if ( ! (HTML_FRAGMENT & h->oflags)) {
 		print_gen_decls(h);
 		t = print_otag(h, TAG_HTML, 0, NULL);
 		tt = print_otag(h, TAG_HEAD, 0, NULL);
-		print_man_head(man, n, mh, h);
+		print_man_head(&man->meta, man->first, &mh, h);
 		print_tagq(h, tt);
 		print_otag(h, TAG_BODY, 0, NULL);
 		print_otag(h, TAG_DIV, 1, &tag);
 	} else
 		t = print_otag(h, TAG_DIV, 1, &tag);
 
-	print_man_nodelist(man, n, mh, h);
+	print_man_nodelist(&man->meta, man->first, &mh, h);
 	print_tagq(h, t);
+	putchar('\n');
 }
 
 static void
Index: tree.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tree.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -Ltree.c -Ltree.c -u -p -r1.65 -r1.66
--- tree.c
+++ tree.c
@@ -41,14 +41,14 @@ void
 tree_mdoc(void *arg, const struct roff_man *mdoc)
 {
 
-	print_mdoc(mdoc_node(mdoc)->child, 0);
+	print_mdoc(mdoc->first->child, 0);
 }
 
 void
 tree_man(void *arg, const struct roff_man *man)
 {
 
-	print_man(man_node(man)->child, 0);
+	print_man(man->first->child, 0);
 }
 
 static void
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -Lman_term.c -Lman_term.c -u -p -r1.180 -r1.181
--- man_term.c
+++ man_term.c
@@ -141,25 +141,20 @@ void
 terminal_man(void *arg, const struct roff_man *man)
 {
 	struct termp		*p;
-	const struct roff_meta	*meta;
 	struct roff_node	*n;
 	struct mtermp		 mt;
 
 	p = (struct termp *)arg;
-
 	p->overstep = 0;
 	p->rmargin = p->maxrmargin = p->defrmargin;
 	p->tabwidth = term_len(p, 5);
 
-	n = man_node(man)->child;
-	meta = man_meta(man);
-
 	memset(&mt, 0, sizeof(struct mtermp));
-
 	mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
 	mt.offset = term_len(p, p->defindent);
 	mt.pardist = 1;
 
+	n = man->first->child;
 	if (p->synopsisonly) {
 		while (n != NULL) {
 			if (n->tok == MAN_SH &&
@@ -167,7 +162,8 @@ terminal_man(void *arg, const struct rof
 			    !strcmp(n->child->child->string, "SYNOPSIS")) {
 				if (n->child->next->child != NULL)
 					print_man_nodelist(p, &mt,
-					    n->child->next->child, meta);
+					    n->child->next->child,
+					    &man->meta);
 				term_newln(p);
 				break;
 			}
@@ -176,10 +172,10 @@ terminal_man(void *arg, const struct rof
 	} else {
 		if (p->defindent == 0)
 			p->defindent = 7;
-		term_begin(p, print_man_head, print_man_foot, meta);
+		term_begin(p, print_man_head, print_man_foot, &man->meta);
 		p->flags |= TERMP_NOSPACE;
 		if (n != NULL)
-			print_man_nodelist(p, &mt, n, meta);
+			print_man_nodelist(p, &mt, n, &man->meta);
 		term_end(p);
 	}
 }
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.192 -r1.193
--- mandocdb.c
+++ mandocdb.c
@@ -1195,19 +1195,18 @@ mpages_merge(struct mparse *mp)
 			goto nextpage;
 		} else if (man != NULL && man->macroset == MACROSET_MDOC) {
 			mpage->form = FORM_SRC;
-			mpage->sec = mdoc_meta(man)->msec;
+			mpage->sec = man->meta.msec;
 			mpage->sec = mandoc_strdup(
 			    mpage->sec == NULL ? "" : mpage->sec);
-			mpage->arch = mdoc_meta(man)->arch;
+			mpage->arch = man->meta.arch;
 			mpage->arch = mandoc_strdup(
 			    mpage->arch == NULL ? "" : mpage->arch);
-			mpage->title =
-			    mandoc_strdup(mdoc_meta(man)->title);
+			mpage->title = mandoc_strdup(man->meta.title);
 		} else if (man != NULL && man->macroset == MACROSET_MAN) {
 			mpage->form = FORM_SRC;
-			mpage->sec = mandoc_strdup(man_meta(man)->msec);
+			mpage->sec = mandoc_strdup(man->meta.msec);
 			mpage->arch = mandoc_strdup(mlink->arch);
-			mpage->title = mandoc_strdup(man_meta(man)->title);
+			mpage->title = mandoc_strdup(man->meta.title);
 		} else {
 			mpage->form = FORM_CAT;
 			mpage->sec = mandoc_strdup(mlink->dsec);
@@ -1230,9 +1229,9 @@ mpages_merge(struct mparse *mp)
 
 		assert(mpage->desc == NULL);
 		if (man != NULL && man->macroset == MACROSET_MDOC)
-			parse_mdoc(mpage, mdoc_meta(man), mdoc_node(man));
+			parse_mdoc(mpage, &man->meta, man->first);
 		else if (man != NULL)
-			parse_man(mpage, man_meta(man), man_node(man));
+			parse_man(mpage, &man->meta, man->first);
 		else
 			parse_cat(mpage, fd);
 		if (mpage->desc == NULL)
Index: demandoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/demandoc.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -Ldemandoc.c -Ldemandoc.c -u -p -r1.19 -r1.20
--- demandoc.c
+++ demandoc.c
@@ -121,9 +121,9 @@ pmandoc(struct mparse *mp, int fd, const
 	if (man == NULL)
 		return;
 	if (man->macroset == MACROSET_MDOC)
-		pmdoc(mdoc_node(man), &line, &col, list);
+		pmdoc(man->first->child, &line, &col, list);
 	else
-		pman(man_node(man), &line, &col, list);
+		pman(man->first->child, &line, &col, list);
 
 	if ( ! list)
 		putchar('\n');
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.318
retrieving revision 1.319
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.318 -r1.319
--- mdoc_term.c
+++ mdoc_term.c
@@ -253,25 +253,22 @@ static	const struct termact termacts[MDO
 void
 terminal_mdoc(void *arg, const struct roff_man *mdoc)
 {
-	const struct roff_meta	*meta;
 	struct roff_node	*n;
 	struct termp		*p;
 
 	p = (struct termp *)arg;
-
 	p->overstep = 0;
 	p->rmargin = p->maxrmargin = p->defrmargin;
 	p->tabwidth = term_len(p, 5);
 
-	n = mdoc_node(mdoc)->child;
-	meta = mdoc_meta(mdoc);
-
+	n = mdoc->first->child;
 	if (p->synopsisonly) {
 		while (n != NULL) {
 			if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) {
 				if (n->child->next->child != NULL)
 					print_mdoc_nodelist(p, NULL,
-					    meta, n->child->next->child);
+					    &mdoc->meta,
+					    n->child->next->child);
 				term_newln(p);
 				break;
 			}
@@ -280,11 +277,12 @@ terminal_mdoc(void *arg, const struct ro
 	} else {
 		if (p->defindent == 0)
 			p->defindent = 5;
-		term_begin(p, print_mdoc_head, print_mdoc_foot, meta);
+		term_begin(p, print_mdoc_head, print_mdoc_foot,
+		    &mdoc->meta);
 		if (n != NULL) {
 			if (n->tok != MDOC_Sh)
 				term_vspace(p);
-			print_mdoc_nodelist(p, NULL, meta, n);
+			print_mdoc_nodelist(p, NULL, &mdoc->meta, n);
 		}
 		term_end(p);
 	}
Index: man.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -Lman.h -Lman.h -u -p -r1.73 -r1.74
--- man.h
+++ man.h
@@ -63,8 +63,6 @@ __BEGIN_DECLS
 
 struct	roff_man;
 
-const struct roff_node *man_node(const struct roff_man *);
-const struct roff_meta *man_meta(const struct roff_man *);
 const struct mparse   *man_mparse(const struct roff_man *);
 void man_deroff(char **, const struct roff_node *);
 
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v
retrieving revision 1.231
retrieving revision 1.232
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.231 -r1.232
--- mdoc_html.c
+++ mdoc_html.c
@@ -48,7 +48,6 @@ struct	htmlmdoc {
 	void		(*post)(MDOC_ARGS);
 };
 
-static	void		  print_mdoc(MDOC_ARGS);
 static	void		  print_mdoc_head(MDOC_ARGS);
 static	void		  print_mdoc_node(MDOC_ARGS);
 static	void		  print_mdoc_nodelist(MDOC_ARGS);
@@ -264,15 +263,6 @@ static	const char * const lists[LIST_MAX
 };
 
 
-void
-html_mdoc(void *arg, const struct roff_man *mdoc)
-{
-
-	print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc)->child,
-	    (struct html *)arg);
-	putchar('\n');
-}
-
 /*
  * Calculate the scaling unit passed in a `-width' argument.  This uses
  * either a native scaling unit (e.g., 1i, 2m) or the string length of
@@ -331,29 +321,32 @@ synopsis_pre(struct html *h, const struc
 	}
 }
 
-static void
-print_mdoc(MDOC_ARGS)
+void
+html_mdoc(void *arg, const struct roff_man *mdoc)
 {
-	struct tag	*t, *tt;
 	struct htmlpair	 tag;
+	struct html	*h;
+	struct tag	*t, *tt;
 
 	PAIR_CLASS_INIT(&tag, "mandoc");
+	h = (struct html *)arg;
 
 	if ( ! (HTML_FRAGMENT & h->oflags)) {
 		print_gen_decls(h);
 		t = print_otag(h, TAG_HTML, 0, NULL);
 		tt = print_otag(h, TAG_HEAD, 0, NULL);
-		print_mdoc_head(meta, n, h);
+		print_mdoc_head(&mdoc->meta, mdoc->first->child, h);
 		print_tagq(h, tt);
 		print_otag(h, TAG_BODY, 0, NULL);
 		print_otag(h, TAG_DIV, 1, &tag);
 	} else
 		t = print_otag(h, TAG_DIV, 1, &tag);
 
-	mdoc_root_pre(meta, n, h);
-	print_mdoc_nodelist(meta, n, h);
-	mdoc_root_post(meta, n, h);
+	mdoc_root_pre(&mdoc->meta, mdoc->first->child, h);
+	print_mdoc_nodelist(&mdoc->meta, mdoc->first->child, h);
+	mdoc_root_post(&mdoc->meta, mdoc->first->child, h);
 	print_tagq(h, t);
+	putchar('\n');
 }
 
 static void
Index: mdoc_man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_man.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.92 -r1.93
--- mdoc_man.c
+++ mdoc_man.c
@@ -547,16 +547,12 @@ man_man(void *arg, const struct roff_man
 void
 man_mdoc(void *arg, const struct roff_man *mdoc)
 {
-	const struct roff_meta *meta;
 	struct roff_node *n;
 
-	meta = mdoc_meta(mdoc);
-	n = mdoc_node(mdoc)->child;
-
 	printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
-	    meta->title,
-	    (meta->msec == NULL ? "" : meta->msec),
-	    meta->date, meta->os, meta->vol);
+	    mdoc->meta.title,
+	    (mdoc->meta.msec == NULL ? "" : mdoc->meta.msec),
+	    mdoc->meta.date, mdoc->meta.os, mdoc->meta.vol);
 
 	/* Disable hyphenation and if nroff, disable justification. */
 	printf(".nh\n.if n .ad l");
@@ -567,10 +563,8 @@ man_mdoc(void *arg, const struct roff_ma
 		fontqueue.head = fontqueue.tail = mandoc_malloc(8);
 		*fontqueue.tail = 'R';
 	}
-	while (n != NULL) {
-		print_node(meta, n);
-		n = n->next;
-	}
+	for (n = mdoc->first->child; n != NULL; n = n->next)
+		print_node(&mdoc->meta, n);
 	putchar('\n');
 }
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-18 17:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-18 17:53 mdocml: Delete the wrapper functions mdoc_meta(), man_meta(), schwarze

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).