=================================================================== RCS file: /cvs/mandoc/Attic/argv.c,v retrieving revision 1.15 retrieving revision 1.19 diff -u -p -r1.15 -r1.19 --- mandoc/Attic/argv.c 2009/01/16 12:23:25 1.15 +++ mandoc/Attic/argv.c 2009/01/20 13:05:28 1.19 @@ -1,4 +1,4 @@ -/* $Id: argv.c,v 1.15 2009/01/16 12:23:25 kristaps Exp $ */ +/* $Id: argv.c,v 1.19 2009/01/20 13:05:28 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -25,11 +25,12 @@ #include "private.h" - /* FIXME: .It called with -column and quoted arguments. */ +/* FIXME: if arguments are quoted, they should not be later parsed for + * macros. */ static int lookup(int, const char *); -static int parse(struct mdoc *, int, int, +static int parse(struct mdoc *, int, struct mdoc_arg *, int *, char *); static int parse_single(struct mdoc *, int, struct mdoc_arg *, int *, char *); @@ -78,7 +79,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 +100,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 +148,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); } @@ -404,7 +411,7 @@ parse_single(struct mdoc *mdoc, int line, static int -parse(struct mdoc *mdoc, int line, int tok, +parse(struct mdoc *mdoc, int line, struct mdoc_arg *v, int *pos, char *buf) { @@ -451,8 +458,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; @@ -469,7 +481,7 @@ mdoc_argv(struct mdoc *mdoc, int line, int tok, /* FIXME: whitespace if no value. */ ppos = *pos; - if ( ! parse(mdoc, line, tok, v, pos, buf)) + if ( ! parse(mdoc, line, v, pos, buf)) return(ARGV_ERROR); if ( ! postparse(mdoc, line, v, ppos)) return(ARGV_ERROR);