8000 Code + docs review for unicode linestyle patch. · home201448/postgres@f4057cd · GitHub
[go: up one dir, main page]

Skip to content

Commit f4057cd

Browse files
committed
Code + docs review for unicode linestyle patch.
Fix some brain fade in commit a2dabf0: erroneous variable names in docs, rearrangements that made sentences less clear not more so, undocumented and poorly-chosen-anyway API behaviors of subroutines, bad grammar in error messages, copy-and-paste faults. Albe Laurenz and Tom Lane
1 parent fd5ce6b commit f4057cd

File tree

3 files changed

+45
-39
lines changed

3 files changed

+45
-39
lines changed

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

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,14 +2012,15 @@ lo_import 152801
20122012
The <replaceable class="parameter">value</replaceable> must be a
20132013
number. In general, the higher
20142014
the number the more borders and lines the tables will have,
2015-
but this depends on the particular format. In
2016-
<acronym>HTML</acronym> format, this will translate directly
2017-
into the <literal>border=...</literal> attribute; in
2018-
<literal>latex</literal> and <literal>latex-longtable</literal>
2019-
formats, a value of 3 will add a dividing line between each row; in
2020-
the other formats only values 0 (no border), 1 (internal dividing
2021-
lines), and 2 (table frame) make sense and values above 2 will be
2022-
treated the same as <literal>border = 2</literal>.
2015+
but details depend on the particular format.
2016+
In <acronym>HTML</acronym> format, this will translate directly
2017+
into the <literal>border=...</literal> attribute.
2018+
In most other formats only values 0 (no border), 1 (internal
2019+
dividing lines), and 2 (table frame) make sense, and values above 2
2020+
will be treated the same as <literal>border = 2</literal>.
2021+
The <literal>latex</literal> and <literal>latex-longtable</literal>
2022+
formats additionally allow a value of 3 to add dividing lines
2023+
between data rows.
20232024
</para>
20242025
</listitem>
20252026
</varlistentry>
@@ -2194,8 +2195,8 @@ lo_import 152801
21942195

21952196
<para>
21962197
When the <literal>border</> setting is greater than zero,
2197-
this option also determines the characters
2198-
with which the border lines are drawn.
2198+
the <literal>linestyle</literal> option also determines the
2199+
characters with which the border lines are drawn.
21992200
Plain <acronym>ASCII</acronym> characters work everywhere, but
22002201
Unicode characters look nicer on displays that recognize them.
22012202
</para>
@@ -2338,31 +2339,34 @@ lo_import 152801
23382339
</varlistentry>
23392340

23402341
<varlistentry>
2341-
<term><literal>unicode_border_style</literal></term>
2342+
<term><literal>unicode_border_linestyle</literal></term>
23422343
<listitem>
23432344
<para>
2344-
Sets the border drawing style for the <literal>unicode</literal> line style to one
2345-
of <literal>single</literal> or <literal>double</literal>.
2345+
Sets the border drawing style for the <literal>unicode</literal>
2346+
line style to one of <literal>single</literal>
2347+
or <literal>double</literal>.
23462348
</para>
23472349
</listitem>
23482350
</varlistentry>
23492351

23502352
<varlistentry>
2351-
<term><literal>unicode_column_style</literal></term>
2353+
<term><literal>unicode_column_linestyle</literal></term>
23522354
<listitem>
23532355
<para>
2354-
Sets the column drawing style for the <literal>unicode</literal> line style to one
2355-
of <literal>single</literal> or <literal>double</literal>.
2356+
Sets the column drawing style for the <literal>unicode</literal>
2357+
line style to one of <literal>single</literal>
2358+
or <literal>double</literal>.
23562359
</para>
23572360
</listitem>
23582361
</varlistentry>
23592362

23602363
<varlistentry>
2361-
<term><literal>unicode_header_style</literal></term>
2364+
<term><literal>unicode_header_linestyle</literal></term>
23622365
<listitem>
23632366
<para>
2364-
Sets the header drawing style for the <literal>unicode</literal> line style to one
2365-
of <literal>single</literal> or <literal>double</literal>.
2367+
Sets the header drawing style for the <literal>unicode</literal>
2368+
line style to one of <literal>single</literal>
2369+
or <literal>double</literal>.
23662370
</para>
23672371
</listitem>
23682372
</varlistentry>

doc/src/sgml/release-9.5.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,12 +2061,12 @@ FIXME: Add more specifics?
20612061
2014-09-12 [a2dabf0] Stephe..: Add unicode_{column|header|border}_style to psql
20622062
-->
20632063
<para>
2064-
Allow column, header, and border control to <application>psql</>'s
2065-
Unicode style (Pavel Stehule)
2064+
Provide separate column, header, and border linestyle control
2065+
in <application>psql</>'s unicode linestyle (Pavel Stehule)
20662066
</para>
20672067

20682068
<para>
2069-
Single or double output is supported; the default is
2069+
Single or double lines are supported; the default is
20702070
<literal>single</>.
20712071
</para>
20722072
</listitem>

src/bin/psql/command.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,11 +2302,11 @@ _align2string(enum printFormat in)
23022302
}
23032303

23042304
/*
2305-
* Parse entered unicode linestyle. Returns true, when entered string is
2306-
* known linestyle: single, double else returns false.
2305+
* Parse entered unicode linestyle. If ok, update *linestyle and return
2306+
* true, else return false.
23072307
*/
23082308
static bool
2309-
set_unicode_line_style(printQueryOpt *popt, const char *value, size_t vallen,
2309+
set_unicode_line_style(const char *value, size_t vallen,
23102310
unicode_linestyle *linestyle)
23112311
{
23122312
if (pg_strncasecmp("single", value, vallen) == 0)
@@ -2315,10 +2315,6 @@ set_unicode_line_style(printQueryOpt *popt, const char *value, size_t vallen,
23152315
*linestyle = UNICODE_LINESTYLE_DOUBLE;
23162316
else
23172317
return false;
2318-
2319-
/* input is ok, generate new unicode style */
2320-
refresh_utf8format(&(popt->topt));
2321-
23222318
return true;
23232319
}
23242320

@@ -2404,10 +2400,12 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
24042400
{
24052401
if (!value)
24062402
;
2407-
else if (!set_unicode_line_style(popt, value, vallen,
2408-
&popt->topt.unicode_border_linestyle))
2403+
else if (set_unicode_line_style(value, vallen,
2404+
&popt->topt.unicode_border_linestyle))
2405+
refresh_utf8format(&(popt->topt));
2406+
else
24092407
{
2410-
psql_error("\\pset: allowed unicode border linestyle are single, double\n");
2408+
psql_error("\\pset: allowed unicode border linestyles are single, double\n");
24112409
return false;
24122410
}
24132411
}
@@ -2417,10 +2415,12 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
24172415
{
24182416
if (!value)
24192417
;
2420-
else if (!set_unicode_line_style(popt, value, vallen,
2421-
&popt->topt.unicode_column_linestyle))
2418+
else if (set_unicode_line_style(value, vallen,
2419+
&popt->topt.unicode_column_linestyle))
2420+
refresh_utf8format(&(popt->topt));
2421+
else
24222422
{
2423-
psql_error("\\pset: allowed unicode column linestyle are single, double\n");
2423+
psql_error("\\pset: allowed unicode column linestyles are single, double\n");
24242424
return false;
24252425
}
24262426
}
@@ -2430,10 +2430,12 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
24302430
{
24312431
if (!value)
24322432
;
2433-
else if (!set_unicode_line_style(popt, value, vallen,
2434-
&popt->topt.unicode_header_linestyle))
2433+
else if (set_unicode_line_style(value, vallen,
2434+
&popt->topt.unicode_header_linestyle))
2435+
refresh_utf8format(&(popt->topt));
2436+
else
24352437
{
2436-
psql_error("\\pset: allowed unicode header linestyle are single, double\n");
2438+
psql_error("\\pset: allowed unicode header linestyles are single, double\n");
24372439
return false;
24382440
}
24392441
}
@@ -2758,7 +2760,7 @@ printPsetInfo(const char *param, struct printQueryOpt *popt)
27582760

27592761
else if (strcmp(param, "unicode_header_linestyle") == 0)
27602762
{
2761-
printf(_("Unicode border linestyle is \"%s\".\n"),
2763+
printf(_("Unicode header linestyle is \"%s\".\n"),
27622764
_unicode_linestyle2string(popt->topt.unicode_header_linestyle));
27632765
}
27642766

0 commit comments

Comments
 (0)
0