aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/command.c14
-rw-r--r--src/bin/psql/help.c4
-rw-r--r--src/bin/psql/print.c131
-rw-r--r--src/bin/psql/print.h4
4 files changed, 77 insertions, 76 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 0c4db123db5..6e5730e4436 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.149 2005/07/14 08:42:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.150 2005/07/18 20:57:53 momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -1420,16 +1420,16 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
: _("Expanded display is off.\n"));
}
- /* numeric separators */
- else if (strcmp(param, "numericsep") == 0)
+ /* locale-aware numeric output */
+ else if (strcmp(param, "numericlocale") == 0)
{
- popt->topt.numericSep = !popt->topt.numericSep;
+ popt->topt.numericLocale = !popt->topt.numericLocale;
if (!quiet)
{
- if (popt->topt.numericSep)
- puts(_("Showing numeric separators."));
+ if (popt->topt.numericLocale)
+ puts(_("Showing locale-adjusted numeric output."));
else
- puts(_("Numeric separators are off."));
+ puts(_("Locale-adjusted numeric output is off."));
}
}
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 1d24cffd02a..7d6cc7e4a08 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.104 2005/07/10 03:46:13 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.105 2005/07/18 20:57:53 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -239,7 +239,7 @@ slashUsage(unsigned short int pager)
fprintf(output, _(" \\pset NAME [VALUE]\n"
" set table output option\n"
" (NAME := {format|border|expanded|fieldsep|footer|null|\n"
- " numericsep|recordsep|tuples_only|title|tableattr|pager})\n"));
+ " numericlocale|recordsep|tuples_only|title|tableattr|pager})\n"));
fprintf(output, _(" \\t show only rows (currently %s)\n"),
ON(pset.popt.topt.tuples_only));
fprintf(output, _(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n"));
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 25d08a81c03..9a1db45d5c3 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.71 2005/07/18 19:27:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.72 2005/07/18 20:57:53 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -62,8 +62,9 @@ integer_digits(const char *my_str)
return strlen(my_str) - frac_len;
}
+/* Return additional length required for locale-aware numeric output */
static int
-len_numericseps(const char *my_str)
+additional_numeric_locale_len(const char *my_str)
{
int int_len = integer_digits(my_str), len = 0;
int groupdigits = atoi(grouping);
@@ -80,13 +81,13 @@ len_numericseps(const char *my_str)
}
static int
-len_with_numericsep(const char *my_str)
+strlen_with_numeric_locale(const char *my_str)
{
- return strlen(my_str) + len_numericseps(my_str);
+ return strlen(my_str) + additional_numeric_locale_len(my_str);
}
static void
-format_numericsep(char *my_str)
+format_numeric_locale(char *my_str)
{
int i, j, int_len = integer_digits(my_str), leading_digits;
int groupdigits = atoi(grouping);
@@ -95,7 +96,7 @@ format_numericsep(char *my_str)
if (my_str[0] == '-')
my_str++;
- new_str = pg_local_malloc(len_with_numericsep(my_str) + 1);
+ new_str = pg_local_malloc(strlen_with_numeric_locale(my_str) + 1);
leading_digits = (int_len % groupdigits != 0) ?
int_len % groupdigits : groupdigits;
@@ -143,7 +144,7 @@ print_unaligned_text(const char *title, const char *const *headers,
const char *const *cells, const char *const *footers,
const char *opt_align, const char *opt_fieldsep,
const char *opt_recordsep, bool opt_tuples_only,
- bool opt_numericsep, FILE *fout)
+ bool opt_numeric_locale, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
@@ -182,12 +183,12 @@ print_unaligned_text(const char *title, const char *const *headers,
fputs(opt_recordsep, fout);
need_recordsep = false;
}
- if (opt_align[i % col_count] == 'r' && opt_numericsep)
+ if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
fputs(my_cell, fout);
free(my_cell);
}
@@ -227,7 +228,7 @@ print_unaligned_vertical(const char *title, const char *const *headers,
const char *const *cells,
const char *const *footers, const char *opt_align,
const char *opt_fieldsep, const char *opt_recordsep,
- bool opt_tuples_only, bool opt_numericsep, FILE *fout)
+ bool opt_tuples_only, bool opt_numeric_locale, FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
@@ -258,12 +259,12 @@ print_unaligned_vertical(const char *title, const char *const *headers,
fputs(headers[i % col_count], fout);
fputs(opt_fieldsep, fout);
- if (opt_align[i % col_count] == 'r' && opt_numericsep)
+ if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
fputs(my_cell, fout);
free(my_cell);
}
@@ -331,7 +332,7 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths,
static void
print_aligned_text(const char *title, const char *const *headers,
const char *const *cells, const char *const *footers,
- const char *opt_align, bool opt_tuples_only, bool opt_numericsep,
+ const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale,
unsigned short int opt_border, int encoding,
FILE *fout)
{
@@ -398,14 +399,14 @@ print_aligned_text(const char *title, const char *const *headers,
for (i = 0, ptr = cells; *ptr; ptr++, i++)
{
- int numericseps;
+ int numeric_locale_len;
- if (opt_align[i % col_count] == 'r' && opt_numericsep)
- numericseps = len_numericseps(*ptr);
+ if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
+ numeric_locale_len = additional_numeric_locale_len(*ptr);
else
- numericseps = 0;
+ numeric_locale_len = 0;
- tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr), encoding) + numericseps;
+ tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr), encoding) + numeric_locale_len;
if (tmp > widths[i % col_count])
widths[i % col_count] = tmp;
cell_w[i] = tmp;
@@ -485,12 +486,12 @@ print_aligned_text(const char *title, const char *const *headers,
/* content */
if (opt_align[i % col_count] == 'r')
{
- if (opt_numericsep)
+ if (opt_numeric_locale)
{
char *my_cell = pg_local_malloc(cell_w[i] + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
fprintf(fout, "%*s%s", widths[i % col_count] - cell_w[i], "", my_cell);
free(my_cell);
}
@@ -552,7 +553,7 @@ static void
print_aligned_vertical(const char *title, const char *const *headers,
const char *const *cells, const char *const *footers,
const char *opt_align, bool opt_tuples_only,
- bool opt_numericsep, unsigned short int opt_border,
+ bool opt_numeric_locale, unsigned short int opt_border,
int encoding, FILE *fout)
{
unsigned int col_count = 0;
@@ -615,14 +616,14 @@ print_aligned_vertical(const char *title, const char *const *headers,
/* find longest data cell */
for (i = 0, ptr = cells; *ptr; ptr++, i++)
{
- int numericseps;
+ int numeric_locale_len;
- if (opt_align[i % col_count] == 'r' && opt_numericsep)
- numericseps = len_numericseps(*ptr);
+ if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
+ numeric_locale_len = additional_numeric_locale_len(*ptr);
else
- numericseps = 0;
+ numeric_locale_len = 0;
- tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr), encoding) + numericseps;
+ tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr), encoding) + numeric_locale_len;
if (tmp > dwidth)
dwidth = tmp;
cell_w[i] = tmp;
@@ -700,8 +701,8 @@ print_aligned_vertical(const char *title, const char *const *headers,
char *my_cell = pg_local_malloc(cell_w[i] + 1);
strcpy(my_cell, *ptr);
- if (opt_align[i % col_count] == 'r' && opt_numericsep)
- format_numericsep(my_cell);
+ if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
+ format_numeric_locale(my_cell);
if (opt_border < 2)
puts(my_cell);
else
@@ -788,7 +789,7 @@ static void
print_html_text(const char *title, const char *const *headers,
const char *const *cells, const char *const *footers,
const char *opt_align, bool opt_tuples_only,
- bool opt_numericsep, unsigned short int opt_border,
+ bool opt_numeric_locale, unsigned short int opt_border,
const char *opt_table_attr, FILE *fout)
{
unsigned int col_count = 0;
@@ -834,12 +835,12 @@ print_html_text(const char *title, const char *const *headers,
/* is string only whitespace? */
if ((*ptr)[strspn(*ptr, " \t")] == '\0')
fputs("&nbsp; ", fout);
- else if (opt_align[i % col_count] == 'r' && opt_numericsep)
+ else if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
html_escaped_print(my_cell, fout);
free(my_cell);
}
@@ -875,7 +876,7 @@ 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_tuples_only,
- bool opt_numericsep, unsigned short int opt_border,
+ bool opt_numeric_locale, unsigned short int opt_border,
const char *opt_table_attr, FILE *fout)
{
unsigned int col_count = 0;
@@ -919,12 +920,12 @@ print_html_vertical(const char *title, const char *const *headers,
/* is string only whitespace? */
if ((*ptr)[strspn(*ptr, " \t")] == '\0')
fputs("&nbsp; ", fout);
- else if (opt_align[i % col_count] == 'r' && opt_numericsep)
+ else if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
html_escaped_print(my_cell, fout);
free(my_cell);
}
@@ -1000,7 +1001,7 @@ 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_tuples_only,
- bool opt_numericsep, unsigned short int opt_border,
+ bool opt_numeric_locale, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
@@ -1061,12 +1062,12 @@ print_latex_text(const char *title, const char *const *headers,
/* print cells */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
- if (opt_numericsep)
+ if (opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
latex_escaped_print(my_cell, fout);
free(my_cell);
}
@@ -1103,7 +1104,7 @@ 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_tuples_only,
- bool opt_numericsep, unsigned short int opt_border,
+ bool opt_numeric_locale, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
@@ -1174,12 +1175,12 @@ print_latex_vertical(const char *title, const char *const *headers,
if (footers && !opt_tuples_only)
for (ptr = footers; *ptr; ptr++)
{
- if (opt_numericsep)
+ if (opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
latex_escaped_print(my_cell, fout);
free(my_cell);
}
@@ -1220,7 +1221,7 @@ 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_tuples_only,
- bool opt_numericsep, unsigned short int opt_border,
+ bool opt_numeric_locale, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
@@ -1274,12 +1275,12 @@ print_troff_ms_text(const char *title, const char *const *headers,
/* print cells */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
- if (opt_numericsep)
+ if (opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
troff_ms_escaped_print(my_cell, fout);
free(my_cell);
}
@@ -1313,7 +1314,7 @@ 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_tuples_only,
- bool opt_numericsep, unsigned short int opt_border,
+ bool opt_numeric_locale, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
@@ -1386,12 +1387,12 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
troff_ms_escaped_print(headers[i % col_count], fout);
fputc('\t', fout);
- if (opt_numericsep)
+ if (opt_numeric_locale)
{
- char *my_cell = pg_local_malloc(len_with_numericsep(*ptr) + 1);
+ char *my_cell = pg_local_malloc(strlen_with_numeric_locale(*ptr) + 1);
strcpy(my_cell, *ptr);
- format_numericsep(my_cell);
+ format_numeric_locale(my_cell);
troff_ms_escaped_print(my_cell, fout);
free(my_cell);
}
@@ -1533,7 +1534,7 @@ printTable(const char *title,
/* print the stuff */
if (flog)
- print_aligned_text(title, headers, cells, footers, align, opt->tuples_only, opt->numericSep, border, opt->encoding, flog);
+ print_aligned_text(title, headers, cells, footers, align, opt->tuples_only, opt->numericLocale, border, opt->encoding, flog);
switch (opt->format)
{
@@ -1541,50 +1542,50 @@ printTable(const char *title,
if (use_expanded)
print_unaligned_vertical(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
- opt->tuples_only, opt->numericSep, output);
+ opt->tuples_only, opt->numericLocale, output);
else
print_unaligned_text(title, headers, cells, footers, align,
opt->fieldSep, opt->recordSep,
- opt->tuples_only, opt->numericSep, output);
+ opt->tuples_only, opt->numericLocale, output);
break;
case PRINT_ALIGNED:
if (use_expanded)
print_aligned_vertical(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericSep, border,
+ opt->tuples_only, opt->numericLocale, border,
opt->encoding, output);
else
print_aligned_text(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericSep,
+ opt->tuples_only, opt->numericLocale,
border, opt->encoding, output);
break;
case PRINT_HTML:
if (use_expanded)
print_html_vertical(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericSep,
+ opt->tuples_only, opt->numericLocale,
border, opt->tableAttr, output);
else
print_html_text(title, headers, cells, footers,
- align, opt->tuples_only, opt->numericSep, border,
+ align, opt->tuples_only, opt->numericLocale, border,
opt->tableAttr, output);
break;
case PRINT_LATEX:
if (use_expanded)
print_latex_vertical(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericSep,
+ opt->tuples_only, opt->numericLocale,
border, output);
else
print_latex_text(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericSep,
+ opt->tuples_only, opt->numericLocale,
border, output);
break;
case PRINT_TROFF_MS:
if (use_expanded)
print_troff_ms_vertical(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericSep,
+ opt->tuples_only, opt->numericLocale,
border, output);
else
print_troff_ms_text(title, headers, cells, footers, align,
- opt->tuples_only, opt->numericSep,
+ opt->tuples_only, opt->numericLocale,
border, output);
break;
default:
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index bb23b7c08c4..a5fd549aef9 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.27 2005/07/14 08:42:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.28 2005/07/18 20:57:53 momjian Exp $
*/
#ifndef PRINT_H
#define PRINT_H
@@ -40,7 +40,7 @@ typedef struct _printTableOpt
char *fieldSep; /* field separator for unaligned text mode */
char *recordSep; /* record separator for unaligned text
* mode */
- bool numericSep; /* locale-aware numeric units separator and
+ bool numericLocale; /* locale-aware numeric units separator and
* decimal marker */
char *tableAttr; /* attributes for HTML <table ...> */
int encoding; /* character encoding */