Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
45a19efa
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
45a19efa
编写于
7月 14, 2005
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change numericsep to a boolean, and make it locale-aware.
上级
4a8bbbd2
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
93 addition
and
76 deletion
+93
-76
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+4
-5
src/bin/psql/command.c
src/bin/psql/command.c
+8
-6
src/bin/psql/print.c
src/bin/psql/print.c
+74
-62
src/bin/psql/print.h
src/bin/psql/print.h
+5
-2
src/bin/psql/startup.c
src/bin/psql/startup.c
+2
-1
未找到文件。
doc/src/sgml/ref/psql-ref.sgml
浏览文件 @
45a19efa
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.14
6 2005/07/10 03:46:12
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.14
7 2005/07/14 08:42:36
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -1496,10 +1496,9 @@ lo_import 152801
...
@@ -1496,10 +1496,9 @@ lo_import 152801
<term><literal>numericsep</literal></term>
<term><literal>numericsep</literal></term>
<listitem>
<listitem>
<para>
<para>
Specifies the character separator between groups of three digits
Toggles the display of a locale-aware character to separate groups
to the left of the decimal marker. The default is <literal>''</>
of digits to the left of the decimal marker. It also enables
(none). Setting this to a period also changes the decimal marker
a locale-aware decimal marker.
to a comma.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
...
src/bin/psql/command.c
浏览文件 @
45a19efa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.14
8 2005/07/14 06:49:58
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.14
9 2005/07/14 08:42:37
momjian Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "command.h"
#include "command.h"
...
@@ -1420,15 +1420,17 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
...
@@ -1420,15 +1420,17 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
:
_
(
"Expanded display is off.
\n
"
));
:
_
(
"Expanded display is off.
\n
"
));
}
}
/* numeric separators */
else
if
(
strcmp
(
param
,
"numericsep"
)
==
0
)
else
if
(
strcmp
(
param
,
"numericsep"
)
==
0
)
{
{
if
(
value
)
popt
->
topt
.
numericSep
=
!
popt
->
topt
.
numericSep
;
if
(
!
quiet
)
{
{
free
(
popt
->
topt
.
numericSep
);
if
(
popt
->
topt
.
numericSep
)
popt
->
topt
.
numericSep
=
pg_strdup
(
value
);
puts
(
_
(
"Showing numeric separators."
));
else
puts
(
_
(
"Numeric separators are off."
));
}
}
if
(
!
quiet
)
printf
(
_
(
"Numeric separator is
\"
%s
\"
.
\n
"
),
popt
->
topt
.
numericSep
);
}
}
/* null display */
/* null display */
...
...
src/bin/psql/print.c
浏览文件 @
45a19efa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.6
6 2005/07/14 07:32:01
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.6
7 2005/07/14 08:42:37
momjian Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "common.h"
#include "common.h"
...
@@ -24,11 +24,17 @@
...
@@ -24,11 +24,17 @@
#include <termios.h>
#include <termios.h>
#endif
#endif
#include <locale.h>
#include "pqsignal.h"
#include "pqsignal.h"
#include "libpq-fe.h"
#include "libpq-fe.h"
#include "mbprint.h"
#include "mbprint.h"
static
char
*
decimal_point
;
static
char
*
grouping
;
static
char
*
thousands_sep
;
static
void
*
static
void
*
pg_local_malloc
(
size_t
size
)
pg_local_malloc
(
size_t
size
)
{
{
...
@@ -47,6 +53,7 @@ static int
...
@@ -47,6 +53,7 @@ static int
num_numericseps
(
const
char
*
my_str
)
num_numericseps
(
const
char
*
my_str
)
{
{
int
old_len
,
dec_len
,
int_len
;
int
old_len
,
dec_len
,
int_len
;
int
groupdigits
=
atoi
(
grouping
);
if
(
my_str
[
0
]
==
'-'
)
if
(
my_str
[
0
]
==
'-'
)
my_str
++
;
my_str
++
;
...
@@ -55,10 +62,10 @@ num_numericseps(const char *my_str)
...
@@ -55,10 +62,10 @@ num_numericseps(const char *my_str)
dec_len
=
strchr
(
my_str
,
'.'
)
?
strlen
(
strchr
(
my_str
,
'.'
))
:
0
;
dec_len
=
strchr
(
my_str
,
'.'
)
?
strlen
(
strchr
(
my_str
,
'.'
))
:
0
;
int_len
=
old_len
-
dec_len
;
int_len
=
old_len
-
dec_len
;
if
(
int_len
%
3
!=
0
)
if
(
int_len
%
groupdigits
!=
0
)
return
int_len
/
3
;
return
int_len
/
groupdigits
;
else
else
return
int_len
/
3
-
1
;
/* no leading separator */
return
int_len
/
groupdigits
-
1
;
/* no leading separator */
}
}
static
int
static
int
...
@@ -68,17 +75,12 @@ len_with_numericsep(const char *my_str)
...
@@ -68,17 +75,12 @@ len_with_numericsep(const char *my_str)
}
}
static
void
static
void
format_numericsep
(
char
*
my_str
,
char
*
numericsep
)
format_numericsep
(
char
*
my_str
)
{
{
int
i
,
j
,
digits_before_sep
,
old_len
,
new_len
,
dec_len
,
int_len
;
int
i
,
j
,
digits_before_sep
,
old_len
,
new_len
,
dec_len
,
int_len
;
char
*
dec_point
;
char
*
new_str
;
char
*
new_str
;
char
*
dec_value
;
char
*
dec_value
;
int
groupdigits
=
atoi
(
grouping
);
if
(
strcmp
(
numericsep
,
"."
)
!=
0
)
dec_point
=
"."
;
else
dec_point
=
","
;
if
(
my_str
[
0
]
==
'-'
)
if
(
my_str
[
0
]
==
'-'
)
my_str
++
;
my_str
++
;
...
@@ -86,9 +88,9 @@ format_numericsep(char *my_str, char *numericsep)
...
@@ -86,9 +88,9 @@ format_numericsep(char *my_str, char *numericsep)
old_len
=
strlen
(
my_str
);
old_len
=
strlen
(
my_str
);
dec_len
=
strchr
(
my_str
,
'.'
)
?
strlen
(
strchr
(
my_str
,
'.'
))
:
0
;
dec_len
=
strchr
(
my_str
,
'.'
)
?
strlen
(
strchr
(
my_str
,
'.'
))
:
0
;
int_len
=
old_len
-
dec_len
;
int_len
=
old_len
-
dec_len
;
digits_before_sep
=
int_len
%
3
;
digits_before_sep
=
int_len
%
groupdigits
;
new_len
=
int_len
+
int_len
/
3
+
dec_len
;
new_len
=
int_len
+
int_len
/
groupdigits
+
dec_len
;
if
(
digits_before_sep
==
0
)
if
(
digits_before_sep
==
0
)
new_len
--
;
/* no leading separator */
new_len
--
;
/* no leading separator */
...
@@ -99,7 +101,7 @@ format_numericsep(char *my_str, char *numericsep)
...
@@ -99,7 +101,7 @@ format_numericsep(char *my_str, char *numericsep)
/* hit decimal point */
/* hit decimal point */
if
(
my_str
[
i
]
==
'.'
)
if
(
my_str
[
i
]
==
'.'
)
{
{
new_str
[
j
]
=
*
dec_point
;
new_str
[
j
]
=
*
dec
imal
_point
;
new_str
[
j
+
1
]
=
'\0'
;
new_str
[
j
+
1
]
=
'\0'
;
dec_value
=
strchr
(
my_str
,
'.'
);
dec_value
=
strchr
(
my_str
,
'.'
);
strcat
(
new_str
,
++
dec_value
);
strcat
(
new_str
,
++
dec_value
);
...
@@ -115,8 +117,9 @@ format_numericsep(char *my_str, char *numericsep)
...
@@ -115,8 +117,9 @@ format_numericsep(char *my_str, char *numericsep)
/* add separator? */
/* add separator? */
if
(
i
!=
0
&&
if
(
i
!=
0
&&
(
i
-
(
digits_before_sep
?
digits_before_sep
:
3
))
%
3
==
0
)
(
i
-
(
digits_before_sep
?
digits_before_sep
:
groupdigits
))
new_str
[
j
++
]
=
*
numericsep
;
%
groupdigits
==
0
)
new_str
[
j
++
]
=
*
thousands_sep
;
new_str
[
j
]
=
my_str
[
i
];
new_str
[
j
]
=
my_str
[
i
];
}
}
...
@@ -135,7 +138,7 @@ print_unaligned_text(const char *title, const char *const *headers,
...
@@ -135,7 +138,7 @@ print_unaligned_text(const char *title, const char *const *headers,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
const
char
*
opt_fieldsep
,
const
char
*
opt_align
,
const
char
*
opt_fieldsep
,
const
char
*
opt_recordsep
,
bool
opt_tuples_only
,
const
char
*
opt_recordsep
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
FILE
*
fout
)
bool
opt_numericsep
,
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
unsigned
int
i
;
unsigned
int
i
;
...
@@ -174,13 +177,12 @@ print_unaligned_text(const char *title, const char *const *headers,
...
@@ -174,13 +177,12 @@ print_unaligned_text(const char *title, const char *const *headers,
fputs
(
opt_recordsep
,
fout
);
fputs
(
opt_recordsep
,
fout
);
need_recordsep
=
false
;
need_recordsep
=
false
;
}
}
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
>
0
&&
if
(
opt_align
[
i
%
col_count
]
==
'r'
&&
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
fputs
(
my_cell
,
fout
);
fputs
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -220,7 +222,7 @@ print_unaligned_vertical(const char *title, const char *const *headers,
...
@@ -220,7 +222,7 @@ print_unaligned_vertical(const char *title, const char *const *headers,
const
char
*
const
*
cells
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
const
char
*
opt_fieldsep
,
const
char
*
opt_recordsep
,
const
char
*
opt_fieldsep
,
const
char
*
opt_recordsep
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
FILE
*
fout
)
bool
opt_tuples_only
,
bool
opt_numericsep
,
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
unsigned
int
i
;
unsigned
int
i
;
...
@@ -251,13 +253,12 @@ print_unaligned_vertical(const char *title, const char *const *headers,
...
@@ -251,13 +253,12 @@ print_unaligned_vertical(const char *title, const char *const *headers,
fputs
(
headers
[
i
%
col_count
],
fout
);
fputs
(
headers
[
i
%
col_count
],
fout
);
fputs
(
opt_fieldsep
,
fout
);
fputs
(
opt_fieldsep
,
fout
);
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_align
[
i
%
col_count
]
==
'r'
&&
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
fputs
(
my_cell
,
fout
);
fputs
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -325,7 +326,7 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths,
...
@@ -325,7 +326,7 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths,
static
void
static
void
print_aligned_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_aligned_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
int
encoding
,
unsigned
short
int
opt_border
,
int
encoding
,
FILE
*
fout
)
FILE
*
fout
)
{
{
...
@@ -394,8 +395,7 @@ print_aligned_text(const char *title, const char *const *headers,
...
@@ -394,8 +395,7 @@ print_aligned_text(const char *title, const char *const *headers,
{
{
int
numericseps
;
int
numericseps
;
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_align
[
i
%
col_count
]
==
'r'
&&
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
numericseps
=
num_numericseps
(
*
ptr
);
numericseps
=
num_numericseps
(
*
ptr
);
else
else
numericseps
=
0
;
numericseps
=
0
;
...
@@ -480,12 +480,12 @@ print_aligned_text(const char *title, const char *const *headers,
...
@@ -480,12 +480,12 @@ print_aligned_text(const char *title, const char *const *headers,
/* content */
/* content */
if
(
opt_align
[
i
%
col_count
]
==
'r'
)
if
(
opt_align
[
i
%
col_count
]
==
'r'
)
{
{
if
(
strlen
(
*
ptr
)
>
0
&&
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
if
(
opt_numericsep
)
{
{
char
*
my_cell
=
pg_local_malloc
(
cell_w
[
i
]
+
1
);
char
*
my_cell
=
pg_local_malloc
(
cell_w
[
i
]
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
fprintf
(
fout
,
"%*s%s"
,
widths
[
i
%
col_count
]
-
cell_w
[
i
],
""
,
my_cell
);
fprintf
(
fout
,
"%*s%s"
,
widths
[
i
%
col_count
]
-
cell_w
[
i
],
""
,
my_cell
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -547,7 +547,7 @@ static void
...
@@ -547,7 +547,7 @@ static void
print_aligned_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_aligned_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
unsigned
short
int
opt_border
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
int
encoding
,
FILE
*
fout
)
int
encoding
,
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
...
@@ -612,8 +612,7 @@ print_aligned_vertical(const char *title, const char *const *headers,
...
@@ -612,8 +612,7 @@ print_aligned_vertical(const char *title, const char *const *headers,
{
{
int
numericseps
;
int
numericseps
;
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_align
[
i
%
col_count
]
==
'r'
&&
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
numericseps
=
num_numericseps
(
*
ptr
);
numericseps
=
num_numericseps
(
*
ptr
);
else
else
numericseps
=
0
;
numericseps
=
0
;
...
@@ -696,9 +695,8 @@ print_aligned_vertical(const char *title, const char *const *headers,
...
@@ -696,9 +695,8 @@ print_aligned_vertical(const char *title, const char *const *headers,
char
*
my_cell
=
pg_local_malloc
(
cell_w
[
i
]
+
1
);
char
*
my_cell
=
pg_local_malloc
(
cell_w
[
i
]
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_align
[
i
%
col_count
]
==
'r'
&&
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
format_numericsep
(
my_cell
);
format_numericsep
(
my_cell
,
opt_numericsep
);
if
(
opt_border
<
2
)
if
(
opt_border
<
2
)
puts
(
my_cell
);
puts
(
my_cell
);
else
else
...
@@ -785,7 +783,7 @@ static void
...
@@ -785,7 +783,7 @@ static void
print_html_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_html_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
unsigned
short
int
opt_border
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
const
char
*
opt_table_attr
,
FILE
*
fout
)
const
char
*
opt_table_attr
,
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
...
@@ -831,13 +829,12 @@ print_html_text(const char *title, const char *const *headers,
...
@@ -831,13 +829,12 @@ print_html_text(const char *title, const char *const *headers,
/* is string only whitespace? */
/* is string only whitespace? */
if
((
*
ptr
)[
strspn
(
*
ptr
,
"
\t
"
)]
==
'\0'
)
if
((
*
ptr
)[
strspn
(
*
ptr
,
"
\t
"
)]
==
'\0'
)
fputs
(
" "
,
fout
);
fputs
(
" "
,
fout
);
else
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
else
if
(
opt_align
[
i
%
col_count
]
==
'r'
&&
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
html_escaped_print
(
my_cell
,
fout
);
html_escaped_print
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -873,7 +870,7 @@ static void
...
@@ -873,7 +870,7 @@ static void
print_html_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_html_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
unsigned
short
int
opt_border
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
const
char
*
opt_table_attr
,
FILE
*
fout
)
const
char
*
opt_table_attr
,
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
...
@@ -917,13 +914,12 @@ print_html_vertical(const char *title, const char *const *headers,
...
@@ -917,13 +914,12 @@ print_html_vertical(const char *title, const char *const *headers,
/* is string only whitespace? */
/* is string only whitespace? */
if
((
*
ptr
)[
strspn
(
*
ptr
,
"
\t
"
)]
==
'\0'
)
if
((
*
ptr
)[
strspn
(
*
ptr
,
"
\t
"
)]
==
'\0'
)
fputs
(
" "
,
fout
);
fputs
(
" "
,
fout
);
else
if
((
opt_align
[
i
%
col_count
]
==
'r'
)
&&
strlen
(
*
ptr
)
!=
0
&&
else
if
(
opt_align
[
i
%
col_count
]
==
'r'
&&
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
html_escaped_print
(
my_cell
,
fout
);
html_escaped_print
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -999,7 +995,7 @@ static void
...
@@ -999,7 +995,7 @@ static void
print_latex_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_latex_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
unsigned
short
int
opt_border
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
FILE
*
fout
)
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
...
@@ -1060,13 +1056,12 @@ print_latex_text(const char *title, const char *const *headers,
...
@@ -1060,13 +1056,12 @@ print_latex_text(const char *title, const char *const *headers,
/* print cells */
/* print cells */
for
(
i
=
0
,
ptr
=
cells
;
*
ptr
;
i
++
,
ptr
++
)
for
(
i
=
0
,
ptr
=
cells
;
*
ptr
;
i
++
,
ptr
++
)
{
{
if
(
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
latex_escaped_print
(
my_cell
,
fout
);
latex_escaped_print
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -1103,7 +1098,7 @@ static void
...
@@ -1103,7 +1098,7 @@ static void
print_latex_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_latex_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
unsigned
short
int
opt_border
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
FILE
*
fout
)
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
...
@@ -1174,13 +1169,12 @@ print_latex_vertical(const char *title, const char *const *headers,
...
@@ -1174,13 +1169,12 @@ print_latex_vertical(const char *title, const char *const *headers,
if
(
footers
&&
!
opt_tuples_only
)
if
(
footers
&&
!
opt_tuples_only
)
for
(
ptr
=
footers
;
*
ptr
;
ptr
++
)
for
(
ptr
=
footers
;
*
ptr
;
ptr
++
)
{
{
if
(
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
latex_escaped_print
(
my_cell
,
fout
);
latex_escaped_print
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -1221,7 +1215,7 @@ static void
...
@@ -1221,7 +1215,7 @@ static void
print_troff_ms_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_troff_ms_text
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
unsigned
short
int
opt_border
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
FILE
*
fout
)
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
...
@@ -1275,13 +1269,12 @@ print_troff_ms_text(const char *title, const char *const *headers,
...
@@ -1275,13 +1269,12 @@ print_troff_ms_text(const char *title, const char *const *headers,
/* print cells */
/* print cells */
for
(
i
=
0
,
ptr
=
cells
;
*
ptr
;
i
++
,
ptr
++
)
for
(
i
=
0
,
ptr
=
cells
;
*
ptr
;
i
++
,
ptr
++
)
{
{
if
(
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
troff_ms_escaped_print
(
my_cell
,
fout
);
troff_ms_escaped_print
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -1315,7 +1308,7 @@ static void
...
@@ -1315,7 +1308,7 @@ static void
print_troff_ms_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
print_troff_ms_vertical
(
const
char
*
title
,
const
char
*
const
*
headers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
const
*
cells
,
const
char
*
const
*
footers
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
const
char
*
opt_align
,
bool
opt_tuples_only
,
char
*
opt_numericsep
,
unsigned
short
int
opt_border
,
bool
opt_numericsep
,
unsigned
short
int
opt_border
,
FILE
*
fout
)
FILE
*
fout
)
{
{
unsigned
int
col_count
=
0
;
unsigned
int
col_count
=
0
;
...
@@ -1345,12 +1338,10 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
...
@@ -1345,12 +1338,10 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
if
(
opt_tuples_only
)
if
(
opt_tuples_only
)
fputs
(
"c l;
\n
"
,
fout
);
fputs
(
"c l;
\n
"
,
fout
);
/* count columns */
/* count columns */
for
(
ptr
=
headers
;
*
ptr
;
ptr
++
)
for
(
ptr
=
headers
;
*
ptr
;
ptr
++
)
col_count
++
;
col_count
++
;
/* print records */
/* print records */
for
(
i
=
0
,
ptr
=
cells
;
*
ptr
;
i
++
,
ptr
++
)
for
(
i
=
0
,
ptr
=
cells
;
*
ptr
;
i
++
,
ptr
++
)
{
{
...
@@ -1390,13 +1381,12 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
...
@@ -1390,13 +1381,12 @@ print_troff_ms_vertical(const char *title, const char *const *headers,
troff_ms_escaped_print
(
headers
[
i
%
col_count
],
fout
);
troff_ms_escaped_print
(
headers
[
i
%
col_count
],
fout
);
fputc
(
'\t'
,
fout
);
fputc
(
'\t'
,
fout
);
if
(
strlen
(
*
ptr
)
!=
0
&&
if
(
opt_numericsep
)
opt_numericsep
!=
NULL
&&
strlen
(
opt_numericsep
)
>
0
)
{
{
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
char
*
my_cell
=
pg_local_malloc
(
len_with_numericsep
(
*
ptr
)
+
1
);
strcpy
(
my_cell
,
*
ptr
);
strcpy
(
my_cell
,
*
ptr
);
format_numericsep
(
my_cell
,
opt_numericsep
);
format_numericsep
(
my_cell
);
troff_ms_escaped_print
(
my_cell
,
fout
);
troff_ms_escaped_print
(
my_cell
,
fout
);
free
(
my_cell
);
free
(
my_cell
);
}
}
...
@@ -1714,4 +1704,26 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout, FILE *f
...
@@ -1714,4 +1704,26 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout, FILE *f
}
}
/* the end */
void
setDecimalLocale
(
void
)
{
struct
lconv
*
extlconv
;
extlconv
=
localeconv
();
/* These are treated as single-byte strings in the code */
if
(
*
extlconv
->
decimal_point
)
decimal_point
=
strdup
(
extlconv
->
decimal_point
);
else
decimal_point
=
"."
;
/* SQL output standard */
if
(
*
extlconv
->
grouping
&&
atoi
(
extlconv
->
grouping
)
>
0
)
grouping
=
strdup
(
extlconv
->
grouping
);
else
grouping
=
"3"
;
/* most common */
if
(
*
extlconv
->
thousands_sep
)
thousands_sep
=
strdup
(
extlconv
->
thousands_sep
);
else
thousands_sep
=
","
;
/* matches SQL standard decimal marker */
}
src/bin/psql/print.h
浏览文件 @
45a19efa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.2
6 2005/07/10 03:46:13
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.2
7 2005/07/14 08:42:37
momjian Exp $
*/
*/
#ifndef PRINT_H
#ifndef PRINT_H
#define PRINT_H
#define PRINT_H
...
@@ -40,7 +40,8 @@ typedef struct _printTableOpt
...
@@ -40,7 +40,8 @@ typedef struct _printTableOpt
char
*
fieldSep
;
/* field separator for unaligned text mode */
char
*
fieldSep
;
/* field separator for unaligned text mode */
char
*
recordSep
;
/* record separator for unaligned text
char
*
recordSep
;
/* record separator for unaligned text
* mode */
* mode */
char
*
numericSep
;
/* numeric units separator */
bool
numericSep
;
/* locale-aware numeric units separator and
* decimal marker */
char
*
tableAttr
;
/* attributes for HTML <table ...> */
char
*
tableAttr
;
/* attributes for HTML <table ...> */
int
encoding
;
/* character encoding */
int
encoding
;
/* character encoding */
bool
normal_query
;
/* are we presenting the results of a
bool
normal_query
;
/* are we presenting the results of a
...
@@ -86,6 +87,8 @@ typedef struct _printQueryOpt
...
@@ -86,6 +87,8 @@ typedef struct _printQueryOpt
void
printQuery
(
const
PGresult
*
result
,
const
printQueryOpt
*
opt
,
void
printQuery
(
const
PGresult
*
result
,
const
printQueryOpt
*
opt
,
FILE
*
fout
,
FILE
*
flog
);
FILE
*
fout
,
FILE
*
flog
);
void
setDecimalLocale
(
void
);
#ifndef __CYGWIN__
#ifndef __CYGWIN__
#define DEFAULT_PAGER "more"
#define DEFAULT_PAGER "more"
#else
#else
...
...
src/bin/psql/startup.c
浏览文件 @
45a19efa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.11
8 2005/06/21 04:02:33 tgl
Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.11
9 2005/07/14 08:42:37 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
...
@@ -130,6 +130,7 @@ main(int argc, char *argv[])
...
@@ -130,6 +130,7 @@ main(int argc, char *argv[])
setvbuf
(
stderr
,
NULL
,
_IONBF
,
0
);
setvbuf
(
stderr
,
NULL
,
_IONBF
,
0
);
setup_win32_locks
();
setup_win32_locks
();
#endif
#endif
setDecimalLocale
();
pset
.
cur_cmd_source
=
stdin
;
pset
.
cur_cmd_source
=
stdin
;
pset
.
cur_cmd_interactive
=
false
;
pset
.
cur_cmd_interactive
=
false
;
pset
.
encoding
=
PQenv2encoding
();
pset
.
encoding
=
PQenv2encoding
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录