summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-09-06 23:24:28 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-09-06 23:24:28 +0000
commite9b079495988ca64ee62f873dbb5bee4c76d4a82 (patch)
treeb277ac91b05eadebb1eba4d914c1c672444b7ba1 /usr.bin/mandoc
parent6c344478d0311768775c38df1871d5c8c4e32924 (diff)
Simplify by handling empty request lines at the one logical place
in the roff parser instead of in three other places in other parsers. No functional change.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/man.c9
-rw-r--r--usr.bin/mandoc/mdoc.c11
-rw-r--r--usr.bin/mandoc/read.c21
-rw-r--r--usr.bin/mandoc/roff.c11
4 files changed, 17 insertions, 35 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 496b9563daa..5905deebf56 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.86 2014/08/08 16:05:42 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.87 2014/09/06 23:24:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -469,13 +469,6 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
int i, ppos;
int bline;
- if ('"' == buf[offs]) {
- mandoc_msg(MANDOCERR_COMMENT_BAD, man->parse,
- ln, offs, NULL);
- return(1);
- } else if ('\0' == buf[offs])
- return(1);
-
ppos = offs;
/*
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index af1805db250..00066b18345 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.113 2014/08/08 16:17:09 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.114 2014/09/06 23:24:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -791,15 +791,6 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
char mac[5];
struct mdoc_node *n;
- /* Empty post-control lines are ignored. */
-
- if ('"' == buf[offs]) {
- mandoc_msg(MANDOCERR_COMMENT_BAD, mdoc->parse,
- ln, offs, NULL);
- return(1);
- } else if ('\0' == buf[offs])
- return(1);
-
sv = offs;
/*
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 1ad43d7d0df..c9f70d8aed8 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.59 2014/09/06 22:38:35 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.60 2014/09/06 23:24:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -63,9 +63,9 @@ struct mparse {
int line; /* line number in the file */
};
+static void choose_parser(struct mparse *);
static void resize_buf(struct buf *, size_t);
static void mparse_buf_r(struct mparse *, struct buf, int);
-static void pset(const char *, int, struct mparse *);
static int read_whole_file(struct mparse *, const char *, int,
struct buf *, int *);
static void mparse_end(struct mparse *);
@@ -241,19 +241,10 @@ resize_buf(struct buf *buf, size_t initial)
}
static void
-pset(const char *buf, int pos, struct mparse *curp)
+choose_parser(struct mparse *curp)
{
char *cp, *ep;
int format;
- int i;
-
- if ('.' == buf[0] || '\'' == buf[0]) {
- for (i = 1; buf[i]; i++)
- if (' ' != buf[i] && '\t' != buf[i])
- break;
- if ('\0' == buf[i])
- return;
- }
/*
* If neither command line arguments -mdoc or -man select
@@ -544,12 +535,10 @@ rerun:
*/
if ( ! (curp->man || curp->mdoc))
- pset(ln.buf + of, pos - of, curp);
+ choose_parser(curp);
/*
- * Lastly, push down into the parsers themselves. One
- * of these will have already been set in the pset()
- * routine.
+ * Lastly, push down into the parsers themselves.
* If libroff returns ROFF_TBL, then add it to the
* currently open parse. Since we only get here if
* there does exist data (see tbl_data.c), we're
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 88b9e2d7abe..84ce3a0ee89 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.99 2014/09/06 22:38:35 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.100 2014/09/06 23:24:27 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -757,6 +757,15 @@ roff_parseln(struct roff *r, int ln, char **bufp,
return(roff_parsetext(bufp, szp, pos, offs));
}
+ /* Skip empty request lines. */
+
+ if ((*bufp)[pos] == '"') {
+ mandoc_msg(MANDOCERR_COMMENT_BAD, r->parse,
+ ln, pos, NULL);
+ return(ROFF_IGN);
+ } else if ((*bufp)[pos] == '\0')
+ return(ROFF_IGN);
+
/*
* If a scope is open, go to the child handler for that macro,
* as it may want to preprocess before doing anything with it.