=================================================================== RCS file: /cvs/mandoc/mdoc_argv.c,v retrieving revision 1.41 retrieving revision 1.45 diff -u -p -r1.41 -r1.45 --- mandoc/mdoc_argv.c 2010/05/07 06:05:38 1.41 +++ mandoc/mdoc_argv.c 2010/05/09 21:06:50 1.45 @@ -1,4 +1,4 @@ -/* $Id: mdoc_argv.c,v 1.41 2010/05/07 06:05:38 kristaps Exp $ */ +/* $Id: mdoc_argv.c,v 1.45 2010/05/09 21:06:50 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -398,13 +398,14 @@ args(struct mdoc *m, int line, int *pos, assert(*pos); assert(' ' != buf[*pos]); - if (0 == buf[*pos]) + if ('\0' == buf[*pos]) return(ARGS_EOLN); /* - * If the first character is a delimiter and we're to look for - * delimited strings, then pass down the buffer seeing if it - * follows the pattern of [[::delim::][ ]+]+. + * 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. */ if ((fl & ARGS_DELIM) && mdoc_iscdelim(buf[*pos]) > 1) { @@ -412,14 +413,14 @@ args(struct mdoc *m, int line, int *pos, if ( mdoc_iscdelim(buf[i]) < 2) break; i++; - if (0 == buf[i] || ' ' != buf[i]) + if ('\0' == buf[i] || ' ' != buf[i]) break; i++; while (buf[i] && ' ' == buf[i]) i++; } - if (0 == buf[i]) { + if ('\0' == buf[i]) { *v = &buf[*pos]; if (' ' != buf[i - 1]) return(ARGS_PUNCT); @@ -441,7 +442,6 @@ args(struct mdoc *m, int line, int *pos, */ if (ARGS_TABSEP & fl) { - rc = ARGS_PHRASE; /* Scan ahead to tab (can't be escaped). */ p = strchr(*v, '\t'); @@ -455,20 +455,27 @@ args(struct mdoc *m, int line, int *pos, break; } + /* By default, assume a phrase. */ + rc = ARGS_PHRASE; + /* * Adjust new-buffer position to be beyond delimiter * mark (e.g., Ta -> end + 2). */ if (p && pp) { *pos += pp < p ? 2 : 1; + rc = pp < p ? ARGS_PHRASE : ARGS_PPHRASE; p = pp < p ? pp : p; } else if (p && ! pp) { + rc = ARGS_PPHRASE; *pos += 1; } else if (pp && ! p) { p = pp; *pos += 2; - } else + } else { + rc = ARGS_PEND; p = strchr(*v, 0); + } /* Whitespace check for eoln case... */ if (0 == *p && ' ' == *(p - 1) && ! (ARGS_NOWARN & fl)) @@ -662,16 +669,16 @@ static int argv_multi(struct mdoc *m, int line, struct mdoc_argv *v, int *pos, char *buf) { - int c; + enum margserr ac; char *p; for (v->sz = 0; ; v->sz++) { if ('-' == buf[*pos]) break; - c = args(m, line, pos, buf, 0, &p); - if (ARGS_ERROR == c) + ac = args(m, line, pos, buf, 0, &p); + if (ARGS_ERROR == ac) return(0); - else if (ARGS_EOLN == c) + else if (ARGS_EOLN == ac) break; if (0 == v->sz % MULTI_STEP) @@ -689,16 +696,16 @@ static int argv_opt_single(struct mdoc *m, int line, struct mdoc_argv *v, int *pos, char *buf) { - int c; + enum margserr ac; char *p; if ('-' == buf[*pos]) return(1); - c = args(m, line, pos, buf, 0, &p); - if (ARGS_ERROR == c) + ac = args(m, line, pos, buf, 0, &p); + if (ARGS_ERROR == ac) return(0); - if (ARGS_EOLN == c) + if (ARGS_EOLN == ac) return(1); v->sz = 1; @@ -716,15 +723,16 @@ static int argv_single(struct mdoc *m, int line, struct mdoc_argv *v, int *pos, char *buf) { - int c, ppos; + int ppos; + enum margserr ac; char *p; ppos = *pos; - c = args(m, line, pos, buf, 0, &p); - if (ARGS_ERROR == c) + ac = args(m, line, pos, buf, 0, &p); + if (ARGS_ERROR == ac) return(0); - if (ARGS_EOLN == c) + if (ARGS_EOLN == ac) return(mdoc_perr(m, line, ppos, EARGVAL)); v->sz = 1;