source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Unify trickier node handling functions.
@ 2015-04-19 14:58 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-04-19 14:58 UTC (permalink / raw)
  To: source

Log Message:
-----------
Unify trickier node handling functions.
* man_elem_alloc() -> roff_elem_alloc()
* man_block_alloc() -> roff_block_alloc()
The functions mdoc_elem_alloc() and mdoc_block_alloc() remain for
now because they need to do mdoc(7)-specific argument processing.

Modified Files:
--------------
    mdocml:
        libman.h
        man.c
        man_macro.c
        mdoc.c
        mdoc_macro.c
        roff.c
        roff_int.h

Revision Data
-------------
Index: man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.c,v
retrieving revision 1.160
retrieving revision 1.161
diff -Lman.c -Lman.c -u -p -r1.160 -r1.161
--- man.c
+++ man.c
@@ -74,26 +74,6 @@ man_parseln(struct roff_man *man, int ln
 	    man_ptext(man, ln, buf, offs));
 }
 
-void
-man_elem_alloc(struct roff_man *man, int line, int pos, int tok)
-{
-	struct roff_node *p;
-
-	p = roff_node_alloc(man, line, pos, ROFFT_ELEM, tok);
-	roff_node_append(man, p);
-	man->next = ROFF_NEXT_CHILD;
-}
-
-void
-man_block_alloc(struct roff_man *man, int line, int pos, int tok)
-{
-	struct roff_node *p;
-
-	p = roff_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
-	roff_node_append(man, p);
-	man->next = ROFF_NEXT_CHILD;
-}
-
 static void
 man_descope(struct roff_man *man, int line, int offs)
 {
@@ -139,7 +119,7 @@ man_ptext(struct roff_man *man, int line
 		/* Allocate a blank entry. */
 		if (man->last->tok != MAN_SH &&
 		    man->last->tok != MAN_SS) {
-			man_elem_alloc(man, line, offs, MAN_sp);
+			roff_elem_alloc(man, line, offs, MAN_sp);
 			man->next = ROFF_NEXT_SIBLING;
 		}
 		return(1);
Index: mdoc_macro.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_macro.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.192 -r1.193
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -646,7 +646,7 @@ blk_exp_close(MACRO_PROT_ARGS)
 			 * Stray .Ec without previous .Eo:
 			 * Break the output line, keep the arguments.
 			 */
-			mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL);
+			roff_elem_alloc(mdoc, line, ppos, MDOC_br);
 			rew_elem(mdoc, MDOC_br);
 		}
 	} else if (endbody == NULL) {
@@ -990,7 +990,7 @@ blk_full(MACRO_PROT_ARGS)
 		if (tok == MDOC_It && (n == NULL || n->tok != MDOC_Bl)) {
 			mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse,
 			    line, ppos, "It %s", buf + *pos);
-			mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL);
+			roff_elem_alloc(mdoc, line, ppos, MDOC_br);
 			rew_elem(mdoc, MDOC_br);
 			return;
 		}
@@ -1223,7 +1223,7 @@ blk_part_exp(MACRO_PROT_ARGS)
 	 * case of `Eo'); and a body that may be empty.
 	 */
 
-	mdoc_block_alloc(mdoc, line, ppos, tok, NULL);
+	roff_block_alloc(mdoc, line, ppos, tok);
 	head = NULL;
 	for (;;) {
 		la = *pos;
Index: man_macro.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_macro.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -Lman_macro.c -Lman_macro.c -u -p -r1.107 -r1.108
--- man_macro.c
+++ man_macro.c
@@ -259,7 +259,7 @@ blk_exp(MACRO_PROT_ARGS)
 	int		 la;
 
 	rew_scope(man, tok);
-	man_block_alloc(man, line, ppos, tok);
+	roff_block_alloc(man, line, ppos, tok);
 	head = roff_head_alloc(man, line, ppos, tok);
 
 	la = *pos;
@@ -289,8 +289,7 @@ blk_imp(MACRO_PROT_ARGS)
 	struct roff_node *n;
 
 	rew_scope(man, tok);
-	man_block_alloc(man, line, ppos, tok);
-	n = man->last;
+	n = roff_block_alloc(man, line, ppos, tok);
 	if (n->tok == MAN_SH || n->tok == MAN_SS)
 		man->flags &= ~MAN_LITERAL;
 	n = roff_head_alloc(man, line, ppos, tok);
@@ -329,7 +328,7 @@ in_line_eoln(MACRO_PROT_ARGS)
 	char		*p;
 	struct roff_node *n;
 
-	man_elem_alloc(man, line, ppos, tok);
+	roff_elem_alloc(man, line, ppos, tok);
 	n = man->last;
 
 	for (;;) {
Index: libman.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libman.h,v
retrieving revision 1.75
retrieving revision 1.76
diff -Llibman.h -Llibman.h -u -p -r1.75 -r1.76
--- libman.h
+++ libman.h
@@ -36,8 +36,6 @@ extern	const struct man_macro *const man
 
 __BEGIN_DECLS
 
-void		  man_block_alloc(struct roff_man *, int, int, int);
-void		  man_elem_alloc(struct roff_man *, int, int, int);
 int		  man_hash_find(const char *);
 void		  man_macroend(struct roff_man *);
 void		  man_valid_post(struct roff_man *);
Index: mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -Lmdoc.c -Lmdoc.c -u -p -r1.249 -r1.250
--- mdoc.c
+++ mdoc.c
@@ -329,7 +329,7 @@ mdoc_ptext(struct roff_man *mdoc, int li
 		 * blank lines aren't allowed, but enough manuals assume this
 		 * behaviour that we want to work around it.
 		 */
-		mdoc_elem_alloc(mdoc, line, offs, MDOC_sp, NULL);
+		roff_elem_alloc(mdoc, line, offs, MDOC_sp);
 		mdoc->next = ROFF_NEXT_SIBLING;
 		mdoc_valid_post(mdoc);
 		return(1);
Index: roff.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.c,v
retrieving revision 1.267
retrieving revision 1.268
diff -Lroff.c -Lroff.c -u -p -r1.267 -r1.268
--- roff.c
+++ roff.c
@@ -1096,6 +1096,27 @@ roff_word_append(struct roff_man *man, c
 	man->next = ROFF_NEXT_SIBLING;
 }
 
+void
+roff_elem_alloc(struct roff_man *man, int line, int pos, int tok)
+{
+	struct roff_node	*n;
+
+	n = roff_node_alloc(man, line, pos, ROFFT_ELEM, tok);
+	roff_node_append(man, n);
+	man->next = ROFF_NEXT_CHILD;
+}
+
+struct roff_node *
+roff_block_alloc(struct roff_man *man, int line, int pos, int tok)
+{
+	struct roff_node	*n;
+
+	n = roff_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
+	roff_node_append(man, n);
+	man->next = ROFF_NEXT_CHILD;
+	return(n);
+}
+
 struct roff_node *
 roff_head_alloc(struct roff_man *man, int line, int pos, int tok)
 {
Index: roff_int.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff_int.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lroff_int.h -Lroff_int.h -u -p -r1.2 -r1.3
--- roff_int.h
+++ roff_int.h
@@ -23,6 +23,8 @@ struct roff_node *roff_node_alloc(struct
 void		  roff_node_append(struct roff_man *, struct roff_node *);
 void		  roff_word_alloc(struct roff_man *, int, int, const char *);
 void		  roff_word_append(struct roff_man *, const char *);
+void		  roff_elem_alloc(struct roff_man *, int, int, int);
+struct roff_node *roff_block_alloc(struct roff_man *, int, int, int);
 struct roff_node *roff_head_alloc(struct roff_man *, int, int, int);
 struct roff_node *roff_body_alloc(struct roff_man *, int, int, int);
 void		  roff_addeqn(struct roff_man *, const struct eqn *);
--
 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-19 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-19 14:58 mdocml: Unify trickier node handling functions 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).