aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/argv.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-10 15:01:54 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-10 15:01:54 +0000
commit1730c3f7be321f16ec6b7afdfd0fb10a265d23bc (patch)
treed67b563172781b8123d08c04f527bb6d2c3f209d /argv.c
parentd9011dcb574a3608fa48cc49f1d616812090bcb8 (diff)
downloadmandoc-1730c3f7be321f16ec6b7afdfd0fb10a265d23bc.tar.gz
mandoc-1730c3f7be321f16ec6b7afdfd0fb10a265d23bc.tar.zst
mandoc-1730c3f7be321f16ec6b7afdfd0fb10a265d23bc.zip
Bug-fix in mdoc_argv.
Added some documentation to macro.c. Version-up.
Diffstat (limited to 'argv.c')
-rw-r--r--argv.c17
1 files changed, 13 insertions, 4 deletions
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 <kristaps@kth.se>
*
@@ -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))