From 20fbc591274e3bc709ff1f06d4618f8429b49096 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 27 May 2012 17:59:23 +0000 Subject: Correct width of horizontal spans; relevant in case of centered or flush right text, for boxes, and when more columns follow the span. Issue found by sthen@ in the net/arp-scan(1) port manual. "Please check them in and I'll look into them later!" kristaps@ --- tbl_term.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tbl_term.c') diff --git a/tbl_term.c b/tbl_term.c index 644f6cec..64107fb7 100644 --- a/tbl_term.c +++ b/tbl_term.c @@ -1,7 +1,7 @@ -/* $Id: tbl_term.c,v 1.22 2012/05/27 17:54:54 schwarze Exp $ */ +/* $Id: tbl_term.c,v 1.23 2012/05/27 17:59:23 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons - * Copyright (c) 2011 Ingo Schwarze + * Copyright (c) 2011, 2012 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -337,11 +337,19 @@ static void tbl_literal(struct termp *tp, const struct tbl_dat *dp, const struct roffcol *col) { - size_t len, padl, padr; + struct tbl_head *hp; + size_t width, len, padl, padr; + int spans; assert(dp->string); len = term_strlen(tp, dp->string); - padr = col->width > len ? col->width - len : 0; + + hp = dp->layout->head->next; + width = col->width; + for (spans = dp->spans; spans--; hp = hp->next) + width += tp->tbl.cols[hp->ident].width + 3; + + padr = width > len ? width - len : 0; padl = 0; switch (dp->layout->pos) { -- cgit v1.2.3-56-ge451