Module Name: src
Committed By: joerg
Date: Fri Apr 15 13:47:18 UTC 2011
Modified Files:
src/external/bsd/mdocml/dist: man_term.c mdoc_term.c tbl.c tbl_layout.c
tbl_opts.c
Removed Files:
src/external/bsd/mdocml/dist: chars.h man.3 man_argv.c mdoc.3
mdoc_strings.c roff.3 roff.h
Log Message:
Merge for mdocml-1.11.1
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.5 -r0 src/external/bsd/mdocml/dist/chars.h \
src/external/bsd/mdocml/dist/man_argv.c
cvs rdiff -u -r1.1.1.6 -r0 src/external/bsd/mdocml/dist/man.3 \
src/external/bsd/mdocml/dist/mdoc.3
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/mdocml/dist/man_term.c \
src/external/bsd/mdocml/dist/mdoc_term.c
cvs rdiff -u -r1.1.1.9 -r0 src/external/bsd/mdocml/dist/mdoc_strings.c
cvs rdiff -u -r1.1.1.4 -r0 src/external/bsd/mdocml/dist/roff.3
cvs rdiff -u -r1.1.1.3 -r0 src/external/bsd/mdocml/dist/roff.h
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/mdocml/dist/tbl.c \
src/external/bsd/mdocml/dist/tbl_layout.c \
src/external/bsd/mdocml/dist/tbl_opts.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/mdocml/dist/man_term.c
diff -u src/external/bsd/mdocml/dist/man_term.c:1.6 src/external/bsd/mdocml/dist/man_term.c:1.7
--- src/external/bsd/mdocml/dist/man_term.c:1.6 Wed Jan 12 22:58:42 2011
+++ src/external/bsd/mdocml/dist/man_term.c Fri Apr 15 13:47:17 2011
@@ -1,6 +1,6 @@
-/* $Vendor-Id: man_term.c,v 1.94 2011/01/04 01:23:18 schwarze Exp $ */
+/* $Vendor-Id: man_term.c,v 1.105 2011/03/22 10:13:01 kristaps Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <[email protected]>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
* Copyright (c) 2010, 2011 Ingo Schwarze <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -31,7 +31,6 @@
#include "out.h"
#include "man.h"
#include "term.h"
-#include "chars.h"
#include "main.h"
#define INDENT 7
@@ -126,7 +125,7 @@
{ pre_I, NULL, 0 }, /* I */
{ pre_alternate, NULL, 0 }, /* IR */
{ pre_alternate, NULL, 0 }, /* RI */
- { NULL, NULL, MAN_NOTEXT }, /* na */
+ { pre_ign, NULL, MAN_NOTEXT }, /* na */
{ pre_sp, NULL, MAN_NOTEXT }, /* sp */
{ pre_literal, NULL, 0 }, /* nf */
{ pre_literal, NULL, 0 }, /* fi */
@@ -212,6 +211,9 @@
{
term_newln(p);
+ if (n->body && n->body->child && MAN_TBL == n->body->child->type)
+ return;
+
if (NULL == n->prev)
return;
@@ -255,7 +257,7 @@
else
mt->fl &= ~MANT_LITERAL;
- return(1);
+ return(0);
}
/* ARGSUSED */
@@ -397,6 +399,11 @@
else
p->offset = v;
+ /* Don't let this creep beyond the right margin. */
+
+ if (p->offset > p->rmargin)
+ p->offset = p->rmargin;
+
return(0);
}
@@ -850,20 +857,31 @@
size_t rm, rmax;
int c;
- c = 1;
-
switch (n->type) {
case(MAN_TEXT):
- if (0 == *n->string) {
+ /*
+ * If we have a blank line, output a vertical space.
+ * If we have a space as the first character, break
+ * before printing the line's data.
+ */
+ if ('\0' == *n->string) {
term_vspace(p);
- break;
- }
+ return;
+ } else if (' ' == *n->string && MAN_LINE & n->flags)
+ term_newln(p);
term_word(p, n->string);
- /* FIXME: this means that macro lines are munged! */
-
- if (MANT_LITERAL & mt->fl) {
+ /*
+ * If we're in a literal context, make sure that words
+ * togehter on the same line stay together. This is a
+ * POST-printing call, so we check the NEXT word. Since
+ * -man doesn't have nested macros, we don't need to be
+ * more specific than this.
+ */
+ if (MANT_LITERAL & mt->fl &&
+ (NULL == n->next ||
+ n->next->line > n->line)) {
rm = p->rmargin;
rmax = p->maxrmargin;
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
@@ -873,35 +891,40 @@
p->rmargin = rm;
p->maxrmargin = rmax;
}
- break;
+
+ if (MAN_EOS & n->flags)
+ p->flags |= TERMP_SENTENCE;
+ return;
+ case (MAN_EQN):
+ term_word(p, n->eqn->data);
+ return;
case (MAN_TBL):
+ /*
+ * Tables are preceded by a newline. Then process a
+ * table line, which will cause line termination,
+ */
if (TBL_SPAN_FIRST & n->span->flags)
term_newln(p);
term_tbl(p, n->span);
- break;
+ return;
default:
- if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
- term_fontrepl(p, TERMFONT_NONE);
- if (termacts[n->tok].pre)
- c = (*termacts[n->tok].pre)(p, mt, n, m);
break;
}
+ if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+ term_fontrepl(p, TERMFONT_NONE);
+
+ c = 1;
+ if (termacts[n->tok].pre)
+ c = (*termacts[n->tok].pre)(p, mt, n, m);
+
if (c && n->child)
print_man_nodelist(p, mt, n->child, m);
- switch (n->type) {
- case (MAN_TEXT):
- /* FALLTHROUGH */
- case (MAN_TBL):
- break;
- default:
- if (termacts[n->tok].post)
- (*termacts[n->tok].post)(p, mt, n, m);
- if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
- term_fontrepl(p, TERMFONT_NONE);
- break;
- }
+ if (termacts[n->tok].post)
+ (*termacts[n->tok].post)(p, mt, n, m);
+ if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+ term_fontrepl(p, TERMFONT_NONE);
if (MAN_EOS & n->flags)
p->flags |= TERMP_SENTENCE;
@@ -922,24 +945,18 @@
static void
print_man_foot(struct termp *p, const void *arg)
{
- char buf[DATESIZ];
const struct man_meta *meta;
meta = (const struct man_meta *)arg;
term_fontrepl(p, TERMFONT_NONE);
- if (meta->rawdate)
- strlcpy(buf, meta->rawdate, DATESIZ);
- else
- time2a(meta->date, buf, DATESIZ);
-
term_vspace(p);
term_vspace(p);
term_vspace(p);
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
- p->rmargin = p->maxrmargin - term_strlen(p, buf);
+ p->rmargin = p->maxrmargin - term_strlen(p, meta->date);
p->offset = 0;
/* term_strlen() can return zero. */
@@ -957,7 +974,7 @@
p->rmargin = p->maxrmargin;
p->flags &= ~TERMP_NOBREAK;
- term_word(p, buf);
+ term_word(p, meta->date);
term_flushln(p);
}
Index: src/external/bsd/mdocml/dist/mdoc_term.c
diff -u src/external/bsd/mdocml/dist/mdoc_term.c:1.6 src/external/bsd/mdocml/dist/mdoc_term.c:1.7
--- src/external/bsd/mdocml/dist/mdoc_term.c:1.6 Wed Jan 12 22:58:42 2011
+++ src/external/bsd/mdocml/dist/mdoc_term.c Fri Apr 15 13:47:18 2011
@@ -1,6 +1,6 @@
-/* $Vendor-Id: mdoc_term.c,v 1.208 2011/01/06 14:05:12 kristaps Exp $ */
+/* $Vendor-Id: mdoc_term.c,v 1.226 2011/04/04 16:27:03 kristaps Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <[email protected]>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
* Copyright (c) 2010 Ingo Schwarze <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -32,7 +32,6 @@
#include "out.h"
#include "term.h"
#include "mdoc.h"
-#include "chars.h"
#include "main.h"
#define INDENT 5
@@ -73,7 +72,6 @@
static void termp_bd_post(DECL_ARGS);
static void termp_bk_post(DECL_ARGS);
static void termp_bl_post(DECL_ARGS);
-static void termp_bx_post(DECL_ARGS);
static void termp_d1_post(DECL_ARGS);
static void termp_fo_post(DECL_ARGS);
static void termp_in_post(DECL_ARGS);
@@ -95,6 +93,7 @@
static int termp_bl_pre(DECL_ARGS);
static int termp_bold_pre(DECL_ARGS);
static int termp_bt_pre(DECL_ARGS);
+static int termp_bx_pre(DECL_ARGS);
static int termp_cd_pre(DECL_ARGS);
static int termp_d1_pre(DECL_ARGS);
static int termp_ex_pre(DECL_ARGS);
@@ -187,7 +186,7 @@
{ termp_quote_pre, termp_quote_post }, /* Bo */
{ termp_quote_pre, termp_quote_post }, /* Bq */
{ termp_xx_pre, NULL }, /* Bsx */
- { NULL, termp_bx_post }, /* Bx */
+ { termp_bx_pre, NULL }, /* Bx */
{ NULL, NULL }, /* Db */
{ NULL, NULL }, /* Dc */
{ termp_quote_pre, termp_quote_post }, /* Do */
@@ -312,20 +311,6 @@
memset(&npair, 0, sizeof(struct termpair));
npair.ppair = pair;
-
- switch (n->type) {
- case (MDOC_TEXT):
- term_word(p, n->string);
- break;
- case (MDOC_TBL):
- term_tbl(p, n->span);
- break;
- default:
- if (termacts[n->tok].pre && ENDBODY_NOT == n->end)
- chld = (*termacts[n->tok].pre)
- (p, &npair, m, n);
- break;
- }
/*
* Keeps only work until the end of a line. If a keep was
@@ -357,6 +342,34 @@
(n->parent && MDOC_SYNPRETTY & n->parent->flags)))
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
+ /*
+ * After the keep flags have been set up, we may now
+ * produce output. Note that some pre-handlers do so.
+ */
+
+ switch (n->type) {
+ case (MDOC_TEXT):
+ if (' ' == *n->string && MDOC_LINE & n->flags)
+ term_newln(p);
+ if (MDOC_DELIMC & n->flags)
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, n->string);
+ if (MDOC_DELIMO & n->flags)
+ p->flags |= TERMP_NOSPACE;
+ break;
+ case (MDOC_EQN):
+ term_word(p, n->eqn->data);
+ break;
+ case (MDOC_TBL):
+ term_tbl(p, n->span);
+ break;
+ default:
+ if (termacts[n->tok].pre && ENDBODY_NOT == n->end)
+ chld = (*termacts[n->tok].pre)
+ (p, &npair, m, n);
+ break;
+ }
+
if (chld && n->child)
print_mdoc_nodelist(p, &npair, m, n->child);
@@ -367,6 +380,8 @@
break;
case (MDOC_TBL):
break;
+ case (MDOC_EQN):
+ break;
default:
if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)
break;
@@ -401,7 +416,6 @@
static void
print_mdoc_foot(struct termp *p, const void *arg)
{
- char buf[DATESIZ], os[BUFSIZ];
const struct mdoc_meta *m;
m = (const struct mdoc_meta *)arg;
@@ -416,24 +430,21 @@
* SYSTEM DATE SYSTEM
*/
- time2a(m->date, buf, DATESIZ);
- strlcpy(os, m->os, BUFSIZ);
-
term_vspace(p);
p->offset = 0;
p->rmargin = (p->maxrmargin -
- term_strlen(p, buf) + term_len(p, 1)) / 2;
+ term_strlen(p, m->date) + term_len(p, 1)) / 2;
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
- term_word(p, os);
+ term_word(p, m->os);
term_flushln(p);
p->offset = p->rmargin;
- p->rmargin = p->maxrmargin - term_strlen(p, os);
+ p->rmargin = p->maxrmargin - term_strlen(p, m->os);
p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
- term_word(p, buf);
+ term_word(p, m->date);
term_flushln(p);
p->offset = p->rmargin;
@@ -441,7 +452,7 @@
p->flags &= ~TERMP_NOBREAK;
p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
- term_word(p, os);
+ term_word(p, m->os);
term_flushln(p);
p->offset = 0;
@@ -1149,7 +1160,8 @@
termp_ns_pre(DECL_ARGS)
{
- p->flags |= TERMP_NOSPACE;
+ if ( ! (MDOC_LINE & n->flags))
+ p->flags |= TERMP_NOSPACE;
return(1);
}
@@ -1171,25 +1183,30 @@
static int
termp_rv_pre(DECL_ARGS)
{
- const struct mdoc_node *nn;
+ int nchild;
term_newln(p);
term_word(p, "The");
- for (nn = n->child; nn; nn = nn->next) {
+ nchild = n->nchild;
+ for (n = n->child; n; n = n->next) {
term_fontpush(p, TERMFONT_BOLD);
- term_word(p, nn->string);
+ term_word(p, n->string);
term_fontpop(p);
+
p->flags |= TERMP_NOSPACE;
- if (nn->next && NULL == nn->next->next)
- term_word(p, "(), and");
- else if (nn->next)
- term_word(p, "(),");
- else
- term_word(p, "()");
+ term_word(p, "()");
+
+ if (nchild > 2 && n->next) {
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, ",");
+ }
+
+ if (n->next && NULL == n->next->next)
+ term_word(p, "and");
}
- if (n->child && n->child->next)
+ if (nchild > 1)
term_word(p, "functions return");
else
term_word(p, "function returns");
@@ -1212,31 +1229,34 @@
static int
termp_ex_pre(DECL_ARGS)
{
- const struct mdoc_node *nn;
+ int nchild;
+ term_newln(p);
term_word(p, "The");
- for (nn = n->child; nn; nn = nn->next) {
+ nchild = n->nchild;
+ for (n = n->child; n; n = n->next) {
term_fontpush(p, TERMFONT_BOLD);
- term_word(p, nn->string);
+ term_word(p, n->string);
term_fontpop(p);
- p->flags |= TERMP_NOSPACE;
- if (nn->next && NULL == nn->next->next)
- term_word(p, ", and");
- else if (nn->next)
+
+ if (nchild > 2 && n->next) {
+ p->flags |= TERMP_NOSPACE;
term_word(p, ",");
- else
- p->flags &= ~TERMP_NOSPACE;
+ }
+
+ if (n->next && NULL == n->next->next)
+ term_word(p, "and");
}
- if (n->child && n->child->next)
+ if (nchild > 1)
term_word(p, "utilities exit");
else
term_word(p, "utility exits");
term_word(p, "0 on success, and >0 if an error occurs.");
- p->flags |= TERMP_SENTENCE;
+ p->flags |= TERMP_SENTENCE;
return(0);
}
@@ -1276,31 +1296,33 @@
term_newln(p);
}
-
/* ARGSUSED */
static int
termp_xr_pre(DECL_ARGS)
{
- const struct mdoc_node *nn;
- if (NULL == n->child)
+ if (NULL == (n = n->child))
return(0);
- assert(MDOC_TEXT == n->child->type);
- nn = n->child;
+ assert(MDOC_TEXT == n->type);
+ term_word(p, n->string);
- term_word(p, nn->string);
- if (NULL == (nn = nn->next))
+ if (NULL == (n = n->next))
return(0);
+
p->flags |= TERMP_NOSPACE;
term_word(p, "(");
- term_word(p, nn->string);
+ p->flags |= TERMP_NOSPACE;
+
+ assert(MDOC_TEXT == n->type);
+ term_word(p, n->string);
+
+ p->flags |= TERMP_NOSPACE;
term_word(p, ")");
return(0);
}
-
/*
* This decides how to assert whitespace before any of the SYNOPSIS set
* of macros (which, as in the case of Ft/Fo and Ft/Fn, may contain
@@ -1514,30 +1536,43 @@
static int
termp_fn_pre(DECL_ARGS)
{
- const struct mdoc_node *nn;
+ int pretty;
+
+ pretty = MDOC_SYNPRETTY & n->flags;
synopsis_pre(p, n);
+ if (NULL == (n = n->child))
+ return(0);
+
+ assert(MDOC_TEXT == n->type);
term_fontpush(p, TERMFONT_BOLD);
- term_word(p, n->child->string);
+ term_word(p, n->string);
term_fontpop(p);
p->flags |= TERMP_NOSPACE;
term_word(p, "(");
+ p->flags |= TERMP_NOSPACE;
- for (nn = n->child->next; nn; nn = nn->next) {
+ for (n = n->next; n; n = n->next) {
+ assert(MDOC_TEXT == n->type);
term_fontpush(p, TERMFONT_UNDER);
- term_word(p, nn->string);
+ term_word(p, n->string);
term_fontpop(p);
- if (nn->next)
+ if (n->next) {
+ p->flags |= TERMP_NOSPACE;
term_word(p, ",");
+ }
}
+ p->flags |= TERMP_NOSPACE;
term_word(p, ")");
- if (MDOC_SYNPRETTY & n->flags)
+ if (pretty) {
+ p->flags |= TERMP_NOSPACE;
term_word(p, ";");
+ }
return(0);
}
@@ -1559,12 +1594,16 @@
term_word(p, nn->string);
term_fontpop(p);
- if (nn->next)
+ if (nn->next) {
+ p->flags |= TERMP_NOSPACE;
term_word(p, ",");
+ }
}
- if (n->child && n->next && n->next->tok == MDOC_Fa)
+ if (n->child && n->next && n->next->tok == MDOC_Fa) {
+ p->flags |= TERMP_NOSPACE;
term_word(p, ",");
+ }
return(0);
}
@@ -1672,13 +1711,27 @@
/* ARGSUSED */
-static void
-termp_bx_post(DECL_ARGS)
+static int
+termp_bx_pre(DECL_ARGS)
{
- if (n->child)
+ if (NULL != (n = n->child)) {
+ term_word(p, n->string);
p->flags |= TERMP_NOSPACE;
- term_word(p, "BSD");
+ term_word(p, "BSD");
+ } else {
+ term_word(p, "BSD");
+ return(0);
+ }
+
+ if (NULL != (n = n->next)) {
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, "-");
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, n->string);
+ }
+
+ return(0);
}
@@ -1687,6 +1740,7 @@
termp_xx_pre(DECL_ARGS)
{
const char *pp;
+ int flags;
pp = NULL;
switch (n->tok) {
@@ -1712,9 +1766,14 @@
break;
}
- assert(pp);
term_word(p, pp);
- return(1);
+ if (n->child) {
+ flags = p->flags;
+ p->flags |= TERMP_KEEP;
+ term_word(p, n->child->string);
+ p->flags = flags;
+ }
+ return(0);
}
@@ -1979,6 +2038,7 @@
} else if (MDOC_BODY == n->type) {
p->flags |= TERMP_NOSPACE;
term_word(p, "(");
+ p->flags |= TERMP_NOSPACE;
return(1);
}
@@ -2002,10 +2062,13 @@
if (MDOC_BODY != n->type)
return;
+ p->flags |= TERMP_NOSPACE;
term_word(p, ")");
- if (MDOC_SYNPRETTY & n->flags)
+ if (MDOC_SYNPRETTY & n->flags) {
+ p->flags |= TERMP_NOSPACE;
term_word(p, ";");
+ }
}
@@ -2079,6 +2142,7 @@
if (NULL == n->parent || MDOC_Rs != n->parent->tok)
return;
+ p->flags |= TERMP_NOSPACE;
if (NULL == n->next) {
term_word(p, ".");
p->flags |= TERMP_SENTENCE;
@@ -2115,6 +2179,7 @@
term_fontpop(p);
+ p->flags |= TERMP_NOSPACE;
term_word(p, ":");
term_fontpush(p, TERMFONT_BOLD);
@@ -2166,8 +2231,8 @@
* If we're in an `Rs' and there's a journal present, then quote
* us instead of underlining us (for disambiguation).
*/
- if (n->parent && MDOC_Rs == n->parent->tok &&
- n->parent->norm->Rs.child_J)
+ if (n->parent && MDOC_Rs == n->parent->tok &&
+ n->parent->norm->Rs.quote_T)
termp_quote_post(p, pair, m, n);
termp____post(p, pair, m, n);
@@ -2183,7 +2248,7 @@
* us instead of underlining us (for disambiguation).
*/
if (n->parent && MDOC_Rs == n->parent->tok &&
- n->parent->norm->Rs.child_J)
+ n->parent->norm->Rs.quote_T)
return(termp_quote_pre(p, pair, m, n));
term_fontpush(p, TERMFONT_UNDER);
Index: src/external/bsd/mdocml/dist/tbl.c
diff -u src/external/bsd/mdocml/dist/tbl.c:1.2 src/external/bsd/mdocml/dist/tbl.c:1.3
--- src/external/bsd/mdocml/dist/tbl.c:1.2 Thu Mar 3 14:53:01 2011
+++ src/external/bsd/mdocml/dist/tbl.c Fri Apr 15 13:47:18 2011
@@ -1,6 +1,7 @@
-/* $Vendor-Id: tbl.c,v 1.21 2011/01/04 15:02:00 kristaps Exp $ */
+/* $Vendor-Id: tbl.c,v 1.25 2011/04/04 23:04:38 kristaps Exp $ */
/*
- * Copyright (c) 2009, 2010 Kristaps Dzonsons <[email protected]>
+ * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
+ * Copyright (c) 2011 Ingo Schwarze <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -25,7 +26,6 @@
#include <time.h>
#include "mandoc.h"
-#include "roff.h"
#include "libmandoc.h"
#include "libroff.h"
@@ -70,15 +70,14 @@
}
struct tbl_node *
-tbl_alloc(int pos, int line, void *data, const mandocmsg msg)
+tbl_alloc(int pos, int line, struct mparse *parse)
{
struct tbl_node *p;
p = mandoc_calloc(1, sizeof(struct tbl_node));
p->line = line;
p->pos = pos;
- p->data = data;
- p->msg = msg;
+ p->parse = parse;
p->part = TBL_PART_OPTS;
p->opts.tab = '\t';
p->opts.linesize = 12;
@@ -129,22 +128,29 @@
tbl_restart(int line, int pos, struct tbl_node *tbl)
{
if (TBL_PART_CDATA == tbl->part)
- TBL_MSG(tbl, MANDOCERR_TBLBLOCK, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
+ tbl->line, tbl->pos, NULL);
tbl->part = TBL_PART_LAYOUT;
tbl->line = line;
tbl->pos = pos;
if (NULL == tbl->first_span || NULL == tbl->first_span->first)
- TBL_MSG(tbl, MANDOCERR_TBLNODATA, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse,
+ tbl->line, tbl->pos, NULL);
}
const struct tbl_span *
-tbl_span(const struct tbl_node *tbl)
+tbl_span(struct tbl_node *tbl)
{
+ struct tbl_span *span;
assert(tbl);
- return(tbl->last_span);
+ span = tbl->current_span ? tbl->current_span->next
+ : tbl->first_span;
+ if (span)
+ tbl->current_span = span;
+ return(span);
}
void
@@ -152,12 +158,14 @@
{
if (NULL == tbl->first_span || NULL == tbl->first_span->first)
- TBL_MSG(tbl, MANDOCERR_TBLNODATA, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse,
+ tbl->line, tbl->pos, NULL);
if (tbl->last_span)
tbl->last_span->flags |= TBL_SPAN_LAST;
if (TBL_PART_CDATA == tbl->part)
- TBL_MSG(tbl, MANDOCERR_TBLBLOCK, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
+ tbl->line, tbl->pos, NULL);
}
Index: src/external/bsd/mdocml/dist/tbl_layout.c
diff -u src/external/bsd/mdocml/dist/tbl_layout.c:1.2 src/external/bsd/mdocml/dist/tbl_layout.c:1.3
--- src/external/bsd/mdocml/dist/tbl_layout.c:1.2 Thu Mar 3 14:53:01 2011
+++ src/external/bsd/mdocml/dist/tbl_layout.c Fri Apr 15 13:47:18 2011
@@ -1,4 +1,4 @@
-/* $Vendor-Id: tbl_layout.c,v 1.13 2011/01/09 05:38:23 joerg Exp $ */
+/* $Vendor-Id: tbl_layout.c,v 1.18 2011/04/04 23:04:38 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <[email protected]>
*
@@ -104,7 +104,8 @@
(*pos)++;
goto mod;
}
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT,
+ tbl->parse, ln, *pos, NULL);
return(0);
}
@@ -121,12 +122,13 @@
/* No greater than 4 digits. */
if (4 == i) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
*pos += i;
- cp->spacing = atoi(buf);
+ cp->spacing = (size_t)atoi(buf);
goto mod;
/* NOTREACHED */
@@ -160,7 +162,8 @@
(*pos)--;
break;
default:
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
@@ -175,7 +178,8 @@
break;
}
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
@@ -193,7 +197,8 @@
break;
if (KEYS_MAX == i) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
@@ -201,11 +206,38 @@
/*
* If a span cell is found first, raise a warning and abort the
- * parse. FIXME: recover from this somehow?
+ * parse. If a span cell is found and the last layout element
+ * isn't a "normal" layout, bail.
+ *
+ * FIXME: recover from this somehow?
+ */
+
+ if (TBL_CELL_SPAN == c) {
+ if (NULL == rp->first) {
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
+ return(0);
+ } else if (rp->last)
+ switch (rp->last->pos) {
+ case (TBL_CELL_VERT):
+ case (TBL_CELL_DVERT):
+ case (TBL_CELL_HORIZ):
+ case (TBL_CELL_DHORIZ):
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
+ return(0);
+ default:
+ break;
+ }
+ }
+
+ /*
+ * If a vertical spanner is found, we may not be in the first
+ * row.
*/
- if (NULL == rp->first && TBL_CELL_SPAN == c) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ if (TBL_CELL_DOWN == c && rp == tbl->first_row) {
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos, NULL);
return(0);
}
@@ -223,7 +255,7 @@
if (rp->last && (TBL_CELL_VERT == c || TBL_CELL_DVERT == c) &&
(TBL_CELL_VERT == rp->last->pos ||
TBL_CELL_DVERT == rp->last->pos)) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos - 1, NULL);
return(0);
}
@@ -264,7 +296,8 @@
if ('.' == p[*pos]) {
tbl->part = TBL_PART_DATA;
if (NULL == tbl->first_row)
- TBL_MSG(tbl, MANDOCERR_TBLNOLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLNOLAYOUT, tbl->parse,
+ ln, *pos, NULL);
(*pos)++;
return;
}
Index: src/external/bsd/mdocml/dist/tbl_opts.c
diff -u src/external/bsd/mdocml/dist/tbl_opts.c:1.2 src/external/bsd/mdocml/dist/tbl_opts.c:1.3
--- src/external/bsd/mdocml/dist/tbl_opts.c:1.2 Thu Mar 3 14:53:01 2011
+++ src/external/bsd/mdocml/dist/tbl_opts.c Fri Apr 15 13:47:18 2011
@@ -1,4 +1,4 @@
-/* $Vendor-Id: tbl_opts.c,v 1.8 2011/01/09 05:38:23 joerg Exp $ */
+/* $Vendor-Id: tbl_opts.c,v 1.11 2011/04/04 23:04:38 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <[email protected]>
*
@@ -24,6 +24,7 @@
#include <string.h>
#include "mandoc.h"
+#include "libmandoc.h"
#include "libroff.h"
enum tbl_ident {
@@ -92,7 +93,8 @@
/* Arguments always begin with a parenthesis. */
if ('(' != p[*pos]) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
@@ -107,12 +109,14 @@
switch (key) {
case (KEY_DELIM):
if ('\0' == p[(*pos)++]) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
if ('\0' == p[(*pos)++]) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
break;
@@ -120,7 +124,8 @@
if ('\0' != (tbl->opts.tab = p[(*pos)++]))
break;
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
case (KEY_LINESIZE):
for (i = 0; i < KEY_MAXNUMSZ && p[*pos]; i++, (*pos)++) {
@@ -135,13 +140,14 @@
break;
}
- (*tbl->msg)(MANDOCERR_TBL, tbl->data, ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL);
return(0);
case (KEY_DPOINT):
if ('\0' != (tbl->opts.decimal = p[(*pos)++]))
break;
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
default:
abort();
@@ -153,7 +159,7 @@
if (')' == p[(*pos)++])
return(1);
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos - 1, NULL);
return(0);
}
@@ -192,7 +198,7 @@
/* Copy up to first non-alpha character. */
for (sv = *pos, i = 0; i < KEY_MAXNAME; i++, (*pos)++) {
- buf[i] = tolower((unsigned char)p[*pos]);
+ buf[i] = (char)tolower((unsigned char)p[*pos]);
if ( ! isalpha((unsigned char)buf[i]))
break;
}
@@ -200,7 +206,7 @@
/* Exit if buffer is empty (or overrun). */
if (KEY_MAXNAME == i || 0 == i) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL);
return;
}
@@ -239,7 +245,7 @@
*/
if (KEY_MAXKEYS == i)
- TBL_MSG(tbl, MANDOCERR_TBLOPT, ln, sv);
+ mandoc_msg(MANDOCERR_TBLOPT, tbl->parse, ln, sv, NULL);
goto again;
/* NOTREACHED */