diff --git a/src/bin/psql/crosstabview.c b/src/bin/psql/crosstabview.c new file mode 100644 index 6d13b57..c9e11c2 *** a/src/bin/psql/crosstabview.c --- b/src/bin/psql/crosstabview.c *************** printCrosstab(const PGresult *results, *** 203,209 **** * alignment is determined by PQftype(). Otherwise the contents are * made-up strings, so the alignment is 'l' */ ! if (PQnfields(results) == 3) { int colnum; /* column placed inside the grid */ /* --- 203,213 ---- * alignment is determined by PQftype(). Otherwise the contents are * made-up strings, so the alignment is 'l' */ ! if (PQnfields(results) == 2) ! { ! col_align = 'c'; ! } ! else if (PQnfields(results) == 3) { int colnum; /* column placed inside the grid */ /* diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c new file mode 100644 index b2f8c2b..6e2cc6e *** a/src/bin/psql/print.c --- b/src/bin/psql/print.c *************** print_aligned_text(const printTableConte *** 1042,1059 **** { /* spaces first */ fprintf(fout, "%*s", width_wrap[j] - chars_to_output, ""); - fputnbytes(fout, - (char *) (this_line->ptr + bytes_output[j]), - bytes_to_output); } ! else /* Left aligned cell */ { ! /* spaces second */ ! fputnbytes(fout, ! (char *) (this_line->ptr + bytes_output[j]), ! bytes_to_output); } bytes_output[j] += bytes_to_output; /* Do we have more text to wrap? */ --- 1042,1059 ---- { /* spaces first */ fprintf(fout, "%*s", width_wrap[j] - chars_to_output, ""); } ! else if (cont->aligns[j] == 'c') /* Center aligned cell */ { ! /* spaces first */ ! fprintf(fout, "%*s", ! (width_wrap[j] - chars_to_output) / 2, ""); } + fputnbytes(fout, + (char *) (this_line->ptr + bytes_output[j]), + bytes_to_output); + bytes_output[j] += bytes_to_output; /* Do we have more text to wrap? */ *************** print_aligned_text(const printTableConte *** 1083,1095 **** * If left-aligned, pad out remaining space if needed (not * last column, and/or wrap marks required). */ ! if (cont->aligns[j] != 'r') /* Left aligned cell */ { ! if (finalspaces || ! wrap[j] == PRINT_LINE_WRAP_WRAP || ! wrap[j] == PRINT_LINE_WRAP_NEWLINE) fprintf(fout, "%*s", ! width_wrap[j] - chars_to_output, ""); } /* Print right-hand wrap or newline mark */ --- 1083,1104 ---- * If left-aligned, pad out remaining space if needed (not * last column, and/or wrap marks required). */ ! if (finalspaces || ! wrap[j] == PRINT_LINE_WRAP_WRAP || ! wrap[j] == PRINT_LINE_WRAP_NEWLINE) { ! if (cont->aligns[j] == 'c') ! { ! /* last spaces */ fprintf(fout, "%*s", ! width_wrap[j] - chars_to_output ! - ((width_wrap[j] - chars_to_output) / 2 ), ""); ! } ! else if (cont->aligns[j] == 'l') ! { ! /* last spaces */ ! fprintf(fout, "%*s", width_wrap[j] - chars_to_output, ""); ! } } /* Print right-hand wrap or newline mark */ *************** html_escaped_print(const char *in, FILE *** 1778,1783 **** --- 1787,1805 ---- } } + /* + * Returns align value in html format + */ + static const char * + format_html_align_attr(char align) + { + if (align == 'r') + return "right"; + else if (align == 'c') + return "center"; + else + return "left"; + } static void print_html_text(const printTableContent *cont, FILE *fout) *************** print_html_text(const printTableContent *** 1830,1836 **** fputs("