summaryrefslogtreecommitdiffstats
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
commit684938dc1d7c8591d0b63657a1d36b25b24eaea8 (patch)
tree10a58e41eb97d1516b26419cab0bebf1ed50306c /mdoc_argv.c
parentd44be71f515f8494313986bc8379bc35f75dc802 (diff)
downloadmandoc-684938dc1d7c8591d0b63657a1d36b25b24eaea8.tar.gz
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.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 313439cc..12c15966 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -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++;
}