diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-04-15 10:31:01 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-04-15 10:31:01 +0000 |
commit | 980eec0e86e461e8d9899864e5f2b87c53c3f172 (patch) | |
tree | 4115e89025c8ec5eba98f7aa901e3919c8bfb619 /usr.bin | |
parent | e801a96c6b02f2ad1ad92a0e4e243aa7d2af9778 (diff) |
Two bugfixes regarding the -width and -offset macro arguments:
1) They consume the next argument even if it starts with a dash.
2) When -width is the last argument on the line such that the
actual width argument is missing, downgrade from a fatal to a
non-fatal error, just like for -offset. The formatting still
doesn't agree with groff, but at least we don't die any longer.
Item 2 was observed and that part of the patch coded by kristaps@,
who found lots of instances of this particular formatting error
in Mac OSX manuals.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mdoc_argv.c | 42 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 13 |
2 files changed, 13 insertions, 42 deletions
diff --git a/usr.bin/mandoc/mdoc_argv.c b/usr.bin/mandoc/mdoc_argv.c index 97a71a55563..2daa8853b4f 100644 --- a/usr.bin/mandoc/mdoc_argv.c +++ b/usr.bin/mandoc/mdoc_argv.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_argv.c,v 1.39 2011/07/05 04:12:41 schwarze Exp $ */ +/* $Id: mdoc_argv.c,v 1.40 2012/04/15 10:31:00 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -38,8 +38,7 @@ enum argsflag { enum argvflag { ARGV_NONE, /* no args to flag (e.g., -split) */ ARGV_SINGLE, /* one arg to flag (e.g., -file xxx) */ - ARGV_MULTI, /* multiple args (e.g., -column xxx yyy) */ - ARGV_OPT_SINGLE /* optional arg (e.g., -offset [xxx]) */ + ARGV_MULTI /* multiple args (e.g., -column xxx yyy) */ }; struct mdocarg { @@ -53,8 +52,6 @@ static enum margserr args(struct mdoc *, int, int *, static int args_checkpunct(const char *, int); static int argv_multi(struct mdoc *, int, struct mdoc_argv *, int *, char *); -static int argv_opt_single(struct mdoc *, int, - struct mdoc_argv *, int *, char *); static int argv_single(struct mdoc *, int, struct mdoc_argv *, int *, char *); @@ -65,7 +62,7 @@ static const enum argvflag argvflags[MDOC_ARG_MAX] = { ARGV_NONE, /* MDOC_Unfilled */ ARGV_NONE, /* MDOC_Literal */ ARGV_SINGLE, /* MDOC_File */ - ARGV_OPT_SINGLE, /* MDOC_Offset */ + ARGV_SINGLE, /* MDOC_Offset */ ARGV_NONE, /* MDOC_Bullet */ ARGV_NONE, /* MDOC_Dash */ ARGV_NONE, /* MDOC_Hyphen */ @@ -347,10 +344,6 @@ mdoc_argv(struct mdoc *m, int line, enum mdoct tok, if ( ! argv_multi(m, line, &tmp, pos, buf)) return(ARGV_ERROR); break; - case (ARGV_OPT_SINGLE): - if ( ! argv_opt_single(m, line, &tmp, pos, buf)) - return(ARGV_ERROR); - break; case (ARGV_NONE): break; } @@ -665,15 +658,12 @@ argv_multi(struct mdoc *m, int line, } static int -argv_opt_single(struct mdoc *m, int line, +argv_single(struct mdoc *m, int line, struct mdoc_argv *v, int *pos, char *buf) { enum margserr ac; char *p; - if ('-' == buf[*pos]) - return(1); - ac = args(m, line, pos, buf, ARGSFL_NONE, &p); if (ARGS_ERROR == ac) return(0); @@ -686,27 +676,3 @@ argv_opt_single(struct mdoc *m, int line, return(1); } - -static int -argv_single(struct mdoc *m, int line, - struct mdoc_argv *v, int *pos, char *buf) -{ - int ppos; - enum margserr ac; - char *p; - - ppos = *pos; - - ac = args(m, line, pos, buf, ARGSFL_NONE, &p); - if (ARGS_EOLN == ac) { - mdoc_pmsg(m, line, ppos, MANDOCERR_SYNTARGVCOUNT); - return(0); - } else if (ARGS_ERROR == ac) - return(0); - - v->sz = 1; - v->value = mandoc_malloc(sizeof(char *)); - v->value[0] = mandoc_strdup(p); - - return(1); -} diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 85bea2c39d5..75a93f6e094 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,6 +1,6 @@ -/* $Id: mdoc_validate.c,v 1.100 2011/12/03 22:47:27 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.101 2012/04/15 10:31:00 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any @@ -657,8 +657,13 @@ pre_bl(PRE_ARGS) comp = 1; break; case (MDOC_Width): - dup = (NULL != n->norm->Bl.width); - width = n->args->argv[i].value[0]; + /* NB: this can be empty! */ + if (n->args->argv[i].sz) { + width = n->args->argv[i].value[0]; + dup = (NULL != n->norm->Bl.width); + break; + } + mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV); break; case (MDOC_Offset): /* NB: this can be empty! */ |