=================================================================== RCS file: /cvs/mandoc/mdoc_argv.c,v retrieving revision 1.40 retrieving revision 1.43 diff -u -p -r1.40 -r1.43 --- mandoc/mdoc_argv.c 2010/05/07 05:54:09 1.40 +++ mandoc/mdoc_argv.c 2010/05/08 07:30:19 1.43 @@ -1,4 +1,4 @@ -/* $Id: mdoc_argv.c,v 1.40 2010/05/07 05:54:09 kristaps Exp $ */ +/* $Id: mdoc_argv.c,v 1.43 2010/05/08 07:30:19 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -378,6 +378,7 @@ args(struct mdoc *m, int line, int *pos, { int i; char *p, *pp; + enum margserr rc; /* * Parse out the terms (like `val' in `.Xx -arg val' or simply @@ -397,7 +398,7 @@ args(struct mdoc *m, int line, int *pos, assert(*pos); assert(' ' != buf[*pos]); - if (0 == buf[*pos]) + if ('\0' == buf[*pos]) return(ARGS_EOLN); /* @@ -453,14 +454,19 @@ 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; @@ -488,7 +494,7 @@ args(struct mdoc *m, int line, int *pos, for (pp = &buf[*pos]; ' ' == *pp; pp++, (*pos)++) /* Skip ahead. */ ; - return(ARGS_PHRASE); + return(rc); } /* @@ -660,16 +666,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) @@ -687,16 +693,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; @@ -714,15 +720,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;