aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-04 13:14:26 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-04 13:14:26 +0000
commite1e53a5041474d08cef466b93f70aa52c798a0ae (patch)
tree19eaa1a9c8064fbb87c05e5b832814f02ef9d1d0
parent543980ff972d5b50a51593a306420bb65fbf6b61 (diff)
downloadmandoc-e1e53a5041474d08cef466b93f70aa52c798a0ae.tar.gz
mandoc-e1e53a5041474d08cef466b93f70aa52c798a0ae.tar.zst
mandoc-e1e53a5041474d08cef466b93f70aa52c798a0ae.zip
Fix spacing for tables to use term_len(). Also make term.c properly
recode ASCII_HYPHEN and ASCII_NBRSP before passing back for widths.
-rw-r--r--index.sgml11
-rw-r--r--tbl_term.c20
-rw-r--r--term.c8
3 files changed, 23 insertions, 16 deletions
diff --git a/index.sgml b/index.sgml
index 02f48d77..b401956a 100644
--- a/index.sgml
+++ b/index.sgml
@@ -331,10 +331,11 @@
version 1.10.9
</P>
<P>
- Table functionality (see the <A HREF="roff.7.html#x5c265453">roff</A> manual) has been
- merged from <A CLASS="external" HREF="http://tbl.bsd.lv">tbl.bsd.lv</A>. Many back-end
- fixes have also been implemented, primarily in argument handling (quoting) and <A
- HREF="man.7.html">man</A> documents.
+ Table functionality (see the <Q>TS</Q>, <Q>TE</Q>, and <Q>T&amp;</Q> macros in the <A
+ HREF="roff.7.html#x5c265453">roff</A> manual) has been merged from <A CLASS="external"
+ HREF="http://tbl.bsd.lv">tbl.bsd.lv</A>. Many back-end fixes have also been
+ implemented, primarily in argument handling (quoting) and <A HREF="man.7.html">man</A>
+ documents.
</P>
</DIV>
<DIV CLASS="news">
@@ -502,7 +503,7 @@
<TR>
<TD>
<DIV CLASS="foot">
- Copyright &#169; 2008&#8211;2010 Kristaps Dzonsons, $Date: 2011/01/04 10:29:41 $
+ Copyright &#169; 2008&#8211;2010 Kristaps Dzonsons, $Date: 2011/01/04 13:14:26 $
</DIV>
</TD>
</TR>
diff --git a/tbl_term.c b/tbl_term.c
index 97c9d392..d6c27668 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_term.c,v 1.7 2011/01/04 12:06:21 kristaps Exp $ */
+/* $Id: tbl_term.c,v 1.8 2011/01/04 13:14:26 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -206,9 +206,6 @@ tbl_hframe(struct termp *tp, const struct tbl_span *sp)
TBL_OPT_DBOX & sp->tbl->opts))
return;
- tp->flags |= TERMP_NONOSPACE;
- tp->flags |= TERMP_NOSPACE;
-
/*
* Print out the horizontal part of a frame or double frame. A
* double frame has an unbroken `-' outer line the width of the
@@ -465,7 +462,7 @@ tbl_calc_data(struct termp *tp, const struct tbl *tbl,
case (TBL_CELL_HORIZ):
/* FALLTHROUGH */
case (TBL_CELL_DHORIZ):
- tblp->width = 1;
+ tblp->width = term_len(tp, 1);
break;
case (TBL_CELL_LONG):
/* FALLTHROUGH */
@@ -536,7 +533,7 @@ tbl_calc_data_literal(struct termp *tp,
const struct tbl_dat *dp,
struct termp_tbl *tblp)
{
- int sz, bufsz;
+ int sz, bufsz, spsz;
/*
* Calculate our width and use the spacing, with a minimum
@@ -551,16 +548,19 @@ tbl_calc_data_literal(struct termp *tp,
case (TBL_CELL_LONG):
/* FALLTHROUGH */
case (TBL_CELL_CENTRE):
- bufsz = 2;
+ bufsz = term_len(tp, 2);
break;
default:
- bufsz = 1;
+ bufsz = term_len(tp, 1);
break;
}
+ spsz = 0;
if (dp->layout->spacing)
- bufsz = bufsz > dp->layout->spacing ?
- bufsz : dp->layout->spacing;
+ spsz = term_len(tp, dp->layout->spacing);
+
+ if (spsz)
+ bufsz = bufsz > spsz ? bufsz : spsz;
sz += bufsz;
if (tblp->width < sz)
diff --git a/term.c b/term.c
index d402968e..ba54c31d 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.175 2010/12/06 13:25:25 kristaps Exp $ */
+/* $Id: term.c,v 1.176 2011/01/04 13:14:26 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -677,6 +677,12 @@ term_strlen(const struct termp *p, const char *cp)
if (rhs)
for (i = 0; i < rsz; i++)
sz += (*p->width)(p, *rhs++);
+ } else if (ASCII_NBRSP == *cp) {
+ sz += (*p->width)(p, ' ');
+ cp++;
+ } else if (ASCII_HYPH == *cp) {
+ sz += (*p->width)(p, '-');
+ cp++;
} else
sz += (*p->width)(p, *cp++);