Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit42ec8ad

Browse files
committed
Add "\pset linestyle ascii/unicode" option to psql, allowing our traditional
ASCII-art style of table output to be upgraded to use Unicode box drawingcharacters if desired. By default, psql will use the Unicode characterswhenever client_encoding is UTF8.The patch forces linestyle=ascii in pg_regress usage, ensuring we don'tbreak the regression tests in Unicode locales.Roger Leigh
1 parentb140711 commit42ec8ad

File tree

8 files changed

+276
-90
lines changed

8 files changed

+276
-90
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.231 2009/10/08 16:34:00 alvherre Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.232 2009/10/13 21:04:01 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -1760,6 +1760,39 @@ lo_import 152801
17601760
</listitem>
17611761
</varlistentry>
17621762

1763+
<varlistentry>
1764+
<term><literal>linestyle</literal></term>
1765+
<listitem>
1766+
<para>
1767+
Sets the border line drawing style to one
1768+
of <literal>ascii</literal> or <literal>unicode</literal>.
1769+
Unique abbreviations are allowed. (That would mean one
1770+
letter is enough.)
1771+
</para>
1772+
1773+
<para>
1774+
<quote>ASCII</quote> uses plain <acronym>ASCII</acronym> characters.
1775+
</para>
1776+
1777+
<para>
1778+
<quote>Unicode</quote> uses Unicode box-drawing characters.
1779+
</para>
1780+
1781+
<para>
1782+
When the selected output format is one that draws lines or boxes
1783+
around the data, this setting controls how the lines are drawn.
1784+
Plain <acronym>ASCII</acronym> characters work everywhere, but
1785+
Unicode characters look nicer on displays that recognize them.
1786+
</para>
1787+
1788+
<para>
1789+
If this option has not been set, the default behavior is to
1790+
use Unicode characters if the client character set encoding
1791+
is UTF-8, otherwise <acronym>ASCII</acronym> characters.
1792+
</para>
1793+
</listitem>
1794+
</varlistentry>
1795+
17631796
<varlistentry>
17641797
<term><literal>expanded</literal> (or <literal>x</literal>)</term>
17651798
<listitem>

‎src/bin/psql/command.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.209 2009/10/07 22:14:24 alvherre Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.210 2009/10/13 21:04:01 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -1788,6 +1788,26 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
17881788
printf(_("Output format is %s.\n"),_align2string(popt->topt.format));
17891789
}
17901790

1791+
/* set table line style */
1792+
elseif (strcmp(param,"linestyle")==0)
1793+
{
1794+
if (!value)
1795+
;
1796+
elseif (pg_strncasecmp("ascii",value,vallen)==0)
1797+
popt->topt.line_style=&pg_asciiformat;
1798+
elseif (pg_strncasecmp("unicode",value,vallen)==0)
1799+
popt->topt.line_style=&pg_utf8format;
1800+
else
1801+
{
1802+
psql_error("\\pset: allowed line styles are ascii, unicode\n");
1803+
return false;
1804+
}
1805+
1806+
if (!quiet)
1807+
printf(_("Line style is %s.\n"),
1808+
get_line_style(&popt->topt)->name);
1809+
}
1810+
17911811
/* set border style/width */
17921812
elseif (strcmp(param,"border")==0)
17931813
{

‎src/bin/psql/mbprint.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.35 2009/06/11 14:49:08 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.36 2009/10/13 21:04:01 tgl Exp $
77
*
88
* XXX this file does not really belong in psql/. Perhaps move to libpq?
99
* It also seems that the mbvalidate function is redundant with existing
@@ -30,8 +30,8 @@
3030

3131
typedefunsignedintpg_wchar;
3232

33-
staticint
34-
get_utf8_id(void)
33+
int
34+
pg_get_utf8_id(void)
3535
{
3636
staticintutf8_id=-1;
3737

@@ -40,7 +40,7 @@ get_utf8_id(void)
4040
returnutf8_id;
4141
}
4242

43-
#definePG_UTF8get_utf8_id()
43+
#definePG_UTF8pg_get_utf8_id()
4444

4545

4646
staticpg_wchar

‎src/bin/psql/mbprint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/bin/psql/mbprint.h,v 1.13 2009/06/11 14:49:08 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/bin/psql/mbprint.h,v 1.14 2009/10/13 21:04:01 tgl Exp $ */
22
#ifndefMBPRINT_H
33
#defineMBPRINT_H
44

@@ -9,8 +9,8 @@ struct lineptr
99
intwidth;
1010
};
1111

12+
externintpg_get_utf8_id(void);
1213
externunsignedchar*mbvalidate(unsignedchar*pwcs,intencoding);
13-
1414
externintpg_wcswidth(constunsignedchar*pwcs,size_tlen,intencoding);
1515
externvoidpg_wcsformat(unsignedchar*pwcs,size_tlen,intencoding,structlineptr*lines,intcount);
1616
externvoidpg_wcssize(unsignedchar*pwcs,size_tlen,intencoding,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp