/* Print row after folding of columns has been done */
static void basic_print_row(int ncols, const struct rdata *cols,
int maxw, FILE *out)
{
const char *s;
int i, nsp, nz;
align_t al;
num_info n;
tblock output, *outp;
/* Print the content */
output.add("<TR>");
for (i=0; i<ncols; i++)
{
output.add("<TD>");
s=cols[i].data;
al=cols[i].w.align;
if (cols[i].w.dp_col>=0)
{
n=scan_num(s);
if (n.dot_pos!=-1)
{
nz=cols[i].w.dp_col-n.dot_pos;
if ((!n.has_sign) && (cols[i].w.has_sign))
{
/*
output.add("\\phantom{$-$");
if (nz>0)
{
while (nz--)
output.add('0');
}
output.add("}");
*/
}
else
{
if (n.has_sign)
nz++; // - does not count as a digit.
if (nz>0)
{
/*
output.add("\\phantom{");
while (nz--)
output.add('0');
output.add("}");
*/
}
}
if (n.has_sign)
{
/* Typeset the sign in math mode */
output.add(*s);
s++;
}
output.add(s);
if (nsp-cols[i].w.dp_col+n.dot_pos>0
&& cols[i].w.align!=ALIGN_LEFT)
output.add(""); /* was hfill */
al=ALIGN_DP;
}
}
switch(al)
{
case ALIGN_DP:
break;
case ALIGN_LEFT:
case ALIGN_CENTER:
case ALIGN_RIGHT:
output.add(s);
break;
/* Convert data to *TeX */
for (i=0; i<ncols; i++)
{
rd[i].w=dp[i].w;
if (dp[i].data==NULL)
{
rd[i].data=null_string; // Avoid complication of null in
// basic_print_row
continue; // Move on to next item
}
d=__html_do_map(dp[i].data);
if ((rd[i].data=strdup(*d))==NULL)
{
fprintf(stderr, "html_table::print_row: fatal alloca failure\n");
exit(1);
}
delete(d);
}
basic_print_row(ncols, rd, maxw, out); // Printing the rows is actually
// quite complex.
for (i=0; i<ncols; i++)
{
if (rd[i].data!=null_string)
free((void *) rd[i].data); // Free data
}
}
/* Returns NULL or text message */
const char *html_table::print_table(int wd, FILE *out, const int ruled)
{
int i,j;
struct rdata *d;
const struct col_info *col;
if ((d=(struct rdata *) alloca(cols*sizeof(struct rdata)))==NULL)
{
cerr<<"html_table::print_table alloca failute (fatal)\n";
return "[Table omitted due to lack of memory]";
}
if (cols==0 || rows==0)
{
fputs("[empty tabel ignored]\n", out);
return "[Ignored empty table]";
}
for (i=0, col=cdata; col!=NULL; i++, col=col->next)
d[i].w=find_width(rows, col->data);
if (ruled)
fputs("<TABLE BORDER=1>", out);
else
fputs("<TABLE>", out);
for (i=0; i<cols; i++)
{
switch(d[i].w.align)
{
default:
cerr<<"Alignment "<<d[i].w.align<<" unsupported\n";
/* Fall through */