-/* $Id: argv.c,v 1.45 2009/03/09 14:19:59 kristaps Exp $ */
+/* $Id: argv.c,v 1.46 2009/03/10 15:01:54 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
struct mdoc_arg **v, int *pos, char *buf)
{
int i;
- char *p;
+ char *p, sv;
struct mdoc_argv tmp;
struct mdoc_arg *arg;
(*pos)++;
}
- if (buf[*pos])
+ /*
+ * XXX: save the nullified byte as we'll restore it if this
+ * doesn't end up being a command after all.
+ */
+
+ if (buf[*pos]) {
+ sv = buf[*pos];
buf[(*pos)++] = 0;
+ }
(void)memset(&tmp, 0, sizeof(struct mdoc_argv));
tmp.line = line;
*/
if (MDOC_ARG_MAX == (tmp.arg = argv_a2arg(tok, p))) {
+ /* Restore saved byte. */
+ buf[*pos - 1] = sv;
if ( ! pwarn(mdoc, line, i, WARGVPARM))
return(ARGV_ERROR);
return(ARGV_WORD);
return(ARGS_WORD);
}
-
+
/* Do non-tabsep look-ahead here. */
if ( ! (ARGS_TABSEP & fl))
-/* $Id: macro.c,v 1.64 2009/03/09 14:19:59 kristaps Exp $ */
+/* $Id: macro.c,v 1.65 2009/03/10 15:01:54 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
* macro.
*/
+/* FIXME: .Fl, .Ar, .Cd handling of `|'. */
+
static int macro_obsolete(MACRO_PROT_ARGS);
static int macro_constant(MACRO_PROT_ARGS);
static int macro_constant_scoped(MACRO_PROT_ARGS);
for (;;) {
la = *pos;
w = mdoc_args(mdoc, line, pos, buf, tok, &p);
- assert(ARGS_PHRASE != c);
+ assert(ARGS_PHRASE != w);
if (ARGS_ERROR == w)
return(0);
if (ARGS_PUNCT == w)
break;
+ /* Quoted words shouldn't be looked-up. */
+
c = ARGS_QWORD == w ? MDOC_MAX :
lookup(mdoc, line, la, tok, p);
+ /* MDOC_MAX (not a macro) or -1 (error). */
+
if (MDOC_MAX != c && -1 != c) {
if (0 == lastpunct && ! rewind_elem(mdoc, tok))
return(0);
} else if (-1 == c)
return(0);
- /* FIXME: .Fl and .Ar handling of `|'. */
+ /* Non-quote-enclosed punctuation. */
if (ARGS_QWORD != w && mdoc_isdelim(p)) {
if (0 == lastpunct && ! rewind_elem(mdoc, tok))