-/* $Id: tbl_opts.c,v 1.18 2015/01/26 13:03:48 schwarze Exp $ */
+/* $Id: tbl_opts.c,v 1.24 2018/12/14 05:18:03 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
#include <string.h>
#include "mandoc.h"
+#include "tbl.h"
#include "libmandoc.h"
-#include "libroff.h"
+#include "tbl_int.h"
#define KEY_DPOINT 0
#define KEY_DELIM 1
switch (key) {
case KEY_DELIM:
- mandoc_msg(MANDOCERR_TBLEQN, tbl->parse, ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBLOPT_EQN,
+ ln, *pos, "%.*s", len, p + *pos);
want = 2;
break;
case KEY_TAB:
break;
default:
abort();
- /* NOTREACHED */
}
if (len == 0)
- mandoc_msg(MANDOCERR_TBLOPT_NOARG,
- tbl->parse, ln, *pos, keys[key].name);
+ mandoc_msg(MANDOCERR_TBLOPT_NOARG, ln, *pos,
+ "%s", keys[key].name);
else if (want && len != want)
- mandoc_vmsg(MANDOCERR_TBLOPT_ARGSZ,
- tbl->parse, ln, *pos, "%s want %d have %d",
- keys[key].name, want, len);
+ mandoc_msg(MANDOCERR_TBLOPT_ARGSZ, ln, *pos,
+ "%s want %d have %d", keys[key].name, want, len);
*pos += len;
if (p[*pos] == ')')
* and some options are followed by arguments.
*/
void
-tbl_option(struct tbl_node *tbl, int ln, const char *p)
+tbl_option(struct tbl_node *tbl, int ln, const char *p, int *offs)
{
int i, pos, len;
- pos = 0;
+ pos = *offs;
for (;;) {
while (p[pos] == ' ' || p[pos] == '\t' || p[pos] == ',')
pos++;
- if (p[pos] == ';')
+ if (p[pos] == ';') {
+ *offs = pos + 1;
return;
+ }
/* Parse one option name. */
len++;
if (len == 0) {
- mandoc_vmsg(MANDOCERR_TBLOPT_ALPHA,
- tbl->parse, ln, pos, "%c", p[pos]);
+ mandoc_msg(MANDOCERR_TBLOPT_ALPHA,
+ ln, pos, "%c", p[pos]);
pos++;
continue;
}
i++;
if (i == KEY_MAXKEYS) {
- mandoc_vmsg(MANDOCERR_TBLOPT_BAD, tbl->parse,
+ mandoc_msg(MANDOCERR_TBLOPT_BAD,
ln, pos, "%.*s", len, p + pos);
pos += len;
continue;