=================================================================== RCS file: /cvs/mandoc/Attic/argv.c,v retrieving revision 1.16 retrieving revision 1.20 diff -u -p -r1.16 -r1.20 --- mandoc/Attic/argv.c 2009/01/17 20:10:36 1.16 +++ mandoc/Attic/argv.c 2009/01/20 13:44:05 1.20 @@ -1,4 +1,4 @@ -/* $Id: argv.c,v 1.16 2009/01/17 20:10:36 kristaps Exp $ */ +/* $Id: argv.c,v 1.20 2009/01/20 13:44:05 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -25,6 +25,12 @@ #include "private.h" +/* + * Parse arguments and parameters of macros. Arguments follow the + * syntax of `-arg [val [valN...]]', while parameters are free-form text + * following arguments (if any). This file must correctly handle the + * strange punctuation rules dictated by groff. + */ /* FIXME: .It called with -column and quoted arguments. */ @@ -78,7 +84,8 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, char /* Parse routine for non-quoted string. */ - if ('\"' != buf[*pos]) { + assert(*pos > 0); + if ('\"' != buf[*pos] || ! (ARGS_QUOTED & fl)) { *v = &buf[*pos]; /* FIXME: UGLY tab-sep processing. */ @@ -98,9 +105,14 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, char } (*pos)++; } - else - while (buf[*pos] && ! isspace(buf[*pos])) + else { + while (buf[*pos]) { + if (isspace(buf[*pos])) + if ('\\' != buf[*pos - 1]) + break; (*pos)++; + } + } if (0 == buf[*pos]) return(ARGS_WORD); @@ -141,18 +153,18 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, char buf[(*pos)++] = 0; if (0 == buf[*pos]) - return(ARGS_WORD); + return(ARGS_QWORD); while (buf[*pos] && isspace(buf[*pos])) (*pos)++; if (buf[*pos]) - return(ARGS_WORD); + return(ARGS_QWORD); if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_COMPAT, "whitespace at end-of-line")) return(ARGS_ERROR); - return(ARGS_WORD); + return(ARGS_QWORD); } @@ -451,8 +463,13 @@ mdoc_argv(struct mdoc *mdoc, int line, int tok, v->line = line; v->pos = *pos; - while (buf[*pos] && ! isspace(buf[*pos])) + assert(*pos > 0); + while (buf[*pos]) { + if (isspace(buf[*pos])) + if ('\\' != buf[*pos - 1]) + break; (*pos)++; + } if (buf[*pos]) buf[(*pos)++] = 0;