=================================================================== RCS file: /cvs/mandoc/mdoc_argv.c,v retrieving revision 1.108 retrieving revision 1.113 diff -u -p -r1.108 -r1.113 --- mandoc/mdoc_argv.c 2016/07/15 18:03:45 1.108 +++ mandoc/mdoc_argv.c 2017/05/05 13:17:55 1.113 @@ -1,7 +1,7 @@ -/* $Id: mdoc_argv.c,v 1.108 2016/07/15 18:03:45 schwarze Exp $ */ +/* $Id: mdoc_argv.c,v 1.113 2017/05/05 13:17:55 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2012, 2014, 2015 Ingo Schwarze + * Copyright (c) 2012, 2014-2017 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -144,8 +144,7 @@ static const enum mdocargt args_Bl[] = { MDOC_ARG_MAX }; -static const struct mdocarg mdocargs[MDOC_MAX] = { - { ARGSFL_DELIM, NULL }, /* Ap */ +static const struct mdocarg __mdocargs[MDOC_MAX - MDOC_Dd] = { { ARGSFL_NONE, NULL }, /* Dd */ { ARGSFL_NONE, NULL }, /* Dt */ { ARGSFL_NONE, NULL }, /* Os */ @@ -161,6 +160,7 @@ static const struct mdocarg mdocargs[MDOC_MAX] = { { ARGSFL_NONE, NULL }, /* It */ { ARGSFL_DELIM, NULL }, /* Ad */ { ARGSFL_DELIM, args_An }, /* An */ + { ARGSFL_DELIM, NULL }, /* Ap */ { ARGSFL_DELIM, NULL }, /* Ar */ { ARGSFL_DELIM, NULL }, /* Cd */ { ARGSFL_DELIM, NULL }, /* Cm */ @@ -263,12 +263,11 @@ static const struct mdocarg mdocargs[MDOC_MAX] = { { ARGSFL_DELIM, NULL }, /* En */ { ARGSFL_DELIM, NULL }, /* Dx */ { ARGSFL_NONE, NULL }, /* %Q */ - { ARGSFL_NONE, NULL }, /* br */ { ARGSFL_NONE, NULL }, /* sp */ { ARGSFL_NONE, NULL }, /* %U */ { ARGSFL_NONE, NULL }, /* Ta */ - { ARGSFL_NONE, NULL }, /* ll */ }; +static const struct mdocarg *const mdocargs = __mdocargs - MDOC_Dd; /* @@ -277,7 +276,7 @@ static const struct mdocarg mdocargs[MDOC_MAX] = { * Some flags take no argument, some one, some multiple. */ void -mdoc_argv(struct roff_man *mdoc, int line, int tok, +mdoc_argv(struct roff_man *mdoc, int line, enum roff_tok tok, struct mdoc_arg **reta, int *pos, char *buf) { struct mdoc_argv tmpv; @@ -291,6 +290,7 @@ mdoc_argv(struct roff_man *mdoc, int line, int tok, /* Which flags does this macro support? */ + assert(tok >= MDOC_Dd && tok < MDOC_MAX); argtable = mdocargs[tok].argvs; if (argtable == NULL) return; @@ -415,7 +415,7 @@ argn_free(struct mdoc_arg *p, int iarg) enum margserr mdoc_args(struct roff_man *mdoc, int line, int *pos, - char *buf, int tok, char **v) + char *buf, enum roff_tok tok, char **v) { struct roff_node *n; char *v_local; @@ -424,8 +424,6 @@ mdoc_args(struct roff_man *mdoc, int line, int *pos, if (v == NULL) v = &v_local; fl = tok == TOKEN_NONE ? ARGSFL_NONE : mdocargs[tok].flags; - if (tok != MDOC_It) - return args(mdoc, line, pos, buf, fl, v); /* * We know that we're in an `It', so it's reasonable to expect @@ -434,12 +432,15 @@ mdoc_args(struct roff_man *mdoc, int line, int *pos, * safe fall-back into the default behaviour. */ - for (n = mdoc->last; n; n = n->parent) - if (MDOC_Bl == n->tok) - if (LIST_column == n->norm->Bl.type) { + if (tok == MDOC_It) { + for (n = mdoc->last; n != NULL; n = n->parent) { + if (n->tok != MDOC_Bl) + continue; + if (n->norm->Bl.type == LIST_column) fl = ARGSFL_TABSEP; - break; - } + break; + } + } return args(mdoc, line, pos, buf, fl, v); } @@ -480,7 +481,7 @@ args(struct roff_man *mdoc, int line, int *pos, * unless there is a blank in between. */ - if (p[-1] != ' ') + if (p > buf && p[-1] != ' ') mdoc->flags |= MDOC_PHRASEQL; if (p[1] != ' ') mdoc->flags |= MDOC_PHRASEQN;