diff options
-rw-r--r-- | libman.h | 1 | ||||
-rw-r--r-- | libmdoc.h | 1 | ||||
-rw-r--r-- | man.c | 6 | ||||
-rw-r--r-- | mdoc.c | 20 |
4 files changed, 21 insertions, 7 deletions
@@ -66,6 +66,7 @@ enum merr { WROFFNEST, WROFFSCOPE, WTITLECASE, + WBADCOMMENT, WERRMAX }; @@ -93,6 +93,7 @@ enum merr { ELIB, EBADCHILD, ENOTYPE, + EBADCOMMENT, MERRMAX }; @@ -53,6 +53,7 @@ const char *const __man_merrnames[WERRMAX] = { "invalid nesting of roff declarations", /* WROFFNEST */ "scope in roff instructions broken", /* WROFFSCOPE */ "document title should be uppercase", /* WTITLECASE */ + "deprecated comment style", /* WBADCOMMENT */ }; const char *const __man_macronames[MAN_MAX] = { @@ -378,6 +379,11 @@ man_ptext(struct man *m, int line, char *buf) int i, j; char sv; + /* Ignore bogus comments. */ + + if ('\\' == buf[0] && '.' == buf[1] && '\"' == buf[2]) + return(man_pwarn(m, line, 0, WBADCOMMENT)); + /* Literal free-form text whitespace is preserved. */ if (MAN_LITERAL & m->flags) { @@ -84,6 +84,7 @@ const char *const __mdoc_merrnames[MERRMAX] = { "no description found for library", /* ELIB */ "bad child for parent context", /* EBADCHILD */ "list arguments preceding type", /* ENOTYPE */ + "deprecated comment style", /* EBADCOMMENT */ }; const char *const __mdoc_macronames[MDOC_MAX] = { @@ -150,8 +151,8 @@ static struct mdoc_node *node_alloc(struct mdoc *, int, int, enum mdoct, enum mdoc_type); static int node_append(struct mdoc *, struct mdoc_node *); -static int parsetext(struct mdoc *, int, char *); -static int parsemacro(struct mdoc *, int, char *); +static int mdoc_ptext(struct mdoc *, int, char *); +static int mdoc_pmacro(struct mdoc *, int, char *); static int macrowarn(struct mdoc *, int, const char *); static int pstring(struct mdoc *, int, int, const char *, size_t); @@ -280,7 +281,7 @@ mdoc_endparse(struct mdoc *m) /* * Main parse routine. Parses a single line -- really just hands off to - * the macro (parsemacro()) or text parser (parsetext()). + * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()). */ int mdoc_parseln(struct mdoc *m, int ln, char *buf) @@ -289,8 +290,8 @@ mdoc_parseln(struct mdoc *m, int ln, char *buf) if (MDOC_HALT & m->flags) return(0); - return('.' == *buf ? parsemacro(m, ln, buf) : - parsetext(m, ln, buf)); + return('.' == *buf ? mdoc_pmacro(m, ln, buf) : + mdoc_ptext(m, ln, buf)); } @@ -630,11 +631,16 @@ mdoc_node_delete(struct mdoc *m, struct mdoc_node *p) * control character. */ static int -parsetext(struct mdoc *m, int line, char *buf) +mdoc_ptext(struct mdoc *m, int line, char *buf) { int i, j; char sv; + /* Ignore bogus comments. */ + + if ('\\' == buf[0] && '.' == buf[1] && '\"' == buf[2]) + return(mdoc_pwarn(m, line, 0, EBADCOMMENT)); + if (SEC_NONE == m->lastnamed) return(mdoc_perr(m, line, 0, ETEXTPROL)); @@ -730,7 +736,7 @@ macrowarn(struct mdoc *m, int ln, const char *buf) * character. */ int -parsemacro(struct mdoc *m, int ln, char *buf) +mdoc_pmacro(struct mdoc *m, int ln, char *buf) { int i, j, c; char mac[5]; |