version 1.30, 2011/01/05 15:37:23 |
version 1.32, 2011/01/08 17:16:48 |
Line 503 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
Line 503 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
const struct tbl *tp, const struct tbl_dat *dp) |
const struct tbl *tp, const struct tbl_dat *dp) |
{ |
{ |
int i; |
int i; |
size_t sz, psz, ssz, d; |
size_t sz, psz, ssz, d, max; |
char *cp; |
char *cp; |
const char *str; |
const char *str; |
char buf[2]; |
char buf[2]; |
|
|
/* TODO: use spacing modifier. */ |
|
|
|
/* |
/* |
* First calculate number width and decimal place (last + 1 for |
* First calculate number width and decimal place (last + 1 for |
* no-decimal numbers). If the stored decimal is subsequent |
* no-decimal numbers). If the stored decimal is subsequent |
Line 519 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
Line 517 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
* Finally, re-assign the stored values. |
* Finally, re-assign the stored values. |
*/ |
*/ |
|
|
str = ""; |
str = dp && dp->string ? dp->string : ""; |
if (dp->string) |
max = dp && dp->layout ? dp->layout->spacing : 0; |
str = dp->string; |
|
|
|
sz = (*tbl->slen)(str, tbl->arg); |
sz = (*tbl->slen)(str, tbl->arg); |
|
|
Line 530 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
Line 527 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
|
|
psz = (*tbl->slen)(buf, tbl->arg); |
psz = (*tbl->slen)(buf, tbl->arg); |
|
|
if (NULL != (cp = strchr(str, tp->decimal))) { |
if (NULL != (cp = strrchr(str, tp->decimal))) { |
buf[1] = '\0'; |
buf[1] = '\0'; |
for (ssz = 0, i = 0; cp != &str[i]; i++) { |
for (ssz = 0, i = 0; cp != &str[i]; i++) { |
buf[0] = str[i]; |
buf[0] = str[i]; |
Line 557 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
Line 554 tblcalc_number(struct rofftbl *tbl, struct roffcol *co |
|
col->width = sz; |
col->width = sz; |
if (d > col->decimal) |
if (d > col->decimal) |
col->decimal = d; |
col->decimal = d; |
|
|
|
/* Adjust for stipulated width. */ |
|
|
|
if (col->width < max) |
|
col->width = max; |
} |
} |
|
|
|
|