\n", fout);
fprintf(fout, " ", opt_align[(i) % col_count] == 'r' ? "right" : "left");
- if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only
- * whitespace? */
+ /* 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,16 +896,16 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
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)
+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,
+ char *opt_numericsep, 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;
+ 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? */
+ /* 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,14 +1027,14 @@ latex_escaped_print(const char *in, FILE *fout)
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)
+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;
+ const char *const *ptr;
/* print title */
@@ -921,14 +1119,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
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)
+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;
+ const char *const *ptr;
unsigned int record = 1;
(void) opt_align; /* currently unused parameter */
@@ -1027,14 +1225,14 @@ troff_ms_escaped_print(const char *in, FILE *fout)
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)
+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;
+ const char *const *ptr;
/* print title */
@@ -1111,14 +1309,14 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border,
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)
+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;
+ const char *const *ptr;
unsigned int record = 1;
unsigned short current_format = 0; /* 0=none, 1=header, 2=body */
@@ -1263,9 +1461,9 @@ PageOutput(int lines, unsigned short int pager)
void
printTable(const char *title,
- const char *const * headers,
- const char *const * cells,
- const char *const * footers,
+ const char *const *headers,
+ const char *const *cells,
+ const char *const *footers,
const char *align,
const printTableOpt *opt, FILE *fout, FILE *flog)
{
@@ -1298,7 +1496,7 @@ printTable(const char *title,
int col_count = 0,
row_count = 0,
lines;
- const char *const * ptr;
+ const char *const *ptr;
/* rough estimate of columns and rows */
if (headers)
@@ -1325,38 +1523,38 @@ printTable(const char *title,
/* print the stuff */
if (flog)
- print_aligned_text(title, headers, cells, footers, align, opt->tuples_only, border, opt->encoding, 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,
+ print_unaligned_vertical(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
- opt->tuples_only, output);
+ opt->tuples_only, opt->numericSep, output);
else
- print_unaligned_text(title, headers, cells, footers,
+ print_unaligned_text(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
- opt->tuples_only, output);
+ opt->tuples_only, opt->numericSep, output);
break;
case PRINT_ALIGNED:
if (use_expanded)
- print_aligned_vertical(title, headers, cells, footers,
- opt->tuples_only, border,
+ 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,
+ 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,
+ 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, border,
+ align, opt->tuples_only, opt->numericSep, border,
opt->tableAttr, output);
break;
case PRINT_LATEX:
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index 7dcc2657f1..f64f8ba0f8 100644
--- a/src/bin/psql/print.h
+++ b/src/bin/psql/print.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.25 2005/06/14 02:57:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.26 2005/07/10 03:46:13 momjian Exp $
*/
#ifndef PRINT_H
#define PRINT_H
@@ -40,6 +40,7 @@ typedef struct _printTableOpt
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