From b6f6b7ee15f64b3ab129ecfa179af940f18a258d Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 19 Apr 2015 14:57:38 +0000 Subject: 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. --- libman.h | 4 +--- man.c | 24 ++---------------------- man_macro.c | 9 ++++----- mdoc.c | 4 ++-- mdoc_macro.c | 8 ++++---- roff.c | 23 ++++++++++++++++++++++- roff_int.h | 4 +++- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/libman.h b/libman.h index 30b0a326..6dd453ed 100644 --- a/libman.h +++ b/libman.h @@ -1,4 +1,4 @@ -/* $Id: libman.h,v 1.75 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: libman.h,v 1.76 2015/04/19 14:57:38 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze @@ -36,8 +36,6 @@ extern const struct man_macro *const man_macros; __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 *); diff --git a/man.c b/man.c index 6c0b1787..e65e8c8c 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.160 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: man.c,v 1.161 2015/04/19 14:57:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015 Ingo Schwarze @@ -74,26 +74,6 @@ man_parseln(struct roff_man *man, int ln, char *buf, int offs) 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, char *buf, int offs) /* 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); diff --git a/man_macro.c b/man_macro.c index d82811d4..96d99f67 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.107 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: man_macro.c,v 1.108 2015/04/19 14:57:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze @@ -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 (;;) { diff --git a/mdoc.c b/mdoc.c index a397fafc..dc74a104 100644 --- a/mdoc.c +++ b/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.249 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.250 2015/04/19 14:57:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -329,7 +329,7 @@ mdoc_ptext(struct roff_man *mdoc, int line, char *buf, int offs) * 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); diff --git a/mdoc_macro.c b/mdoc_macro.c index 2f4bc6e1..8322cca5 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.192 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.193 2015/04/19 14:57:38 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -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; diff --git a/roff.c b/roff.c index 6995bbd3..6b50b518 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.267 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: roff.c,v 1.268 2015/04/19 14:57:38 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -1096,6 +1096,27 @@ roff_word_append(struct roff_man *man, const char *word) 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) { diff --git a/roff_int.h b/roff_int.h index 41cb4d93..8a9591e4 100644 --- a/roff_int.h +++ b/roff_int.h @@ -1,4 +1,4 @@ -/* $Id: roff_int.h,v 1.2 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: roff_int.h,v 1.3 2015/04/19 14:57:38 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015 Ingo Schwarze @@ -23,6 +23,8 @@ struct roff_node *roff_node_alloc(struct roff_man *, int, int, 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 *); -- cgit v1.2.3-56-ge451