source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Report arguments to .EQ as an error, and simplify the code: *
@ 2014-10-25 14:35 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-10-25 14:35 UTC (permalink / raw)
  To: source

Log Message:
-----------
Report arguments to .EQ as an error, and simplify the code:
* drop trivial wrapper function roff_openeqn()
* drop unused first arg of function eqn_alloc()
* drop usused member "name" of struct eqn_node
While here, sync to OpenBSD by killing some trailing blanks.

Modified Files:
--------------
    mdocml:
        eqn.c
        libroff.h
        mandoc.1
        roff.c

Revision Data
-------------
Index: eqn.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/eqn.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -Leqn.c -Leqn.c -u -p -r1.54 -r1.55
--- eqn.c
+++ eqn.c
@@ -36,8 +36,6 @@
 #define	EQN_NEST_MAX	 128 /* maximum nesting of defines */
 #define	STRNEQ(p1, sz1, p2, sz2) \
 	((sz1) == (sz2) && 0 == strncmp((p1), (p2), (sz1)))
-#define	EQNSTREQ(x, p, sz) \
-	STRNEQ((x)->name, (x)->sz, (p), (sz))
 
 enum	eqn_tok {
 	EQN_TOK_DYAD = 0,
@@ -315,24 +313,12 @@ eqn_read(struct eqn_node **epp, int ln,
 }
 
 struct eqn_node *
-eqn_alloc(const char *name, int pos, int line, struct mparse *parse)
+eqn_alloc(int pos, int line, struct mparse *parse)
 {
 	struct eqn_node	*p;
-	size_t		 sz;
-	const char	*end;
 
 	p = mandoc_calloc(1, sizeof(struct eqn_node));
 
-	if (name && '\0' != *name) {
-		sz = strlen(name);
-		assert(sz);
-		do {
-			sz--;
-			end = name + (int)sz;
-		} while (' ' == *end || '\t' == *end);
-		p->eqn.name = mandoc_strndup(name, sz + 1);
-	}
-
 	p->parse = parse;
 	p->eqn.ln = line;
 	p->eqn.pos = pos;
@@ -1108,7 +1094,6 @@ eqn_free(struct eqn_node *p)
 		free(p->defs[i].val);
 	}
 
-	free(p->eqn.name);
 	free(p->data);
 	free(p->defs);
 	free(p);
Index: mandoc.1
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.1,v
retrieving revision 1.119
retrieving revision 1.120
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.119 -r1.120
--- mandoc.1
+++ mandoc.1
@@ -1465,6 +1465,8 @@ or
 .Ic \&PP
 macro, an
 .Xr eqn 7
+.Ic \&EQ
+or
 .Ic \&EN
 macro, or a
 .Xr roff 7
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.234
retrieving revision 1.235
diff -Lroff.c -Lroff.c -u -p -r1.234 -r1.235
--- roff.c
+++ roff.c
@@ -207,8 +207,6 @@ static	const char	*roff_getstrn(const st
 static	enum rofferr	 roff_it(ROFF_ARGS);
 static	enum rofferr	 roff_line_ignore(ROFF_ARGS);
 static	enum rofferr	 roff_nr(ROFF_ARGS);
-static	void		 roff_openeqn(struct roff *, const char *,
-				int, int, const char *);
 static	enum rofft	 roff_parse(struct roff *, char *, int *,
 				int, int);
 static	enum rofferr	 roff_parsetext(char **, size_t *, int, int *);
@@ -1469,7 +1467,7 @@ roff_getop(const char *v, int *pos, char
  * or a single signed integer number.
  */
 static int
-roff_evalpar(struct roff *r, int ln, 
+roff_evalpar(struct roff *r, int ln,
 	const char *v, int *pos, int *res)
 {
 
@@ -1499,7 +1497,7 @@ roff_evalpar(struct roff *r, int ln, 
  * Proceed left to right, there is no concept of precedence.
  */
 static int
-roff_evalnum(struct roff *r, int ln, const char *v, 
+roff_evalnum(struct roff *r, int ln, const char *v,
 	int *pos, int *res, int skipwhite)
 {
 	int		 mypos, operand2;
@@ -1551,7 +1549,7 @@ roff_evalnum(struct roff *r, int ln, con
 			break;
 		case '/':
 			if (0 == operand2) {
-				mandoc_msg(MANDOCERR_DIVZERO, 
+				mandoc_msg(MANDOCERR_DIVZERO,
 					r->parse, ln, *pos, v);
 				*res = 0;
 				break;
@@ -1928,15 +1926,13 @@ roff_eqndelim(struct roff *r, char **buf
 	return(ROFF_REPARSE);
 }
 
-static void
-roff_openeqn(struct roff *r, const char *name, int line,
-		int offs, const char *buf)
+static enum rofferr
+roff_EQ(ROFF_ARGS)
 {
 	struct eqn_node *e;
-	int		 poff;
 
 	assert(NULL == r->eqn);
-	e = eqn_alloc(name, offs, line, r->parse);
+	e = eqn_alloc(ppos, ln, r->parse);
 
 	if (r->last_eqn) {
 		r->last_eqn->next = e;
@@ -1948,17 +1944,10 @@ roff_openeqn(struct roff *r, const char 
 
 	r->eqn = r->last_eqn = e;
 
-	if (buf) {
-		poff = 0;
-		eqn_read(&r->eqn, line, buf, offs, &poff);
-	}
-}
-
-static enum rofferr
-roff_EQ(ROFF_ARGS)
-{
+	if ((*bufp)[pos])
+		mandoc_vmsg(MANDOCERR_ARG_SKIP, r->parse, ln, pos,
+		    ".EQ %s", *bufp + pos);
 
-	roff_openeqn(r, *bufp + pos, ln, ppos, NULL);
 	return(ROFF_IGN);
 }
 
Index: libroff.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libroff.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -Llibroff.h -Llibroff.h -u -p -r1.30 -r1.31
--- libroff.h
+++ libroff.h
@@ -77,7 +77,7 @@ int		 tbl_data(struct tbl_node *, int, c
 int		 tbl_cdata(struct tbl_node *, int, const char *);
 const struct tbl_span	*tbl_span(struct tbl_node *);
 void		 tbl_end(struct tbl_node **);
-struct eqn_node	*eqn_alloc(const char *, int, int, struct mparse *);
+struct eqn_node	*eqn_alloc(int, int, struct mparse *);
 enum rofferr	 eqn_end(struct eqn_node **);
 void		 eqn_free(struct eqn_node *);
 enum rofferr	 eqn_read(struct eqn_node **, int,
--
 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:[~2014-10-25 14:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-25 14:35 mdocml: Report arguments to .EQ as an error, and simplify the code: * 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).