summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-25 14:32:08 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-25 14:32:08 +0000
commit23640dfdc3b34b2fe692227e2ffe687359cae60e (patch)
treec004fe7327f9dfcf716cd8337f024340a259583b /usr.bin/mandoc
parentff1953fd0fce3f1c9c4c95e7a157e716f1f41ea9 (diff)
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
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/eqn.c19
-rw-r--r--usr.bin/mandoc/libroff.h4
-rw-r--r--usr.bin/mandoc/roff.c25
3 files changed, 11 insertions, 37 deletions
diff --git a/usr.bin/mandoc/eqn.c b/usr.bin/mandoc/eqn.c
index d7bcb9ff2e3..82d169ed6b1 100644
--- a/usr.bin/mandoc/eqn.c
+++ b/usr.bin/mandoc/eqn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eqn.c,v 1.17 2014/10/16 01:10:06 schwarze Exp $ */
+/* $OpenBSD: eqn.c,v 1.18 2014/10/25 14:32:07 schwarze Exp $ */
/*
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -34,8 +34,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,
@@ -313,24 +311,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;
@@ -1106,7 +1092,6 @@ eqn_free(struct eqn_node *p)
free(p->defs[i].val);
}
- free(p->eqn.name);
free(p->data);
free(p->defs);
free(p);
diff --git a/usr.bin/mandoc/libroff.h b/usr.bin/mandoc/libroff.h
index 3f555a1a8f9..6e2c444b124 100644
--- a/usr.bin/mandoc/libroff.h
+++ b/usr.bin/mandoc/libroff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libroff.h,v 1.8 2014/10/16 01:10:06 schwarze Exp $ */
+/* $OpenBSD: libroff.h,v 1.9 2014/10/25 14:32:07 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,7 +77,7 @@ int tbl_data(struct tbl_node *, int, const char *);
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,
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 685a85d9be2..7e9da8d555c 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.106 2014/10/20 19:21:31 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.107 2014/10/25 14:32:07 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -205,8 +205,6 @@ static const char *roff_getstrn(const struct roff *,
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 *);
@@ -1926,15 +1924,13 @@ roff_eqndelim(struct roff *r, char **bufp, size_t *szp, int pos)
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;
@@ -1946,17 +1942,10 @@ roff_openeqn(struct roff *r, const char *name, int line,
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);
}