-/* $Id: mdoc_argv.c,v 1.93 2014/04/23 21:06:41 schwarze Exp $ */
+/* $OpenBSD$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include <sys/types.h>
static enum margserr args(struct mdoc *, int, int *,
char *, enum argsflag, char **);
static int args_checkpunct(const char *, int);
-static int argv_multi(struct mdoc *, int,
+static void argv_multi(struct mdoc *, int,
struct mdoc_argv *, int *, char *);
-static int argv_single(struct mdoc *, int,
+static void argv_single(struct mdoc *, int,
struct mdoc_argv *, int *, char *);
static const enum argvflag argvflags[MDOC_ARG_MAX] = {
{ ARGSFL_NONE, NULL }, /* Nd */
{ ARGSFL_DELIM, NULL }, /* Nm */
{ ARGSFL_DELIM, NULL }, /* Op */
- { ARGSFL_NONE, NULL }, /* Ot */
+ { ARGSFL_DELIM, NULL }, /* Ot */
{ ARGSFL_DELIM, NULL }, /* Pa */
{ ARGSFL_NONE, args_Ex }, /* Rv */
{ ARGSFL_DELIM, NULL }, /* St */
{ ARGSFL_NONE, NULL }, /* Ek */
{ ARGSFL_NONE, NULL }, /* Bt */
{ ARGSFL_NONE, NULL }, /* Hf */
- { ARGSFL_NONE, NULL }, /* Fr */
+ { ARGSFL_DELIM, NULL }, /* Fr */
{ ARGSFL_NONE, NULL }, /* Ud */
{ ARGSFL_DELIM, NULL }, /* Lb */
{ ARGSFL_NONE, NULL }, /* Lp */
{ ARGSFL_DELIM, NULL }, /* Brc */
{ ARGSFL_NONE, NULL }, /* %C */
{ ARGSFL_NONE, NULL }, /* Es */
- { ARGSFL_NONE, NULL }, /* En */
+ { ARGSFL_DELIM, NULL }, /* En */
{ ARGSFL_DELIM, NULL }, /* Dx */
{ ARGSFL_NONE, NULL }, /* %Q */
{ ARGSFL_NONE, NULL }, /* br */
switch (argvflags[tmp.arg]) {
case ARGV_SINGLE:
- if ( ! argv_single(mdoc, line, &tmp, pos, buf))
- return(ARGV_ERROR);
+ argv_single(mdoc, line, &tmp, pos, buf);
break;
case ARGV_MULTI:
- if ( ! argv_multi(mdoc, line, &tmp, pos, buf))
- return(ARGV_ERROR);
+ argv_multi(mdoc, line, &tmp, pos, buf);
break;
case ARGV_NONE:
break;
* is unterminated.
*/
if (MDOC_PHRASELIT & mdoc->flags)
- mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE);
+ mandoc_msg(MANDOCERR_ARG_QUOTE,
+ mdoc->parse, line, *pos, NULL);
mdoc->flags &= ~MDOC_PHRASELIT;
return(ARGS_EOLN);
/* Whitespace check for eoln case... */
if ('\0' == *p && ' ' == *(p - 1))
- mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE);
+ mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse,
+ line, *pos, NULL);
*pos += (int)(p - *v);
if ('\0' == buf[*pos]) {
if (MDOC_PPHRASE & mdoc->flags)
return(ARGS_QWORD);
- mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE);
+ mandoc_msg(MANDOCERR_ARG_QUOTE,
+ mdoc->parse, line, *pos, NULL);
return(ARGS_QWORD);
}
(*pos)++;
if ('\0' == buf[*pos])
- mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE);
+ mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse,
+ line, *pos, NULL);
return(ARGS_QWORD);
}
return('\0' == buf[i]);
}
-static int
+static void
argv_multi(struct mdoc *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
char *p;
for (v->sz = 0; ; v->sz++) {
- if ('-' == buf[*pos])
+ if (buf[*pos] == '-')
break;
ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p);
- if (ARGS_ERROR == ac)
- return(0);
- else if (ARGS_EOLN == ac)
+ if (ac == ARGS_EOLN)
break;
- if (0 == v->sz % MULTI_STEP)
+ if (v->sz % MULTI_STEP == 0)
v->value = mandoc_reallocarray(v->value,
v->sz + MULTI_STEP, sizeof(char *));
v->value[(int)v->sz] = mandoc_strdup(p);
}
-
- return(1);
}
-static int
+static void
argv_single(struct mdoc *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
char *p;
ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p);
- if (ARGS_ERROR == ac)
- return(0);
- if (ARGS_EOLN == ac)
- return(1);
+ if (ac == ARGS_EOLN)
+ return;
v->sz = 1;
v->value = mandoc_malloc(sizeof(char *));
v->value[0] = mandoc_strdup(p);
-
- return(1);
}