diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-04-03 16:30:43 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-04-03 16:30:43 +0000 |
commit | 7b5508e5ab84457176675d2c1b861e2be8ef2a6c (patch) | |
tree | 4ce9558cd3f0e3ac0bf2e1a849e90b6a72c7beb9 /usr.bin | |
parent | 2563c9e78c5ee0daf4204e7057cd9e7b8e7c16e0 (diff) |
When two conflicting list types are specified for the same list,
use the first, discard the second, and warn. No need to bail out.
ok deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/libmdoc.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_argv.c | 35 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 10 |
3 files changed, 29 insertions, 19 deletions
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h index 92f6c01f27a..b76f2ed8f04 100644 --- a/usr.bin/mandoc/libmdoc.h +++ b/usr.bin/mandoc/libmdoc.h @@ -1,4 +1,4 @@ -/* $Id: libmdoc.h,v 1.25 2010/04/02 12:39:47 schwarze Exp $ */ +/* $Id: libmdoc.h,v 1.26 2010/04/03 16:30:42 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -167,6 +167,7 @@ int mdoc_argv(struct mdoc *, int, enum mdoct, #define ARGV_ARG (1) #define ARGV_WORD (2) void mdoc_argv_free(struct mdoc_arg *); +void mdoc_argn_free(struct mdoc_arg *, int); int mdoc_args(struct mdoc *, int, int *, char *, enum mdoct, char **); int mdoc_zargs(struct mdoc *, int, diff --git a/usr.bin/mandoc/mdoc_argv.c b/usr.bin/mandoc/mdoc_argv.c index 43ba178e0f2..f181dcbe897 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.22 2010/04/02 12:39:47 schwarze Exp $ */ +/* $Id: mdoc_argv.c,v 1.23 2010/04/03 16:30:42 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -285,7 +285,7 @@ mdoc_argv(struct mdoc *m, int line, enum mdoct tok, void mdoc_argv_free(struct mdoc_arg *p) { - int i, j; + int i; if (NULL == p) return; @@ -297,23 +297,28 @@ mdoc_argv_free(struct mdoc_arg *p) } assert(p->argc); - /* LINTED */ - for (i = 0; i < (int)p->argc; i++) { - if (0 == p->argv[i].sz) - continue; - if (NULL == p->argv[i].value) - continue; + for (i = p->argc - 1; i >= 0; i--) + mdoc_argn_free(p, i); + + free(p->argv); + free(p); +} + - /* LINTED */ - for (j = 0; j < (int)p->argv[i].sz; j++) - if (p->argv[i].value[j]) - free(p->argv[i].value[j]); +void +mdoc_argn_free(struct mdoc_arg *p, int iarg) +{ + struct mdoc_argv *arg = &p->argv[iarg]; + int j; - free(p->argv[i].value); + if (arg->sz && arg->value) { + for (j = arg->sz - 1; j >= 0; j--) + free(arg->value[j]); + free(arg->value); } - free(p->argv); - free(p); + for (--p->argc; iarg < (int)p->argc; iarg++) + p->argv[iarg] = p->argv[iarg+1]; } diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 69d7a46a246..45792ce5968 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.45 2010/04/03 16:24:17 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.46 2010/04/03 16:30:42 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -618,8 +618,12 @@ pre_bl(PRE_ARGS) case (MDOC_Inset): /* FALLTHROUGH */ case (MDOC_Column): - if (type >= 0) - return(mdoc_nerr(mdoc, n, EMULTILIST)); + if (type >= 0) { + if ( ! mdoc_nwarn(mdoc, n, EMULTILIST)) + return(0); + mdoc_argn_free(n->args, pos); + break; + } type = n->args->argv[pos].arg; break; case (MDOC_Compact): |