aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--libman.h4
-rw-r--r--libmdoc.h3
-rw-r--r--man.c53
-rw-r--r--man_macro.c9
-rw-r--r--mdoc.c42
5 files changed, 18 insertions, 93 deletions
diff --git a/libman.h b/libman.h
index 91827987..66e36c97 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.60 2014/07/30 20:06:36 schwarze Exp $ */
+/* $Id: libman.h,v 1.61 2014/07/30 21:18:24 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -26,10 +26,8 @@ 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_NEWLINE (1 << 6) /* first macro/text in a line */
enum man_next next; /* where to put the next node */
diff --git a/libmdoc.h b/libmdoc.h
index 8b9b8dec..21badbde 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.86 2014/07/09 11:31:43 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.87 2014/07/30 21:18:24 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/man.c b/man.c
index 0d3ca7e3..d61014e0 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.134 2014/07/30 20:06:36 schwarze Exp $ */
+/* $Id: man.c,v 1.135 2014/07/30 21:18:24 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -68,7 +68,6 @@ const struct man_node *
man_node(const struct man *man)
{
- assert( ! (MAN_HALT & man->flags));
return(man->first);
}
@@ -76,7 +75,6 @@ const struct man_meta *
man_meta(const struct man *man)
{
- assert( ! (MAN_HALT & man->flags));
return(&man->meta);
}
@@ -116,11 +114,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
@@ -129,8 +123,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));
@@ -352,8 +344,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;
@@ -369,8 +359,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;
@@ -590,7 +578,7 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
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,46 +590,21 @@ 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 ( ! bline) {
- man->flags &= ~MAN_ILINE;
- return(1);
- }
-
- /*
- * If we're in a block scope, then allow this macro to slip by
- * without closing scope around it.
- */
-
- if (MAN_ILINE & man->flags) {
- man->flags &= ~MAN_ILINE;
- 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 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_ELINE & man->flags)
+ if ( ! bline || man->flags & MAN_ELINE ||
+ man_macros[tok].flags & MAN_NSCOPED)
return(1);
- /* Close out the block scope opened in the prior line. */
-
assert(MAN_BLINE & man->flags);
man->flags &= ~MAN_BLINE;
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/man_macro.c b/man_macro.c
index 98573796..c8aa4018 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.85 2014/07/09 11:28:26 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.86 2014/07/30 21:18:24 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -415,13 +415,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/mdoc.c b/mdoc.c
index 159d4a02..a9e7dfbd 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.220 2014/07/09 11:31:43 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.221 2014/07/30 21:18:24 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -104,7 +104,6 @@ const struct mdoc_node *
mdoc_node(const struct mdoc *mdoc)
{
- assert( ! (MDOC_HALT & mdoc->flags));
return(mdoc->first);
}
@@ -112,7 +111,6 @@ const struct mdoc_meta *
mdoc_meta(const struct mdoc *mdoc)
{
- assert( ! (MDOC_HALT & mdoc->flags));
return(&mdoc->meta);
}
@@ -205,19 +203,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
@@ -225,8 +215,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;
@@ -242,8 +230,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;
@@ -262,8 +248,6 @@ int
mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs)
{
- assert( ! (MDOC_HALT & mdoc->flags));
-
mdoc->flags |= MDOC_NEWLINE;
/*
@@ -883,11 +867,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);
@@ -900,9 +881,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));
}
/*
@@ -916,15 +895,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. */
@@ -933,11 +910,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