source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: simplify the eqn_box_makebinary() function by removing the
Date: Fri, 7 Jul 2017 12:16:47 -0500 (EST)	[thread overview]
Message-ID: <84808224689288185.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
simplify the eqn_box_makebinary() function by removing the trivial pos
parameter; also minus two lines of code; no functional change

Modified Files:
--------------
    mandoc:
        eqn.c

Revision Data
-------------
Index: eqn.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/eqn.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -Leqn.c -Leqn.c -u -p -r1.74 -r1.75
--- eqn.c
+++ eqn.c
@@ -286,7 +286,7 @@ enum	parse_mode {
 static	struct eqn_box	*eqn_box_alloc(struct eqn_node *, struct eqn_box *);
 static	void		 eqn_box_free(struct eqn_box *);
 static	struct eqn_box	*eqn_box_makebinary(struct eqn_node *,
-				enum eqn_post, struct eqn_box *);
+				struct eqn_box *);
 static	void		 eqn_def(struct eqn_node *);
 static	struct eqn_def	*eqn_def_find(struct eqn_node *);
 static	void		 eqn_delim(struct eqn_node *);
@@ -541,8 +541,7 @@ eqn_box_alloc(struct eqn_node *ep, struc
  * The new EQN_SUBEXPR will have a two-child limit.
  */
 static struct eqn_box *
-eqn_box_makebinary(struct eqn_node *ep,
-	enum eqn_post pos, struct eqn_box *parent)
+eqn_box_makebinary(struct eqn_node *ep, struct eqn_box *parent)
 {
 	struct eqn_box	*b, *newb;
 
@@ -554,7 +553,6 @@ eqn_box_makebinary(struct eqn_node *ep,
 	parent->last = b->prev;
 	b->prev = NULL;
 	newb = eqn_box_alloc(ep, parent);
-	newb->pos = pos;
 	newb->type = EQN_SUBEXPR;
 	newb->expectargs = 2;
 	newb->args = 1;
@@ -669,7 +667,6 @@ eqn_parse(struct eqn_node *ep, struct eq
 	const char	*cp, *cpn;
 	char		*p;
 	enum eqn_tok	 tok;
-	enum eqn_post	 pos;
 	enum { CCL_LET, CCL_DIG, CCL_PUN } ccl, ccln;
 	int		 size;
 
@@ -728,7 +725,7 @@ next_tok:
 			cur->type = EQN_TEXT;
 			cur->text = mandoc_strdup("");
 		}
-		parent = eqn_box_makebinary(ep, EQNPOS_NONE, parent);
+		parent = eqn_box_makebinary(ep, parent);
 		parent->type = EQN_LIST;
 		parent->expectargs = 1;
 		parent->font = EQNFONT_ROMAN;
@@ -865,23 +862,23 @@ next_tok:
 			parent->pos = EQNPOS_FROMTO;
 			break;
 		}
+		parent = eqn_box_makebinary(ep, parent);
 		switch (tok) {
 		case EQN_TOK_FROM:
-			pos = EQNPOS_FROM;
+			parent->pos = EQNPOS_FROM;
 			break;
 		case EQN_TOK_TO:
-			pos = EQNPOS_TO;
+			parent->pos = EQNPOS_TO;
 			break;
 		case EQN_TOK_SUP:
-			pos = EQNPOS_SUP;
+			parent->pos = EQNPOS_SUP;
 			break;
 		case EQN_TOK_SUB:
-			pos = EQNPOS_SUB;
+			parent->pos = EQNPOS_SUB;
 			break;
 		default:
 			abort();
 		}
-		parent = eqn_box_makebinary(ep, pos, parent);
 		break;
 	case EQN_TOK_SQRT:
 		while (parent->args == parent->expectargs)
@@ -913,7 +910,8 @@ next_tok:
 			parent = parent->parent;
 		while (EQN_SUBEXPR == parent->type)
 			parent = parent->parent;
-		parent = eqn_box_makebinary(ep, EQNPOS_OVER, parent);
+		parent = eqn_box_makebinary(ep, parent);
+		parent->pos = EQNPOS_OVER;
 		break;
 	case EQN_TOK_RIGHT:
 	case EQN_TOK_BRACE_CLOSE:
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

                 reply	other threads:[~2017-07-07 17:16 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=84808224689288185.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.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).