summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2011-02-10 00:06:31 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2011-02-10 00:06:31 +0000
commit1f3a1b3bfaa052785e1016eb2857e162281e0995 (patch)
tree2695ee1120d311219f9167403abe10b3c0cbec15
parent317c42ed06f8ffda5982d9e80ee6b5ead90b9e82 (diff)
Tbl code maintenance by kristaps@.
- Remember the line-number of a tbl_span, and use it in messages. - Put *_span_alloc() functions right into the *_addspan() ones, since these are the only places they are called from.
-rw-r--r--usr.bin/mandoc/man.c31
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/mdoc.c35
-rw-r--r--usr.bin/mandoc/tbl_data.c19
-rw-r--r--usr.bin/mandoc/tree.c9
5 files changed, 37 insertions, 60 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index dd39e73d8ef..ece070e374c 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.54 2011/01/16 02:56:47 schwarze Exp $ */
+/* $Id: man.c,v 1.55 2011/02/10 00:06:30 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -44,8 +44,6 @@ static struct man_node *man_node_alloc(struct man *, int, int,
enum man_type, enum mant);
static int man_node_append(struct man *,
struct man_node *);
-static int man_span_alloc(struct man *,
- const struct tbl_span *);
static void man_node_free(struct man_node *);
static void man_node_unlink(struct man *,
struct man_node *);
@@ -296,22 +294,6 @@ man_block_alloc(struct man *m, int line, int pos, enum mant tok)
return(1);
}
-static int
-man_span_alloc(struct man *m, const struct tbl_span *span)
-{
- struct man_node *n;
-
- /* FIXME: grab from span */
- n = man_node_alloc(m, 0, 0, MAN_TBL, MAN_MAX);
- n->span = span;
-
- if ( ! man_node_append(m, n))
- return(0);
-
- m->next = MAN_NEXT_SIBLING;
- return(1);
-}
-
int
man_word_alloc(struct man *m, int line, int pos, const char *word)
{
@@ -364,11 +346,18 @@ man_node_delete(struct man *m, struct man_node *p)
int
man_addspan(struct man *m, const struct tbl_span *sp)
{
+ struct man_node *n;
assert( ! (MAN_HALT & m->flags));
- if ( ! man_span_alloc(m, sp))
+
+ n = man_node_alloc(m, sp->line, 0, MAN_TBL, MAN_MAX);
+ n->span = sp;
+
+ if ( ! man_node_append(m, n))
return(0);
- return(man_descope(m, 0, 0));
+
+ m->next = MAN_NEXT_SIBLING;
+ return(man_descope(m, sp->line, 0));
}
static int
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 6165e156caf..32056ddaece 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.32 2011/02/06 17:33:20 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.33 2011/02/10 00:06:30 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -260,6 +260,7 @@ struct tbl_span {
struct tbl_row *layout; /* layout row */
struct tbl_dat *first;
struct tbl_dat *last;
+ int line; /* parse line */
int flags;
#define TBL_SPAN_FIRST (1 << 0)
#define TBL_SPAN_LAST (1 << 1)
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index a6b50af9e83..a89d82a4bf5 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.78 2011/01/09 13:16:48 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.79 2011/02/10 00:06:30 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -94,9 +94,6 @@ static int node_append(struct mdoc *,
struct mdoc_node *);
static int mdoc_ptext(struct mdoc *, int, char *, int);
static int mdoc_pmacro(struct mdoc *, int, char *, int);
-static int mdoc_span_alloc(struct mdoc *,
- const struct tbl_span *);
-
const struct mdoc_node *
mdoc_node(const struct mdoc *m)
@@ -223,18 +220,25 @@ mdoc_endparse(struct mdoc *m)
int
mdoc_addspan(struct mdoc *m, const struct tbl_span *sp)
{
+ struct mdoc_node *n;
assert( ! (MDOC_HALT & m->flags));
/* No text before an initial macro. */
if (SEC_NONE == m->lastnamed) {
- /* FIXME: grab from span. */
- mdoc_pmsg(m, 0, 0, MANDOCERR_NOTEXT);
+ mdoc_pmsg(m, sp->line, 0, MANDOCERR_NOTEXT);
return(1);
}
- return(mdoc_span_alloc(m, sp));
+ n = node_alloc(m, sp->line, 0, MDOC_MAX, MDOC_TBL);
+ n->span = sp;
+
+ if ( ! node_append(m, n))
+ return(0);
+
+ m->next = MDOC_NEXT_SIBLING;
+ return(1);
}
@@ -542,23 +546,6 @@ mdoc_elem_alloc(struct mdoc *m, int line, int pos,
return(1);
}
-static int
-mdoc_span_alloc(struct mdoc *m, const struct tbl_span *sp)
-{
- struct mdoc_node *n;
-
- /* FIXME: grab from tbl_span. */
- n = node_alloc(m, 0, 0, MDOC_MAX, MDOC_TBL);
- n->span = sp;
-
- if ( ! node_append(m, n))
- return(0);
-
- m->next = MDOC_NEXT_SIBLING;
- return(1);
-}
-
-
int
mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p)
{
diff --git a/usr.bin/mandoc/tbl_data.c b/usr.bin/mandoc/tbl_data.c
index 31ac487da90..d0fdb122743 100644
--- a/usr.bin/mandoc/tbl_data.c
+++ b/usr.bin/mandoc/tbl_data.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_data.c,v 1.8 2011/01/25 12:24:26 schwarze Exp $ */
+/* $Id: tbl_data.c,v 1.9 2011/02/10 00:06:30 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -25,10 +25,10 @@
#include "libmandoc.h"
#include "libroff.h"
-static int data(struct tbl_node *, struct tbl_span *,
- int, const char *, int *);
-static struct tbl_span *newspan(struct tbl_node *, struct tbl_row *);
-
+static int data(struct tbl_node *, struct tbl_span *,
+ int, const char *, int *);
+static struct tbl_span *newspan(struct tbl_node *, int,
+ struct tbl_row *);
static int
data(struct tbl_node *tbl, struct tbl_span *dp,
@@ -172,11 +172,12 @@ tbl_cdata(struct tbl_node *tbl, int ln, const char *p)
}
static struct tbl_span *
-newspan(struct tbl_node *tbl, struct tbl_row *rp)
+newspan(struct tbl_node *tbl, int line, struct tbl_row *rp)
{
struct tbl_span *dp;
dp = mandoc_calloc(1, sizeof(struct tbl_span));
+ dp->line = line;
dp->tbl = &tbl->opts;
dp->layout = rp;
dp->head = tbl->first_head;
@@ -222,11 +223,11 @@ tbl_data(struct tbl_node *tbl, int ln, const char *p)
rp && rp->first; rp = rp->next) {
switch (rp->first->pos) {
case (TBL_CELL_HORIZ):
- dp = newspan(tbl, rp);
+ dp = newspan(tbl, ln, rp);
dp->pos = TBL_SPAN_HORIZ;
continue;
case (TBL_CELL_DHORIZ):
- dp = newspan(tbl, rp);
+ dp = newspan(tbl, ln, rp);
dp->pos = TBL_SPAN_DHORIZ;
continue;
default:
@@ -244,7 +245,7 @@ tbl_data(struct tbl_node *tbl, int ln, const char *p)
assert(rp);
- dp = newspan(tbl, rp);
+ dp = newspan(tbl, ln, rp);
if ( ! strcmp(p, "_")) {
dp->pos = TBL_SPAN_HORIZ;
diff --git a/usr.bin/mandoc/tree.c b/usr.bin/mandoc/tree.c
index 5ad54dd2cb0..f66daad968e 100644
--- a/usr.bin/mandoc/tree.c
+++ b/usr.bin/mandoc/tree.c
@@ -1,4 +1,4 @@
-/* $Id: tree.c,v 1.12 2011/01/16 01:11:50 schwarze Exp $ */
+/* $Id: tree.c,v 1.13 2011/02/10 00:06:30 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -250,8 +250,6 @@ print_span(const struct tbl_span *sp, int indent)
for (i = 0; i < indent; i++)
putchar('\t');
- printf("tbl: ");
-
switch (sp->pos) {
case (TBL_SPAN_HORIZ):
putchar('-');
@@ -284,7 +282,8 @@ print_span(const struct tbl_span *sp, int indent)
if (NULL == dp->layout)
putchar('*');
putchar(']');
- if (dp->next)
- putchar(' ');
+ putchar(' ');
}
+
+ printf("(tbl) %d:1", sp->line);
}