aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_argv.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-03-17 01:23:28 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-03-17 01:23:28 +0000
commitcc5eaab1fc61af7bb315ef9938831121ef7ad4bc (patch)
treef3ff3328cbe7d0600aa562a39ca6b2c7ae81cc37 /mdoc_argv.c
parent5ac5955e47f16a7b4767aa4bd138b6ad73e53760 (diff)
downloadmandoc-cc5eaab1fc61af7bb315ef9938831121ef7ad4bc.tar.gz
mandoc-cc5eaab1fc61af7bb315ef9938831121ef7ad4bc.tar.zst
mandoc-cc5eaab1fc61af7bb315ef9938831121ef7ad4bc.zip
Make args_checkpunct() use mdoc_isdelim() instead of mdoc_iscdelim(),
which is wrong. Then remove mdoc_iscdelim() alltogether.
Diffstat (limited to 'mdoc_argv.c')
-rw-r--r--mdoc_argv.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/mdoc_argv.c b/mdoc_argv.c
index c404dae3..dc28916c 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.64 2011/03/17 00:58:14 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.65 2011/03/17 01:23:28 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -412,13 +412,6 @@ args(struct mdoc *m, int line, int *pos,
return(ARGS_EOLN);
}
- /*
- * If the first character is a closing delimiter and we're to
- * look for delimited strings, then pass down the buffer seeing
- * if it follows the pattern of [[::delim::][ ]+]+. Note that
- * we ONLY care about closing delimiters.
- */
-
*v = &buf[*pos];
if (ARGS_DELIM & fl && args_checkpunct(&buf[*pos])) {
@@ -572,28 +565,50 @@ args(struct mdoc *m, int line, int *pos,
/*
* Check if the string consists only of space-separated closing
- * delimiters.
+ * delimiters. This is a bit of a dance: the first must be a close
+ * delimiter, but it may be followed by middle delimiters. Arbitrary
+ * whitespace may separate these tokens.
*/
static int
args_checkpunct(const char *p)
{
- int i;
+ int i, j;
+ char buf[DELIMSZ];
enum mdelim d;
i = 0;
- if (DELIM_CLOSE != mdoc_iscdelim(p[i]))
+ /* First token must be a close-delimiter. */
+
+ for (j = 0; p[i] && ' ' != p[i] && j < DELIMSZ; j++, i++)
+ buf[j] = p[i];
+
+ if (DELIMSZ == j)
return(0);
- while ('\0' != p[i]) {
- d = mdoc_iscdelim(p[i]);
- if (DELIM_NONE == d || DELIM_OPEN == d)
- break;
- i++;
- if ('\0' == p[i] || ' ' != p[i])
- break;
+ buf[j] = '\0';
+ if (DELIM_CLOSE != mdoc_isdelim(buf))
+ return(0);
+
+ while (' ' == p[i])
i++;
- while (p[i] && ' ' == p[i])
+
+ /* Remaining must NOT be open/none. */
+
+ while (p[i]) {
+ j = 0;
+ while (p[i] && ' ' != p[i] && j < DELIMSZ)
+ buf[j++] = p[i++];
+
+ if (DELIMSZ == j)
+ return(0);
+
+ buf[j] = '\0';
+ d = mdoc_isdelim(buf);
+ if (DELIM_NONE == d || DELIM_OPEN == d)
+ return(0);
+
+ while (' ' == p[i])
i++;
}