source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Simplify by making the eqn and tbl steering functions void; no
Date: Fri, 28 Nov 2014 01:27:36 -0500 (EST)	[thread overview]
Message-ID: <17199357465215155493.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Simplify by making the eqn and tbl steering functions void;
no functional change, minus 15 lines of code.

Modified Files:
--------------
    mdocml:
        libmandoc.h
        man.c
        mdoc.c
        read.c

Revision Data
-------------
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -Lread.c -Lread.c -u -p -r1.99 -r1.100
--- read.c
+++ read.c
@@ -317,7 +317,7 @@ mparse_buf_r(struct mparse *curp, struct
 	struct buf	 ln;
 	size_t		 pos; /* byte number in the ln buffer */
 	enum rofferr	 rr;
-	int		 of, rc;
+	int		 of;
 	int		 lnn; /* line number in the real file */
 	unsigned char	 c;
 
@@ -570,34 +570,21 @@ rerun:
 		 * Do the same for ROFF_EQN.
 		 */
 
-		rc = -1;
-
-		if (ROFF_TBL == rr)
-			while (NULL != (span = roff_span(curp->roff))) {
-				rc = curp->man ?
-				    man_addspan(curp->man, span) :
-				    mdoc_addspan(curp->mdoc, span);
-				if (0 == rc)
-					break;
-			}
-		else if (ROFF_EQN == rr)
-			rc = curp->mdoc ?
-			    mdoc_addeqn(curp->mdoc,
-				roff_eqn(curp->roff)) :
-			    man_addeqn(curp->man,
-				roff_eqn(curp->roff));
-		else if (curp->man || curp->mdoc)
-			rc = curp->man ?
-			    man_parseln(curp->man,
-				curp->line, ln.buf, of) :
-			    mdoc_parseln(curp->mdoc,
-				curp->line, ln.buf, of);
-
-		if (0 == rc) {
-			assert(MANDOCLEVEL_FATAL <= curp->file_status);
-			break;
-		} else if (2 == rc)
-			break;
+		if (rr == ROFF_TBL) {
+			while ((span = roff_span(curp->roff)) != NULL)
+				if (curp->man == NULL)
+					mdoc_addspan(curp->mdoc, span);
+				else
+					man_addspan(curp->man, span);
+		} else if (rr == ROFF_EQN) {
+			if (curp->man == NULL)
+				mdoc_addeqn(curp->mdoc, roff_eqn(curp->roff));
+			else
+				man_addeqn(curp->man, roff_eqn(curp->roff));
+		} else if ((curp->man == NULL ?
+		    mdoc_parseln(curp->mdoc, curp->line, ln.buf, of) :
+		    man_parseln(curp->man, curp->line, ln.buf, of)) == 2)
+				break;
 
 		/* Temporary buffers typically are not full. */
 
Index: libmandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libmandoc.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -Llibmandoc.h -Llibmandoc.h -u -p -r1.48 -r1.49
--- libmandoc.h
+++ libmandoc.h
@@ -60,16 +60,16 @@ struct	mdoc	*mdoc_alloc(struct roff *, s
 void		 mdoc_reset(struct mdoc *);
 int		 mdoc_parseln(struct mdoc *, int, char *, int);
 int		 mdoc_endparse(struct mdoc *);
-int		 mdoc_addspan(struct mdoc *, const struct tbl_span *);
-int		 mdoc_addeqn(struct mdoc *, const struct eqn *);
+void		 mdoc_addspan(struct mdoc *, const struct tbl_span *);
+void		 mdoc_addeqn(struct mdoc *, const struct eqn *);
 
 void		 man_free(struct man *);
 struct	man	*man_alloc(struct roff *, struct mparse *, int);
 void		 man_reset(struct man *);
 int		 man_parseln(struct man *, int, char *, int);
 int		 man_endparse(struct man *);
-int		 man_addspan(struct man *, const struct tbl_span *);
-int		 man_addeqn(struct man *, const struct eqn *);
+void		 man_addspan(struct man *, const struct tbl_span *);
+void		 man_addeqn(struct man *, const struct eqn *);
 
 int		 preconv_cue(const struct buf *, size_t);
 int		 preconv_encode(struct buf *, size_t *,
Index: man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -Lman.c -Lman.c -u -p -r1.144 -r1.145
--- man.c
+++ man.c
@@ -317,7 +317,7 @@ man_node_delete(struct man *man, struct 
 	man_node_free(p);
 }
 
-int
+void
 man_addeqn(struct man *man, const struct eqn *ep)
 {
 	struct man_node	*n;
@@ -329,10 +329,9 @@ man_addeqn(struct man *man, const struct
 	man_node_append(man, n);
 	man->next = MAN_NEXT_SIBLING;
 	man_descope(man, ep->ln, ep->pos);
-	return(1);
 }
 
-int
+void
 man_addspan(struct man *man, const struct tbl_span *sp)
 {
 	struct man_node	*n;
@@ -342,7 +341,6 @@ man_addspan(struct man *man, const struc
 	man_node_append(man, n);
 	man->next = MAN_NEXT_SIBLING;
 	man_descope(man, sp->line, 0);
-	return(1);
 }
 
 static void
Index: mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.c,v
retrieving revision 1.232
retrieving revision 1.233
diff -Lmdoc.c -Lmdoc.c -u -p -r1.232 -r1.233
--- mdoc.c
+++ mdoc.c
@@ -198,7 +198,7 @@ mdoc_endparse(struct mdoc *mdoc)
 	return(1);
 }
 
-int
+void
 mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep)
 {
 	struct mdoc_node *n;
@@ -209,10 +209,9 @@ mdoc_addeqn(struct mdoc *mdoc, const str
 		n->flags |= MDOC_LINE;
 	node_append(mdoc, n);
 	mdoc->next = MDOC_NEXT_SIBLING;
-	return(1);
 }
 
-int
+void
 mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp)
 {
 	struct mdoc_node *n;
@@ -221,7 +220,6 @@ mdoc_addspan(struct mdoc *mdoc, const st
 	n->span = sp;
 	node_append(mdoc, n);
 	mdoc->next = MDOC_NEXT_SIBLING;
-	return(1);
 }
 
 /*
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-11-28  6:27 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=17199357465215155493.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).