From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.rz.uni-karlsruhe.de (Debian-exim@smtp1.rz.uni-karlsruhe.de [129.13.185.217]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o9ELtVtB023530 for ; Thu, 14 Oct 2010 17:55:31 -0400 (EDT) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by smtp1.rz.uni-karlsruhe.de with esmtp (Exim 4.63 #1) id 1P6Vlq-000361-7f; Thu, 14 Oct 2010 23:55:30 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.71) (envelope-from ) id 1P6Vlq-0000zU-69 for tech@mdocml.bsd.lv; Thu, 14 Oct 2010 23:55:30 +0200 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1P6Vlq-0000Wo-5I for tech@mdocml.bsd.lv; Thu, 14 Oct 2010 23:55:30 +0200 Received: from schwarze by usta.de with local (Exim 4.71) (envelope-from ) id 1P6Vlq-0004jl-4F for tech@mdocml.bsd.lv; Thu, 14 Oct 2010 23:55:30 +0200 Date: Thu, 14 Oct 2010 23:55:30 +0200 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: integrate tbl into mandoc Message-ID: <20101014215530.GC30282@iris.usta.de> References: <20101013004622.GC18513@iris.usta.de> <20101014211831.GB30282@iris.usta.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101014211831.GB30282@iris.usta.de> User-Agent: Mutt/1.5.20 (2009-06-14) Hi, this one corrects alignment by using term_*len() functions. I guess not all details are 100% correct yet, but this will get us started with respect to alignment. It is cumulative to the last patch i sent just before. Yours, Ingo diff -Naur mandoc-tbl-term/man_term.c mandoc-tbl/man_term.c --- mandoc-tbl-term/man_term.c Thu Oct 14 22:49:10 2010 +++ mandoc-tbl/man_term.c Thu Oct 14 23:43:50 2010 @@ -838,7 +838,7 @@ if (MAN_BLOCK != n->type) return(0); - if ( ! tbl_close(n->data.TS, "", n->line)) + if ( ! tbl_close(p, n->data.TS, "", n->line)) return(0); tbl_write(p, n->data.TS); diff -Naur mandoc-tbl-term/tbl.c mandoc-tbl/tbl.c --- mandoc-tbl-term/tbl.c Thu Oct 14 22:50:44 2010 +++ mandoc-tbl/tbl.c Wed Oct 13 22:55:39 2010 @@ -90,7 +90,7 @@ int -tbl_close(struct tbl *tbl, const char *f, int ln) +tbl_close(struct termp *p, struct tbl *tbl, const char *f, int ln) { if (TBL_PART_DATA != tbl->part) @@ -98,7 +98,7 @@ if ( ! tbl_data_close(tbl, f, ln)) return(0); #if 1 - return(tbl_calc_term(tbl)); + return(tbl_calc_term(p, tbl)); #else return(tbl_calc_tree(tbl)); #endif diff -Naur mandoc-tbl-term/tbl.h mandoc-tbl/tbl.h --- mandoc-tbl-term/tbl.h Thu Oct 14 22:50:54 2010 +++ mandoc-tbl/tbl.h Wed Oct 13 22:53:55 2010 @@ -26,7 +26,7 @@ void tbl_reset(struct tbl *); int tbl_read(struct tbl *, const char *, int, const char *, int); -int tbl_close(struct tbl *, const char *, int); +int tbl_close(struct termp *, struct tbl *, const char *, int); int tbl_write(struct termp *, const struct tbl *); __END_DECLS diff -Naur mandoc-tbl-term/tbl_extern.h mandoc-tbl/tbl_extern.h --- mandoc-tbl-term/tbl_extern.h Thu Oct 14 23:00:42 2010 +++ mandoc-tbl/tbl_extern.h Wed Oct 13 22:56:31 2010 @@ -174,7 +174,7 @@ struct tbl_data *tbl_data_alloc(struct tbl_span *); int tbl_write_term(struct termp *, const struct tbl *); -int tbl_calc_term(struct tbl *); +int tbl_calc_term(struct termp *, struct tbl *); int tbl_write_tree(const struct tbl *); int tbl_calc_tree(struct tbl *); diff -Naur mandoc-tbl-term/tbl_term.c mandoc-tbl/tbl_term.c --- mandoc-tbl-term/tbl_term.c Thu Oct 14 23:28:00 2010 +++ mandoc-tbl/tbl_term.c Thu Oct 14 23:40:15 2010 @@ -29,10 +29,10 @@ /* FIXME: `n' modifier doesn't always do the right thing. */ /* FIXME: `n' modifier doesn't use the cell-spacing buffer. */ -static void calc_data(struct tbl_data *); -static void calc_data_literal(struct tbl_data *); -static void calc_data_number(struct tbl_data *); -static void calc_data_spanner(struct tbl_data *); +static void calc_data(struct termp *, struct tbl_data *); +static void calc_data_literal(struct termp *, struct tbl_data *); +static void calc_data_number(struct termp *, struct tbl_data *); +static void calc_data_spanner(struct termp *, struct tbl_data *); static inline void write_char(struct termp *, char, int); static void write_data(struct termp *, const struct tbl_data *, int); @@ -118,7 +118,7 @@ int -tbl_calc_term(struct tbl *tbl) +tbl_calc_term(struct termp *p, struct tbl *tbl) { struct tbl_span *span; struct tbl_data *data; @@ -136,7 +136,7 @@ if (TBL_DATA_NDHORIZ & span->flags) continue; TAILQ_FOREACH(data, &span->data, entries) - calc_data(data); + calc_data(p, data); } /* Calculate width as the simple spanner value. */ @@ -144,10 +144,10 @@ TAILQ_FOREACH(head, &tbl->head, entries) switch (head->pos) { case (TBL_HEAD_VERT): - head->width = 1; + head->width = term_len(p, 1); break; case (TBL_HEAD_DVERT): - head->width = 2; + head->width = term_len(p, 2); break; default: break; @@ -246,16 +246,16 @@ static void -calc_data_spanner(struct tbl_data *data) +calc_data_spanner(struct termp *p, struct tbl_data *data) { /* N.B., these are horiz spanners (not vert) so always 1. */ - data->cell->head->width = 1; + data->cell->head->width = term_len(p, 1); } static void -calc_data_number(struct tbl_data *data) +calc_data_number(struct termp *p, struct tbl_data *data) { int sz, d; char *dp, pnt; @@ -272,15 +272,14 @@ /* TODO: use spacing modifier. */ assert(data->string); - sz = (int)strlen(data->string); + sz = (int)term_strlen(p, data->string); pnt = data->span->tbl->decimal; - if (NULL == (dp = strchr(data->string, pnt))) - d = sz + 1; - else - d = (int)(dp - data->string) + 1; + dp = strchr(data->string, pnt); + d = dp ? sz - (int)term_strlen(p, dp) : sz; + d += term_len(p, 1); - sz += 2; + sz += term_len(p, 2); if (data->cell->head->decimal > d) { sz += data->cell->head->decimal - d; @@ -297,7 +296,7 @@ static void -calc_data_literal(struct tbl_data *data) +calc_data_literal(struct termp *p, struct tbl_data *data) { int sz, bufsz; @@ -308,7 +307,7 @@ */ assert(data->string); - sz = (int)strlen(data->string); + sz = (int)term_strlen(p, data->string); switch (data->cell->pos) { case (TBL_CELL_LONG): @@ -325,21 +324,21 @@ bufsz = bufsz > data->cell->spacing ? bufsz : data->cell->spacing; - sz += bufsz; + sz += term_len(p, bufsz); if (data->cell->head->width < sz) data->cell->head->width = sz; } static void -calc_data(struct tbl_data *data) +calc_data(struct termp *p, struct tbl_data *data) { switch (data->cell->pos) { case (TBL_CELL_HORIZ): /* FALLTHROUGH */ case (TBL_CELL_DHORIZ): - calc_data_spanner(data); + calc_data_spanner(p, data); break; case (TBL_CELL_LONG): /* FALLTHROUGH */ @@ -348,10 +347,10 @@ case (TBL_CELL_LEFT): /* FALLTHROUGH */ case (TBL_CELL_RIGHT): - calc_data_literal(data); + calc_data_literal(p, data); break; case (TBL_CELL_NUMBER): - calc_data_number(data); + calc_data_number(p, data); break; default: abort(); -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv