This has been saved for the 7.6 release:
http:/momjian.postgresql.org/cgi-bin/pgpatches2
---
Roger Leigh wrote:
> Hello,
>
> I've created a patch which adds support for troff "-ms" output to
> psql. i.e. "\pset format troff-ms". The patch also corrects some
> problems with the "latex" format, notably defining an extra column in
> the output table, and correcting some alignment issues; it also
> changes the output to match the border setting as documented in the
> manual page and as shown with the "aligned" format.
>
> The troff-ms output is mostly identical to the latex output allowing
> for the differences between the two typesetters.
>
> The output should be saved in a file and piped as follows:
>
> cat file | tbl | troff -T ps -ms > file.ps
> or
> tbl file | troff -T ps -ms > file.ps
>
> Because it contains tabs, you'll need to redirect psql output or use
> "script", rather than pasting from a terminal window, due to the tabs
> which can be replaced with spaces.
>
> I've attached the patch (against the current mainline), and example
> output of each for each of border=[123] and expanded mode on and off
> (both source and printable copy).
>
>
> Regards,
> Roger
>
>
> PS. I'm not subscribed, so I would appreciate a CC on any replies.
> Thanks!
>
>
> --
> Roger Leigh
>
> Printing on GNU/Linux? http://gimp-print.sourceforge.net/
> GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
Content-Description: patch to add troff output to psql
[ text/x-patch is unsupported, treating like TEXT/PLAIN ]
> Index: doc/src/sgml/ref/psql-ref.sgml
> ===
> RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/psql-ref.sgml,v
> retrieving revision 1.119
> diff -u -r1.119 psql-ref.sgml
> --- doc/src/sgml/ref/psql-ref.sgml15 Jul 2004 03:56:04 - 1.119
> +++ doc/src/sgml/ref/psql-ref.sgml1 Aug 2004 17:36:46 -
> @@ -1372,9 +1372,10 @@
>
>
>Sets the output format to one of unaligned,
> - aligned, html, or
> - latex. Unique abbreviations are allowed.
> - (That would mean one letter is enough.)
> + aligned, html,
> + latex, or troff-ms.
> + Unique abbreviations are allowed. (That would mean one letter
> + is enough.)
>
>
>
> Index: src/bin/psql/command.c
> ===
> RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/command.c,v
> retrieving revision 1.122
> diff -u -r1.122 command.c
> --- src/bin/psql/command.c15 Jul 2004 03:56:06 - 1.122
> +++ src/bin/psql/command.c1 Aug 2004 17:36:53 -
> @@ -1307,6 +1307,9 @@
> case PRINT_LATEX:
> return "latex";
> break;
> + case PRINT_TROFF_MS:
> + return "troff-ms";
> + break;
> }
> return "unknown";
> }
> @@ -1335,9 +1338,11 @@
> popt->topt.format = PRINT_HTML;
> else if (pg_strncasecmp("latex", value, vallen) == 0)
> popt->topt.format = PRINT_LATEX;
> + else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
> + popt->topt.format = PRINT_TROFF_MS;
> else
> {
> - psql_error("\\pset: allowed formats are unaligned, aligned,
> html, latex\n");
> + psql_error("\\pset: allowed formats are unaligned, aligned,
> html, latex, troff-ms\n");
> return false;
> }
>
> Index: src/bin/psql/print.c
> ===
> RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/print.c,v
> retrieving revision 1.48
> diff -u -r1.48 print.c
> --- src/bin/psql/print.c 23 May 2004 22:20:10 - 1.48
> +++ src/bin/psql/print.c 1 Aug 2004 17:36:56 -
> @@ -769,7 +769,7 @@
>
>
> /*/
> -/* LaTeX */
> +/* LaTeX */
> /*/
>
>
> @@ -790,6 +790,9 @@
> case '$':
> fputs("\\$", fout);
> break;
> + case '_':
> + fputs("\\_", fout);
> + break;
> case '{':
> fputs("\\{", fout);
> break;
> @@ -817,7 +820,6 @@
> {
> unsigned int col_count = 0;
> unsigned int i;
> - const char *cp;
> const char *const * ptr;
>
>
> @@ -829,42 +831,39 @@
> fputs("\n\\end{center}\n\n", fout);
> }
>
> + /* count columns */
> + for (ptr = headers