\n", fout);
fprintf(fout, " ", opt_align[(i) % col_count] == 'r' ? "right" : "left");
! /* is string only whitespace? */
! if ((*ptr)[strspn(*ptr, " \t")] == '\0')
fputs(" ", fout);
+ else if ((opt_align[i % col_count] == 'r') && strlen(*ptr) != 0 &&
+ opt_numericsep != NULL && strlen(opt_numericsep) > 0)
+ {
+ char *my_cell = malloc(len_with_numericsep(*ptr));
+
+ if (!my_cell)
+ {
+ fprintf(stderr, _("out of memory\n"));
+ exit(EXIT_FAILURE);
+ }
+ strcpy(my_cell, *ptr);
+ format_numericsep(my_cell, opt_numericsep);
+ html_escaped_print(my_cell, fout);
+ free(my_cell);
+ }
else
html_escaped_print(*ptr, fout);
+
fputs(" | \n", fout);
if ((i + 1) % col_count == 0)
***************
*** 714,729 ****
static void
! print_html_vertical(const char *title, const char *const * headers,
! const char *const * cells, const char *const * footers,
! const char *opt_align, bool opt_barebones, unsigned short int opt_border,
! const char *opt_table_attr,
! FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
unsigned int record = 1;
! const char *const * ptr;
fprintf(fout, "\n", fout);
fprintf(fout, " ", opt_align[i % col_count] == 'r' ? "right" : "left");
! if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only
! * whitespace? */
fputs(" ", fout);
else
html_escaped_print(*ptr, fout);
fputs(" | \n \n", fout);
}
--- 940,966 ----
fputs("\n", fout);
fprintf(fout, " ", opt_align[i % col_count] == 'r' ? "right" : "left");
! /* is string only whitespace? */
! if ((*ptr)[strspn(*ptr, " \t")] == '\0')
fputs(" ", fout);
+ else if ((opt_align[i % col_count] == 'r') && strlen(*ptr) != 0 &&
+ opt_numericsep != NULL && strlen(opt_numericsep) > 0)
+ {
+ char *my_cell = malloc(len_with_numericsep(*ptr));
+
+ if (!my_cell)
+ {
+ fprintf(stderr, _("out of memory\n"));
+ exit(EXIT_FAILURE);
+ }
+ strcpy(my_cell, *ptr);
+ format_numericsep(my_cell, opt_numericsep);
+ html_escaped_print(my_cell, fout);
+ free(my_cell);
+ }
else
html_escaped_print(*ptr, fout);
+
fputs(" | \n \n", fout);
}
***************
*** 829,842 ****
static void
! print_latex_text(const char *title, const char *const * headers,
! const char *const * cells, const char *const * footers,
! const char *opt_align, bool opt_barebones, unsigned short int opt_border,
! FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const * ptr;
/* print title */
--- 1027,1040 ----
static void
! print_latex_text(const char *title, const char *const *headers,
! const char *const *cells, const char *const *footers,
! const char *opt_align, bool opt_barebones,
! unsigned short int opt_border, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const *ptr;
/* print title */
***************
*** 921,934 ****
static void
! print_latex_vertical(const char *title, const char *const * headers,
! const char *const * cells, const char *const * footers,
! const char *opt_align, bool opt_barebones, unsigned short int opt_border,
! FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const * ptr;
unsigned int record = 1;
(void) opt_align; /* currently unused parameter */
--- 1119,1132 ----
static void
! print_latex_vertical(const char *title, const char *const *headers,
! const char *const *cells, const char *const *footers,
! const char *opt_align, bool opt_barebones,
! unsigned short int opt_border, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const *ptr;
unsigned int record = 1;
(void) opt_align; /* currently unused parameter */
***************
*** 1027,1040 ****
static void
! print_troff_ms_text(const char *title, const char *const * headers,
! const char *const * cells, const char *const * footers,
! const char *opt_align, bool opt_barebones, unsigned short int opt_border,
! FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const * ptr;
/* print title */
--- 1225,1238 ----
static void
! print_troff_ms_text(const char *title, const char *const *headers,
! const char *const *cells, const char *const *footers,
! const char *opt_align, bool opt_barebones,
! unsigned short int opt_border, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const *ptr;
/* print title */
***************
*** 1111,1124 ****
static void
! print_troff_ms_vertical(const char *title, const char *const * headers,
! const char *const * cells, const char *const * footers,
! const char *opt_align, bool opt_barebones, unsigned short int opt_border,
! FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const * ptr;
unsigned int record = 1;
unsigned short current_format = 0; /* 0=none, 1=header, 2=body */
--- 1309,1322 ----
static void
! print_troff_ms_vertical(const char *title, const char *const *headers,
! const char *const *cells, const char *const *footers,
! const char *opt_align, bool opt_barebones,
! unsigned short int opt_border, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
! const char *const *ptr;
unsigned int record = 1;
unsigned short current_format = 0; /* 0=none, 1=header, 2=body */
***************
*** 1263,1271 ****
void
printTable(const char *title,
! const char *const * headers,
! const char *const * cells,
! const char *const * footers,
const char *align,
const printTableOpt *opt, FILE *fout, FILE *flog)
{
--- 1461,1469 ----
void
printTable(const char *title,
! const char *const *headers,
! const char *const *cells,
! const char *const *footers,
const char *align,
const printTableOpt *opt, FILE *fout, FILE *flog)
{
***************
*** 1298,1304 ****
int col_count = 0,
row_count = 0,
lines;
! const char *const * ptr;
/* rough estimate of columns and rows */
if (headers)
--- 1496,1502 ----
int col_count = 0,
row_count = 0,
lines;
! const char *const *ptr;
/* rough estimate of columns and rows */
if (headers)
***************
*** 1325,1362 ****
/* print the stuff */
if (flog)
! print_aligned_text(title, headers, cells, footers, align, opt->tuples_only, border, opt->encoding, flog);
switch (opt->format)
{
case PRINT_UNALIGNED:
if (use_expanded)
! print_unaligned_vertical(title, headers, cells, footers,
opt->fieldSep, opt->recordSep,
! opt->tuples_only, output);
else
! print_unaligned_text(title, headers, cells, footers,
opt->fieldSep, opt->recordSep,
! opt->tuples_only, output);
break;
case PRINT_ALIGNED:
if (use_expanded)
! print_aligned_vertical(title, headers, cells, footers,
! opt->tuples_only, border,
opt->encoding, output);
else
! print_aligned_text(title, headers, cells, footers,
! align, opt->tuples_only,
border, opt->encoding, output);
break;
case PRINT_HTML:
if (use_expanded)
! print_html_vertical(title, headers, cells, footers,
! align, opt->tuples_only,
border, opt->tableAttr, output);
else
print_html_text(title, headers, cells, footers,
! align, opt->tuples_only, border,
opt->tableAttr, output);
break;
case PRINT_LATEX:
--- 1523,1560 ----
/* print the stuff */
if (flog)
! print_aligned_text(title, headers, cells, footers, align, opt->tuples_only, opt->numericSep, border, opt->encoding, flog);
switch (opt->format)
{
case PRINT_UNALIGNED:
if (use_expanded)
! print_unaligned_vertical(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
! opt->tuples_only, opt->numericSep, output);
else
! print_unaligned_text(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
! opt->tuples_only, opt->numericSep, output);
break;
case PRINT_ALIGNED:
if (use_expanded)
! print_aligned_vertical(title, headers, cells, footers, align,
! opt->tuples_only, opt->numericSep, border,
opt->encoding, output);
else
! print_aligned_text(title, headers, cells, footers, align,
! opt->tuples_only, opt->numericSep,
border, opt->encoding, output);
break;
case PRINT_HTML:
if (use_expanded)
! print_html_vertical(title, headers, cells, footers, align,
! opt->tuples_only, opt->numericSep,
border, opt->tableAttr, output);
else
print_html_text(title, headers, cells, footers,
! align, opt->tuples_only, opt->numericSep, border,
opt->tableAttr, output);
break;
case PRINT_LATEX:
Index: src/bin/psql/print.h
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/print.h,v
retrieving revision 1.25
diff -c -c -r1.25 print.h
*** src/bin/psql/print.h 14 Jun 2005 02:57:41 -0000 1.25
--- src/bin/psql/print.h 10 Jul 2005 03:24:24 -0000
***************
*** 40,45 ****
--- 40,46 ----
char *fieldSep; /* field separator for unaligned text mode */
char *recordSep; /* record separator for unaligned text
* mode */
+ char *numericSep; /* numeric units separator */
char *tableAttr; /* attributes for HTML */
int encoding; /* character encoding */
bool normal_query; /* are we presenting the results of a