From: Kristaps Dzonsons Date: Tue, 10 Mar 2009 15:01:54 +0000 (+0000) Subject: Bug-fix in mdoc_argv. X-Git-Tag: VERSION_1_5_1~21 X-Git-Url: https://git.cameronkatri.com/mandoc.git/commitdiff_plain/1730c3f7be321f16ec6b7afdfd0fb10a265d23bc Bug-fix in mdoc_argv. Added some documentation to macro.c. Version-up. --- diff --git a/Makefile b/Makefile index 7b2f0256..98f9257d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .SUFFIXES: .html .sgml -VERSION = 1.4.7 -VDATE = 9 March 2009 +VERSION = 1.4.8 +VDATE = 10 March 2009 BINDIR = $(PREFIX)/bin INCLUDEDIR = $(PREFIX)/include diff --git a/argv.c b/argv.c index 99eb9f86..4865cdf4 100644 --- a/argv.c +++ b/argv.c @@ -1,4 +1,4 @@ -/* $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 * @@ -226,7 +226,7 @@ mdoc_argv(struct mdoc *mdoc, int line, int tok, struct mdoc_arg **v, int *pos, char *buf) { int i; - char *p; + char *p, sv; struct mdoc_argv tmp; struct mdoc_arg *arg; @@ -251,8 +251,15 @@ mdoc_argv(struct mdoc *mdoc, int line, int tok, (*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; @@ -265,6 +272,8 @@ mdoc_argv(struct mdoc *mdoc, int line, int tok, */ 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); @@ -575,7 +584,7 @@ args(struct mdoc *mdoc, int line, return(ARGS_WORD); } - + /* Do non-tabsep look-ahead here. */ if ( ! (ARGS_TABSEP & fl)) diff --git a/macro.c b/macro.c index 1384d6f6..becad97b 100644 --- a/macro.c +++ b/macro.c @@ -1,4 +1,4 @@ -/* $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 * @@ -30,6 +30,8 @@ * 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); @@ -798,7 +800,7 @@ macro_text(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); @@ -807,9 +809,13 @@ macro_text(MACRO_PROT_ARGS) 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); @@ -822,7 +828,7 @@ macro_text(MACRO_PROT_ARGS) } 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))