summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-02 10:10:57 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-02 10:10:57 +0000
commit18bac1d9d98fd8bc679a1de9e741fb25e542062e (patch)
tree10e164afcd2ef05278dbcbe506f45444082d3a17
parent52b05cf7e6f8b28dfbdbbdbdbeb9fd3f45b32407 (diff)
downloadmandoc-18bac1d9d98fd8bc679a1de9e741fb25e542062e.tar.gz
Churn to get parts of 'struct tbl' visible from mandoc.h: rename the
existing 'struct tbl' as 'struct tbl_node', then move all option stuff into a 'struct tbl' in mandoc.h. This conflicted with a structure in chars.c, which was renamed.
-rw-r--r--chars.c22
-rw-r--r--libroff.h39
-rw-r--r--mandoc.h15
-rw-r--r--roff.c10
-rw-r--r--tbl.c36
-rw-r--r--tbl_data.c8
-rw-r--r--tbl_layout.c18
-rw-r--r--tbl_opts.c24
8 files changed, 89 insertions, 83 deletions
diff --git a/chars.c b/chars.c
index 5288abbe..b9f4b4fd 100644
--- a/chars.c
+++ b/chars.c
@@ -54,22 +54,22 @@ struct ln {
#include "chars.in"
-struct tbl {
+struct ctab {
enum chars type;
struct ln **htab;
};
static inline int match(const struct ln *,
const char *, size_t, int);
-static const struct ln *find(struct tbl *, const char *, size_t, int);
+static const struct ln *find(struct ctab *, const char *, size_t, int);
void
chars_free(void *arg)
{
- struct tbl *tab;
+ struct ctab *tab;
- tab = (struct tbl *)arg;
+ tab = (struct ctab *)arg;
free(tab->htab);
free(tab);
@@ -79,7 +79,7 @@ chars_free(void *arg)
void *
chars_init(enum chars type)
{
- struct tbl *tab;
+ struct ctab *tab;
struct ln **htab;
struct ln *pp;
int i, hash;
@@ -91,7 +91,7 @@ chars_init(enum chars type)
* (they're in-line re-ordered during lookup).
*/
- tab = malloc(sizeof(struct tbl));
+ tab = malloc(sizeof(struct ctab));
if (NULL == tab) {
perror(NULL);
exit((int)MANDOCLEVEL_SYSERR);
@@ -130,7 +130,7 @@ chars_spec2cp(void *arg, const char *p, size_t sz)
{
const struct ln *ln;
- ln = find((struct tbl *)arg, p, sz, CHARS_CHAR);
+ ln = find((struct ctab *)arg, p, sz, CHARS_CHAR);
if (NULL == ln)
return(-1);
return(ln->unicode);
@@ -145,7 +145,7 @@ chars_res2cp(void *arg, const char *p, size_t sz)
{
const struct ln *ln;
- ln = find((struct tbl *)arg, p, sz, CHARS_STRING);
+ ln = find((struct ctab *)arg, p, sz, CHARS_STRING);
if (NULL == ln)
return(-1);
return(ln->unicode);
@@ -160,7 +160,7 @@ chars_spec2str(void *arg, const char *p, size_t sz, size_t *rsz)
{
const struct ln *ln;
- ln = find((struct tbl *)arg, p, sz, CHARS_CHAR);
+ ln = find((struct ctab *)arg, p, sz, CHARS_CHAR);
if (NULL == ln)
return(NULL);
@@ -177,7 +177,7 @@ chars_res2str(void *arg, const char *p, size_t sz, size_t *rsz)
{
const struct ln *ln;
- ln = find((struct tbl *)arg, p, sz, CHARS_STRING);
+ ln = find((struct ctab *)arg, p, sz, CHARS_STRING);
if (NULL == ln)
return(NULL);
@@ -187,7 +187,7 @@ chars_res2str(void *arg, const char *p, size_t sz, size_t *rsz)
static const struct ln *
-find(struct tbl *tab, const char *p, size_t sz, int type)
+find(struct ctab *tab, const char *p, size_t sz, int type)
{
struct ln *pp, *prev;
struct ln **htab;
diff --git a/libroff.h b/libroff.h
index cef8d9bc..04998297 100644
--- a/libroff.h
+++ b/libroff.h
@@ -25,46 +25,35 @@ enum tbl_part {
TBL_PART_DATA /* creating data rows */
};
-struct tbl {
+struct tbl_node {
mandocmsg msg; /* status messages */
void *data; /* privdata for messages */
- enum tbl_part part;
- char tab; /* cell-separator */
- char decimal; /* decimal point */
int pos; /* invocation column */
int line; /* invocation line */
- int linesize;
- char delims[2];
- int opts;
-#define TBL_OPT_CENTRE (1 << 0)
-#define TBL_OPT_EXPAND (1 << 1)
-#define TBL_OPT_BOX (1 << 2)
-#define TBL_OPT_DBOX (1 << 3)
-#define TBL_OPT_ALLBOX (1 << 4)
-#define TBL_OPT_NOKEEP (1 << 5)
-#define TBL_OPT_NOSPACE (1 << 6)
+ enum tbl_part part;
+ struct tbl opts;
struct tbl_row *first_row;
struct tbl_row *last_row;
struct tbl_span *first_span;
struct tbl_span *last_span;
struct tbl_head *first_head;
struct tbl_head *last_head;
- struct tbl *next;
+ struct tbl_node *next;
};
#define TBL_MSG(tblp, type, line, col) \
(*(tblp)->msg)((type), (tblp)->data, (line), (col), NULL)
-struct tbl *tbl_alloc(int, int, void *, mandocmsg);
-void tbl_restart(int, int, struct tbl *);
-void tbl_free(struct tbl *);
-void tbl_reset(struct tbl *);
-enum rofferr tbl_read(struct tbl *, int, const char *, int);
-int tbl_option(struct tbl *, int, const char *);
-int tbl_layout(struct tbl *, int, const char *);
-int tbl_data(struct tbl *, int, const char *);
-const struct tbl_span *tbl_span(const struct tbl *);
-void tbl_end(struct tbl *);
+struct tbl_node *tbl_alloc(int, int, void *, mandocmsg);
+void tbl_restart(int, int, struct tbl_node *);
+void tbl_free(struct tbl_node *);
+void tbl_reset(struct tbl_node *);
+enum rofferr tbl_read(struct tbl_node *, int, const char *, int);
+int tbl_option(struct tbl_node *, int, const char *);
+int tbl_layout(struct tbl_node *, int, const char *);
+int tbl_data(struct tbl_node *, int, const char *);
+const struct tbl_span *tbl_span(const struct tbl_node *);
+void tbl_end(struct tbl_node *);
__END_DECLS
diff --git a/mandoc.h b/mandoc.h
index 5eba175d..8553a8dd 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -145,6 +145,21 @@ enum mandocerr {
MANDOCERR_MAX
};
+struct tbl {
+ char tab; /* cell-separator */
+ char decimal; /* decimal point */
+ int linesize;
+ char delims[2];
+ int opts;
+#define TBL_OPT_CENTRE (1 << 0)
+#define TBL_OPT_EXPAND (1 << 1)
+#define TBL_OPT_BOX (1 << 2)
+#define TBL_OPT_DBOX (1 << 3)
+#define TBL_OPT_ALLBOX (1 << 4)
+#define TBL_OPT_NOKEEP (1 << 5)
+#define TBL_OPT_NOSPACE (1 << 6)
+};
+
enum tbl_headt {
TBL_HEAD_DATA, /* plug in data from tbl_dat */
TBL_HEAD_VERT, /* vertical spacer */
diff --git a/roff.c b/roff.c
index 258de792..c84077b8 100644
--- a/roff.c
+++ b/roff.c
@@ -86,9 +86,9 @@ struct roff {
struct regset *regs; /* read/writable registers */
struct roffstr *first_string; /* user-defined strings & macros */
const char *current_string; /* value of last called user macro */
- struct tbl *first_tbl; /* first table parsed */
- struct tbl *last_tbl; /* last table parsed */
- struct tbl *tbl; /* current table being parsed */
+ struct tbl_node *first_tbl; /* first table parsed */
+ struct tbl_node *last_tbl; /* last table parsed */
+ struct tbl_node *tbl; /* current table being parsed */
};
struct roffnode {
@@ -301,7 +301,7 @@ roffnode_push(struct roff *r, enum rofft tok, const char *name,
static void
roff_free1(struct roff *r)
{
- struct tbl *t;
+ struct tbl_node *t;
while (r->first_tbl) {
t = r->first_tbl;
@@ -1152,7 +1152,7 @@ roff_T_(ROFF_ARGS)
static enum rofferr
roff_TS(ROFF_ARGS)
{
- struct tbl *t;
+ struct tbl_node *t;
if (r->tbl) {
(*r->msg)(MANDOCERR_SCOPEBROKEN, r->data, ln, ppos, NULL);
diff --git a/tbl.c b/tbl.c
index 732daa4c..57b8135b 100644
--- a/tbl.c
+++ b/tbl.c
@@ -25,14 +25,14 @@
#include "libmandoc.h"
#include "libroff.h"
-static void tbl_calc(struct tbl *);
-static void tbl_calc_data(struct tbl *, struct tbl_dat *);
+static void tbl_calc(struct tbl_node *);
+static void tbl_calc_data(struct tbl_node *, struct tbl_dat *);
static void tbl_calc_data_literal(struct tbl_dat *);
-static void tbl_calc_data_number(struct tbl *, struct tbl_dat *);
+static void tbl_calc_data_number(struct tbl_node *, struct tbl_dat *);
static void tbl_calc_data_spanner(struct tbl_dat *);
enum rofferr
-tbl_read(struct tbl *tbl, int ln, const char *p, int offs)
+tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs)
{
int len;
const char *cp;
@@ -69,25 +69,25 @@ tbl_read(struct tbl *tbl, int ln, const char *p, int offs)
return(tbl_data(tbl, ln, p) ? ROFF_TBL : ROFF_IGN);
}
-struct tbl *
+struct tbl_node *
tbl_alloc(int pos, int line, void *data, const mandocmsg msg)
{
- struct tbl *p;
+ struct tbl_node *p;
- p = mandoc_calloc(1, sizeof(struct tbl));
+ p = mandoc_calloc(1, sizeof(struct tbl_node));
p->line = line;
p->pos = pos;
p->data = data;
p->msg = msg;
p->part = TBL_PART_OPTS;
- p->tab = '\t';
- p->linesize = 12;
- p->decimal = '.';
+ p->opts.tab = '\t';
+ p->opts.linesize = 12;
+ p->opts.decimal = '.';
return(p);
}
void
-tbl_free(struct tbl *p)
+tbl_free(struct tbl_node *p)
{
struct tbl_row *rp;
struct tbl_cell *cp;
@@ -126,7 +126,7 @@ tbl_free(struct tbl *p)
}
void
-tbl_restart(int line, int pos, struct tbl *tbl)
+tbl_restart(int line, int pos, struct tbl_node *tbl)
{
tbl->part = TBL_PART_LAYOUT;
@@ -138,7 +138,7 @@ tbl_restart(int line, int pos, struct tbl *tbl)
}
const struct tbl_span *
-tbl_span(const struct tbl *tbl)
+tbl_span(const struct tbl_node *tbl)
{
assert(tbl);
@@ -146,7 +146,7 @@ tbl_span(const struct tbl *tbl)
}
void
-tbl_end(struct tbl *tbl)
+tbl_end(struct tbl_node *tbl)
{
if (NULL == tbl->first_span || NULL == tbl->first_span->first)
@@ -156,7 +156,7 @@ tbl_end(struct tbl *tbl)
}
static void
-tbl_calc(struct tbl *tbl)
+tbl_calc(struct tbl_node *tbl)
{
struct tbl_span *sp;
struct tbl_dat *dp;
@@ -193,7 +193,7 @@ tbl_calc(struct tbl *tbl)
}
static void
-tbl_calc_data(struct tbl *tbl, struct tbl_dat *data)
+tbl_calc_data(struct tbl_node *tbl, struct tbl_dat *data)
{
/*
@@ -237,7 +237,7 @@ tbl_calc_data_spanner(struct tbl_dat *data)
}
static void
-tbl_calc_data_number(struct tbl *tbl, struct tbl_dat *data)
+tbl_calc_data_number(struct tbl_node *tbl, struct tbl_dat *data)
{
int sz, d;
char *dp, pnt;
@@ -255,7 +255,7 @@ tbl_calc_data_number(struct tbl *tbl, struct tbl_dat *data)
assert(data->string);
sz = (int)strlen(data->string);
- pnt = tbl->decimal;
+ pnt = tbl->opts.decimal;
if (NULL == (dp = strchr(data->string, pnt)))
d = sz + 1;
diff --git a/tbl_data.c b/tbl_data.c
index 708a9ea6..9c59f6be 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -24,11 +24,11 @@
#include "libmandoc.h"
#include "libroff.h"
-static void data(struct tbl *, struct tbl_span *,
+static void data(struct tbl_node *, struct tbl_span *,
int, const char *, int *);
void
-data(struct tbl *tbl, struct tbl_span *dp,
+data(struct tbl_node *tbl, struct tbl_span *dp,
int ln, const char *p, int *pos)
{
struct tbl_dat *dat;
@@ -62,7 +62,7 @@ data(struct tbl *tbl, struct tbl_span *dp,
dp->last = dp->first = dat;
sv = *pos;
- while (p[*pos] && p[*pos] != tbl->tab)
+ while (p[*pos] && p[*pos] != tbl->opts.tab)
(*pos)++;
dat->string = mandoc_malloc(*pos - sv + 1);
@@ -85,7 +85,7 @@ data(struct tbl *tbl, struct tbl_span *dp,
}
int
-tbl_data(struct tbl *tbl, int ln, const char *p)
+tbl_data(struct tbl_node *tbl, int ln, const char *p)
{
struct tbl_span *dp;
struct tbl_row *rp;
diff --git a/tbl_layout.c b/tbl_layout.c
index f723aaee..ecb7e508 100644
--- a/tbl_layout.c
+++ b/tbl_layout.c
@@ -45,18 +45,18 @@ static const struct tbl_phrase keys[KEYS_MAX] = {
{ '|', TBL_CELL_VERT }
};
-static int mods(struct tbl *, struct tbl_cell *,
+static int mods(struct tbl_node *, struct tbl_cell *,
int, const char *, int *);
-static int cell(struct tbl *, struct tbl_row *,
+static int cell(struct tbl_node *, struct tbl_row *,
int, const char *, int *);
-static void row(struct tbl *, int, const char *, int *);
-static struct tbl_cell *cell_alloc(struct tbl *,
+static void row(struct tbl_node *, int, const char *, int *);
+static struct tbl_cell *cell_alloc(struct tbl_node *,
struct tbl_row *, enum tbl_cellt);
static void head_adjust(const struct tbl_cell *,
struct tbl_head *);
static int
-mods(struct tbl *tbl, struct tbl_cell *cp,
+mods(struct tbl_node *tbl, struct tbl_cell *cp,
int ln, const char *p, int *pos)
{
char buf[5];
@@ -154,7 +154,7 @@ mod:
}
static int
-cell(struct tbl *tbl, struct tbl_row *rp,
+cell(struct tbl_node *tbl, struct tbl_row *rp,
int ln, const char *p, int *pos)
{
int i;
@@ -197,7 +197,7 @@ cell(struct tbl *tbl, struct tbl_row *rp,
static void
-row(struct tbl *tbl, int ln, const char *p, int *pos)
+row(struct tbl_node *tbl, int ln, const char *p, int *pos)
{
struct tbl_row *rp;
@@ -248,7 +248,7 @@ cell:
}
int
-tbl_layout(struct tbl *tbl, int ln, const char *p)
+tbl_layout(struct tbl_node *tbl, int ln, const char *p)
{
int pos;
@@ -260,7 +260,7 @@ tbl_layout(struct tbl *tbl, int ln, const char *p)
}
static struct tbl_cell *
-cell_alloc(struct tbl *tbl, struct tbl_row *rp, enum tbl_cellt pos)
+cell_alloc(struct tbl_node *tbl, struct tbl_row *rp, enum tbl_cellt pos)
{
struct tbl_cell *p, *pp;
struct tbl_head *h, *hp;
diff --git a/tbl_opts.c b/tbl_opts.c
index aa407cad..6d546c0c 100644
--- a/tbl_opts.c
+++ b/tbl_opts.c
@@ -71,11 +71,13 @@ static const struct tbl_phrase keys[KEY_MAXKEYS] = {
{ "nospaces", TBL_OPT_NOSPACE, KEY_NOSPACE},
};
-static int arg(struct tbl *, int, const char *, int *, int);
-static void opt(struct tbl *, int, const char *, int *);
+static int arg(struct tbl_node *, int,
+ const char *, int *, int);
+static void opt(struct tbl_node *, int,
+ const char *, int *);
static int
-arg(struct tbl *tbl, int ln, const char *p, int *pos, int key)
+arg(struct tbl_node *tbl, int ln, const char *p, int *pos, int key)
{
int i;
char buf[KEY_MAXNUMSZ];
@@ -100,18 +102,18 @@ arg(struct tbl *tbl, int ln, const char *p, int *pos, int key)
switch (key) {
case (KEY_DELIM):
- if ('\0' == (tbl->delims[0] = p[(*pos)++])) {
+ if ('\0' == (tbl->opts.delims[0] = p[(*pos)++])) {
TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
return(0);
}
- if ('\0' == (tbl->delims[1] = p[(*pos)++])) {
+ if ('\0' == (tbl->opts.delims[1] = p[(*pos)++])) {
TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
return(0);
}
break;
case (KEY_TAB):
- if ('\0' != (tbl->tab = p[(*pos)++]))
+ if ('\0' != (tbl->opts.tab = p[(*pos)++]))
break;
TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
@@ -125,14 +127,14 @@ arg(struct tbl *tbl, int ln, const char *p, int *pos, int key)
if (i < KEY_MAXNUMSZ) {
buf[i] = '\0';
- tbl->linesize = atoi(buf);
+ tbl->opts.linesize = atoi(buf);
break;
}
(*tbl->msg)(MANDOCERR_TBL, tbl->data, ln, *pos, NULL);
return(0);
case (KEY_DPOINT):
- if ('\0' != (tbl->decimal = p[(*pos)++]))
+ if ('\0' != (tbl->opts.decimal = p[(*pos)++]))
break;
TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
@@ -152,7 +154,7 @@ arg(struct tbl *tbl, int ln, const char *p, int *pos, int key)
}
static void
-opt(struct tbl *tbl, int ln, const char *p, int *pos)
+opt(struct tbl_node *tbl, int ln, const char *p, int *pos)
{
int i, sv;
char buf[KEY_MAXNAME];
@@ -220,7 +222,7 @@ again: /*
*/
if (keys[i].key)
- tbl->opts |= keys[i].key;
+ tbl->opts.opts |= keys[i].key;
else if ( ! arg(tbl, ln, p, pos, keys[i].ident))
return;
@@ -240,7 +242,7 @@ again: /*
}
int
-tbl_option(struct tbl *tbl, int ln, const char *p)
+tbl_option(struct tbl_node *tbl, int ln, const char *p)
{
int pos;