Skip to content

Commit add9182

Browse files
committed
Reorganize format options of psql in alphabetical order
This makes the addition of new formats easier, and documentation lookups easier. Author: Daniel Vérité Reviewed-by: Fabien Coelho Discussion: https://postgr.es/m/alpine.DEB.2.20.1803081004241.2916@lancre
1 parent 8f045e2 commit add9182

File tree

4 files changed

+30
-31
lines changed

4 files changed

+30
-31
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,12 +2584,11 @@ lo_import 152801
25842584
<term><literal>format</literal></term>
25852585
<listitem>
25862586
<para>
2587-
Sets the output format to one of <literal>unaligned</literal>,
2588-
<literal>aligned</literal>, <literal>wrapped</literal>,
2589-
<literal>html</literal>, <literal>asciidoc</literal>,
2587+
Sets the output format to one of <literal>aligned</literal>,
2588+
<literal>asciidoc</literal>, <literal>html</literal>,
25902589
<literal>latex</literal> (uses <literal>tabular</literal>),
2591-
<literal>latex-longtable</literal>, or
2592-
<literal>troff-ms</literal>.
2590+
<literal>latex-longtable</literal>, <literal>troff-ms</literal>,
2591+
<literal>unaligned</literal>, or <literal>wrapped</literal>.
25932592
Unique abbreviations are allowed. (That would mean one letter
25942593
is enough.)
25952594
</para>
@@ -2615,10 +2614,10 @@ lo_import 152801
26152614
</para>
26162615

26172616
<para>
2618-
The <literal>html</literal>, <literal>asciidoc</literal>, <literal>latex</literal>,
2619-
<literal>latex-longtable</literal>, and <literal>troff-ms</literal>
2620-
formats put out tables that are intended to
2621-
be included in documents using the respective mark-up
2617+
The <literal>asciidoc</literal>, <literal>html</literal>,
2618+
<literal>latex</literal>, <literal>latex-longtable</literal>, and
2619+
<literal>troff-ms</literal> formats put out tables that are intended
2620+
to be included in documents using the respective mark-up
26222621
language. They are not complete documents! This might not be
26232622
necessary in <acronym>HTML</acronym>, but in
26242623
<application>LaTeX</application> you must have a complete

src/bin/psql/command.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,21 +3560,15 @@ _align2string(enum printFormat in)
35603560
case PRINT_NOTHING:
35613561
return "nothing";
35623562
break;
3563-
case PRINT_UNALIGNED:
3564-
return "unaligned";
3565-
break;
35663563
case PRINT_ALIGNED:
35673564
return "aligned";
35683565
break;
3569-
case PRINT_WRAPPED:
3570-
return "wrapped";
3566+
case PRINT_ASCIIDOC:
3567+
return "asciidoc";
35713568
break;
35723569
case PRINT_HTML:
35733570
return "html";
35743571
break;
3575-
case PRINT_ASCIIDOC:
3576-
return "asciidoc";
3577-
break;
35783572
case PRINT_LATEX:
35793573
return "latex";
35803574
break;
@@ -3584,6 +3578,12 @@ _align2string(enum printFormat in)
35843578
case PRINT_TROFF_MS:
35853579
return "troff-ms";
35863580
break;
3581+
case PRINT_UNALIGNED:
3582+
return "unaligned";
3583+
break;
3584+
case PRINT_WRAPPED:
3585+
return "wrapped";
3586+
break;
35873587
}
35883588
return "unknown";
35893589
}
@@ -3639,25 +3639,25 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
36393639
{
36403640
if (!value)
36413641
;
3642-
else if (pg_strncasecmp("unaligned", value, vallen) == 0)
3643-
popt->topt.format = PRINT_UNALIGNED;
36443642
else if (pg_strncasecmp("aligned", value, vallen) == 0)
36453643
popt->topt.format = PRINT_ALIGNED;
3646-
else if (pg_strncasecmp("wrapped", value, vallen) == 0)
3647-
popt->topt.format = PRINT_WRAPPED;
3648-
else if (pg_strncasecmp("html", value, vallen) == 0)
3649-
popt->topt.format = PRINT_HTML;
36503644
else if (pg_strncasecmp("asciidoc", value, vallen) == 0)
36513645
popt->topt.format = PRINT_ASCIIDOC;
3646+
else if (pg_strncasecmp("html", value, vallen) == 0)
3647+
popt->topt.format = PRINT_HTML;
36523648
else if (pg_strncasecmp("latex", value, vallen) == 0)
36533649
popt->topt.format = PRINT_LATEX;
36543650
else if (pg_strncasecmp("latex-longtable", value, vallen) == 0)
36553651
popt->topt.format = PRINT_LATEX_LONGTABLE;
36563652
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
36573653
popt->topt.format = PRINT_TROFF_MS;
3654+
else if (pg_strncasecmp("unaligned", value, vallen) == 0)
3655+
popt->topt.format = PRINT_UNALIGNED;
3656+
else if (pg_strncasecmp("wrapped", value, vallen) == 0)
3657+
popt->topt.format = PRINT_WRAPPED;
36583658
else
36593659
{
3660-
psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
3660+
psql_error("\\pset: allowed formats are aligned, asciidoc, html, latex, latex-longtable, troff-ms, unaligned, wrapped\n");
36613661
return false;
36623662
}
36633663
}

src/bin/psql/tab-complete.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3539,9 +3539,9 @@ psql_completion(const char *text, int start, int end)
35393539
else if (TailMatchesCS("\\pset", MatchAny))
35403540
{
35413541
if (TailMatchesCS("format"))
3542-
COMPLETE_WITH_CS("unaligned", "aligned", "wrapped", "html",
3543-
"asciidoc", "latex", "latex-longtable",
3544-
"troff-ms");
3542+
COMPLETE_WITH_CS("aligned", "asciidoc", "html", "latex",
3543+
"latex-longtable", "troff-ms", "unaligned",
3544+
"wrapped");
35453545
else if (TailMatchesCS("linestyle"))
35463546
COMPLETE_WITH_CS("ascii", "old-ascii", "unicode");
35473547
else if (TailMatchesCS("pager"))

src/include/fe_utils/print.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
enum printFormat
2727
{
2828
PRINT_NOTHING = 0, /* to make sure someone initializes this */
29-
PRINT_UNALIGNED,
3029
PRINT_ALIGNED,
31-
PRINT_WRAPPED,
32-
PRINT_HTML,
3330
PRINT_ASCIIDOC,
31+
PRINT_HTML,
3432
PRINT_LATEX,
3533
PRINT_LATEX_LONGTABLE,
36-
PRINT_TROFF_MS
34+
PRINT_TROFF_MS,
35+
PRINT_UNALIGNED,
36+
PRINT_WRAPPED
3737
/* add your favourite output format here ... */
3838
};
3939

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy