summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-08-08 15:32:17 +0000
committerschwarze <schwarze@openbsd.org>2014-08-08 15:32:17 +0000
commitbd39224a2803e9f26c41fd655bfcf69cbd581003 (patch)
tree850ef1288b7d5fd0c8c2c6b477265562a74fb298
parentGet rid of the useless FATAL error "child violates parent syntax". (diff)
downloadwireguard-openbsd-bd39224a2803e9f26c41fd655bfcf69cbd581003.tar.xz
wireguard-openbsd-bd39224a2803e9f26c41fd655bfcf69cbd581003.zip
Simplify: replace one global flag by one local variable
and remove three unused global flags. No functional change.
-rw-r--r--usr.bin/mandoc/libman.h5
-rw-r--r--usr.bin/mandoc/libmdoc.h3
-rw-r--r--usr.bin/mandoc/man.c68
-rw-r--r--usr.bin/mandoc/man_macro.c9
-rw-r--r--usr.bin/mandoc/mdoc.c42
5 files changed, 23 insertions, 104 deletions
diff --git a/usr.bin/mandoc/libman.h b/usr.bin/mandoc/libman.h
index 507808ee13d..a14d2adc988 100644
--- a/usr.bin/mandoc/libman.h
+++ b/usr.bin/mandoc/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.35 2014/07/07 19:17:39 schwarze Exp $ */
+/* $Id: libman.h,v 1.36 2014/08/08 15:32:17 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -26,12 +26,9 @@ struct man {
struct mparse *parse; /* parse pointer */
int quick; /* abort parse early */
int flags; /* parse flags */
-#define MAN_HALT (1 << 0) /* badness happened: die */
#define MAN_ELINE (1 << 1) /* Next-line element scope. */
#define MAN_BLINE (1 << 2) /* Next-line block scope. */
-#define MAN_ILINE (1 << 3) /* Ignored in next-line scope. */
#define MAN_LITERAL (1 << 4) /* Literal input. */
-#define MAN_BPLINE (1 << 5)
#define MAN_NEWLINE (1 << 6) /* first macro/text in a line */
enum man_next next; /* where to put the next node */
struct man_node *last; /* the last parsed node */
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h
index 224743682fa..545b96e3ad0 100644
--- a/usr.bin/mandoc/libmdoc.h
+++ b/usr.bin/mandoc/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.56 2014/07/09 11:30:07 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.57 2014/08/08 15:32:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -28,7 +28,6 @@ struct mdoc {
const char *defos; /* default argument for .Os */
int quick; /* abort parse early */
int flags; /* parse flags */
-#define MDOC_HALT (1 << 0) /* error in parse: halt */
#define MDOC_LITERAL (1 << 1) /* in a literal scope */
#define MDOC_PBODY (1 << 2) /* in the document body */
#define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 87b15be981d..133202c7aa8 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.83 2014/07/07 21:35:42 schwarze Exp $ */
+/* $Id: man.c,v 1.84 2014/08/08 15:32:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -64,7 +64,6 @@ const struct man_node *
man_node(const struct man *man)
{
- assert( ! (MAN_HALT & man->flags));
return(man->first);
}
@@ -72,7 +71,6 @@ const struct man_meta *
man_meta(const struct man *man)
{
- assert( ! (MAN_HALT & man->flags));
return(&man->meta);
}
@@ -112,11 +110,7 @@ int
man_endparse(struct man *man)
{
- assert( ! (MAN_HALT & man->flags));
- if (man_macroend(man))
- return(1);
- man->flags |= MAN_HALT;
- return(0);
+ return(man_macroend(man));
}
int
@@ -125,8 +119,6 @@ man_parseln(struct man *man, int ln, char *buf, int offs)
man->flags |= MAN_NEWLINE;
- assert( ! (MAN_HALT & man->flags));
-
return (roff_getcontrol(man->roff, buf, &offs) ?
man_pmacro(man, ln, buf, offs) :
man_ptext(man, ln, buf, offs));
@@ -348,8 +340,6 @@ man_addeqn(struct man *man, const struct eqn *ep)
{
struct man_node *n;
- assert( ! (MAN_HALT & man->flags));
-
n = man_node_alloc(man, ep->ln, ep->pos, MAN_EQN, MAN_MAX);
n->eqn = ep;
@@ -365,8 +355,6 @@ man_addspan(struct man *man, const struct tbl_span *sp)
{
struct man_node *n;
- assert( ! (MAN_HALT & man->flags));
-
n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX);
n->span = sp;
@@ -474,10 +462,11 @@ man_ptext(struct man *man, int line, char *buf, int offs)
static int
man_pmacro(struct man *man, int ln, char *buf, int offs)
{
- int i, ppos;
- enum mant tok;
char mac[5];
struct man_node *n;
+ enum mant tok;
+ int i, ppos;
+ int bline;
if ('"' == buf[offs]) {
mandoc_msg(MANDOCERR_COMMENT_BAD, man->parse,
@@ -577,20 +566,15 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
man->flags &= ~MAN_BLINE;
}
- /*
- * Save the fact that we're in the next-line for a block. In
- * this way, embedded roff instructions can "remember" state
- * when they exit.
- */
+ /* Remember whether we are in next-line scope for a block head. */
- if (MAN_BLINE & man->flags)
- man->flags |= MAN_BPLINE;
+ bline = man->flags & MAN_BLINE;
/* Call to handler... */
assert(man_macros[tok].fp);
if ( ! (*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf))
- goto err;
+ return(0);
/* In quick mode (for mandocdb), abort after the NAME section. */
@@ -602,35 +586,14 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
}
/*
- * We weren't in a block-line scope when entering the
- * above-parsed macro, so return.
- */
-
- if ( ! (MAN_BPLINE & man->flags)) {
- man->flags &= ~MAN_ILINE;
- return(1);
- }
- man->flags &= ~MAN_BPLINE;
-
- /*
- * If we're in a block scope, then allow this macro to slip by
- * without closing scope around it.
+ * If we are in a next-line scope for a block head,
+ * close it out now and switch to the body,
+ * unless the next-line scope is allowed to continue.
*/
- if (MAN_ILINE & man->flags) {
- man->flags &= ~MAN_ILINE;
+ if ( ! bline || man->flags & MAN_ELINE ||
+ man_macros[tok].flags & MAN_NSCOPED)
return(1);
- }
-
- /*
- * If we've opened a new next-line element scope, then return
- * now, as the next line will close out the block scope.
- */
-
- if (MAN_ELINE & man->flags)
- return(1);
-
- /* Close out the block scope opened in the prior line. */
assert(MAN_BLINE & man->flags);
man->flags &= ~MAN_BLINE;
@@ -638,11 +601,6 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
if ( ! man_unscope(man, man->last->parent))
return(0);
return(man_body_alloc(man, ln, ppos, man->last->tok));
-
-err: /* Error out. */
-
- man->flags |= MAN_HALT;
- return(0);
}
/*
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c
index f1c8ec3616b..a183bc4bf91 100644
--- a/usr.bin/mandoc/man_macro.c
+++ b/usr.bin/mandoc/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.48 2014/07/09 11:27:20 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.49 2014/08/08 15:32:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -411,13 +411,6 @@ in_line_eoln(MACRO_PROT_ARGS)
return(1);
}
- /* Set ignorable context, if applicable. */
-
- if (MAN_NSCOPED & man_macros[tok].flags) {
- assert( ! (MAN_SCOPED & man_macros[tok].flags));
- man->flags |= MAN_ILINE;
- }
-
assert(MAN_ROOT != man->last->type);
man->next = MAN_NEXT_SIBLING;
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index a5e2f7267b4..3d189d047ed 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.110 2014/07/09 11:30:07 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.111 2014/08/08 15:32:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -100,7 +100,6 @@ const struct mdoc_node *
mdoc_node(const struct mdoc *mdoc)
{
- assert( ! (MDOC_HALT & mdoc->flags));
return(mdoc->first);
}
@@ -108,7 +107,6 @@ const struct mdoc_meta *
mdoc_meta(const struct mdoc *mdoc)
{
- assert( ! (MDOC_HALT & mdoc->flags));
return(&mdoc->meta);
}
@@ -201,19 +199,11 @@ mdoc_alloc(struct roff *roff, struct mparse *parse,
return(p);
}
-/*
- * Climb back up the parse tree, validating open scopes. Mostly calls
- * through to macro_end() in macro.c.
- */
int
mdoc_endparse(struct mdoc *mdoc)
{
- assert( ! (MDOC_HALT & mdoc->flags));
- if (mdoc_macroend(mdoc))
- return(1);
- mdoc->flags |= MDOC_HALT;
- return(0);
+ return(mdoc_macroend(mdoc));
}
int
@@ -221,8 +211,6 @@ mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep)
{
struct mdoc_node *n;
- assert( ! (MDOC_HALT & mdoc->flags));
-
n = node_alloc(mdoc, ep->ln, ep->pos, MDOC_MAX, MDOC_EQN);
n->eqn = ep;
@@ -238,8 +226,6 @@ mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp)
{
struct mdoc_node *n;
- assert( ! (MDOC_HALT & mdoc->flags));
-
n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, MDOC_TBL);
n->span = sp;
@@ -258,8 +244,6 @@ int
mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs)
{
- assert( ! (MDOC_HALT & mdoc->flags));
-
mdoc->flags |= MDOC_NEWLINE;
/*
@@ -879,11 +863,8 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
* into macro processing.
*/
- if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok) {
- if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf))
- goto err;
- return(1);
- }
+ if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok)
+ return(mdoc_macro(mdoc, tok, ln, sv, &offs, buf));
n = mdoc->last;
assert(mdoc->last);
@@ -896,9 +877,7 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
LIST_column == n->norm->Bl.type) {
mdoc->flags |= MDOC_FREECOL;
- if ( ! mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf))
- goto err;
- return(1);
+ return(mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf));
}
/*
@@ -912,15 +891,13 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
MDOC_Bl == n->parent->tok &&
LIST_column == n->parent->norm->Bl.type) {
mdoc->flags |= MDOC_FREECOL;
- if ( ! mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf))
- goto err;
- return(1);
+ return(mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf));
}
/* Normal processing of a macro. */
if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf))
- goto err;
+ return(0);
/* In quick mode (for mandocdb), abort after the NAME section. */
@@ -929,11 +906,6 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
return(2);
return(1);
-
-err: /* Error out. */
-
- mdoc->flags |= MDOC_HALT;
- return(0);
}
enum mdelim