-/* $Id: argv.c,v 1.36 2009/03/05 12:08:53 kristaps Exp $ */
+/* $Id: argv.c,v 1.37 2009/03/05 13:12:12 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
static int argv_a2arg(int, const char *);
static int args(struct mdoc *, int, int *,
char *, int, char **);
-static int argv(struct mdoc *, int,
+static int argv(struct mdoc *, int, int,
struct mdoc_arg *, int *, char *);
static int argv_single(struct mdoc *, int,
struct mdoc_arg *, int *, char *);
ARGV_MULTI, /* MDOC_Column */
ARGV_SINGLE, /* MDOC_Width */
ARGV_NONE, /* MDOC_Compact */
- ARGV_OPT_SINGLE, /* MDOC_Std */
+ ARGV_SINGLE, /* MDOC_Std */
ARGV_NONE, /* MDOC_p1003_1_88 */
ARGV_NONE, /* MDOC_p1003_1_90 */
ARGV_NONE, /* MDOC_p1003_1_96 */
break;
i++;
/* There must be at least one space... */
- if (0 == buf[i] || ! isspace((int)buf[i]))
+ if (0 == buf[i] || ! isspace((u_char)buf[i]))
break;
i++;
- while (buf[i] && isspace((int)buf[i]))
+ while (buf[i] && isspace((u_char)buf[i]))
i++;
}
if (0 == buf[i]) {
if ( ! (ARGS_TABSEP & fl))
while (buf[*pos]) {
- if (isspace((int)buf[*pos]))
+ if (isspace((u_char)buf[*pos]))
if ('\\' != buf[*pos - 1])
break;
(*pos)++;
return(ARGS_WORD);
if ( ! (ARGS_TABSEP & fl))
- while (buf[*pos] && isspace((int)buf[*pos]))
+ while (buf[*pos] && isspace((u_char)buf[*pos]))
(*pos)++;
if (buf[*pos])
if (0 == buf[*pos])
return(ARGS_QWORD);
- while (buf[*pos] && isspace((int)buf[*pos]))
+ while (buf[*pos] && isspace((u_char)buf[*pos]))
(*pos)++;
if (buf[*pos])
* multiple parameters.
*/
static int
-argv(struct mdoc *mdoc, int line,
+argv(struct mdoc *mdoc, int tok, int line,
struct mdoc_arg *v, int *pos, char *buf)
{
+ int fl;
v->sz = 0;
v->value = NULL;
+ fl = mdoc_argvflags[v->arg];
- switch (mdoc_argvflags[v->arg]) {
+ /*
+ * Override the default per-argument value.
+ */
+
+ switch (tok) {
+ case (MDOC_Ex):
+ fl = ARGV_OPT_SINGLE;
+ break;
+ default:
+ break;
+ }
+
+ switch (fl) {
case (ARGV_SINGLE):
return(argv_single(mdoc, line, v, pos, buf));
case (ARGV_MULTI):
if (0 == buf[*pos])
return(ARGV_EOLN);
- assert( ! isspace((int)buf[*pos]));
+ assert( ! isspace((u_char)buf[*pos]));
if ('-' != buf[*pos])
return(ARGV_WORD);
/* LINTED */
while (buf[*pos]) {
- if (isspace((int)buf[*pos]))
+ if (isspace((u_char)buf[*pos]))
if ('\\' != buf[*pos - 1])
break;
(*pos)++;
return(ARGV_WORD);
}
- while (buf[*pos] && isspace((int)buf[*pos]))
+ while (buf[*pos] && isspace((u_char)buf[*pos]))
(*pos)++;
/* FIXME: whitespace if no value. */
- if ( ! argv(mdoc, line, v, pos, buf))
+ if ( ! argv(mdoc, tok, line, v, pos, buf))
return(ARGV_ERROR);
return(ARGV_ARG);