-/* $Id: argv.c,v 1.14 2009/01/16 11:50:54 kristaps Exp $ */
+/* $Id: argv.c,v 1.17 2009/01/19 17:02:58 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
#include "private.h"
+/* FIXME: .It called with -column and quoted arguments. */
+
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 *);
/* 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. */
}
(*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);
static int
-parse(struct mdoc *mdoc, int line, int tok,
+parse(struct mdoc *mdoc, int line,
struct mdoc_arg *v, int *pos, char *buf)
{
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;
/* 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);