No need for screen_size to be static.
This commit is contained in:
parent
8c3d7715bc
commit
24a4aff68e
@ -10,16 +10,13 @@
|
|||||||
* didn't really belong there.
|
* didn't really belong there.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.38 2000/05/29 21:25:04 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.39 2001/01/06 17:43:01 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "libpq-fe.h"
|
|
||||||
#include "libpq-int.h"
|
|
||||||
#include "pqsignal.h"
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
@ -36,17 +33,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TIOCGWINSZ
|
#include "libpq-fe.h"
|
||||||
static struct winsize screen_size;
|
#include "libpq-int.h"
|
||||||
|
#include "pqsignal.h"
|
||||||
#else
|
|
||||||
static struct winsize
|
|
||||||
{
|
|
||||||
int ws_row;
|
|
||||||
int ws_col;
|
|
||||||
} screen_size;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void do_field(const PQprintOpt *po, const PGresult *res,
|
static void do_field(const PQprintOpt *po, const PGresult *res,
|
||||||
@ -103,6 +92,15 @@ PQprint(FILE *fout,
|
|||||||
int usePipe = 0;
|
int usePipe = 0;
|
||||||
pqsigfunc oldsigpipehandler = NULL;
|
pqsigfunc oldsigpipehandler = NULL;
|
||||||
char *pagerenv;
|
char *pagerenv;
|
||||||
|
#ifdef TIOCGWINSZ
|
||||||
|
struct winsize screen_size;
|
||||||
|
#else
|
||||||
|
struct winsize
|
||||||
|
{
|
||||||
|
int ws_row;
|
||||||
|
int ws_col;
|
||||||
|
} screen_size;
|
||||||
|
#endif
|
||||||
|
|
||||||
nTups = PQntuples(res);
|
nTups = PQntuples(res);
|
||||||
if (!(fieldNames = (const char **) calloc(nFields, sizeof(char *))))
|
if (!(fieldNames = (const char **) calloc(nFields, sizeof(char *))))
|
||||||
@ -151,17 +149,21 @@ PQprint(FILE *fout,
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* try to pipe to the pager program if possible */
|
/*
|
||||||
|
* If we think there'll be more than one screen of output,
|
||||||
|
* try to pipe to the pager program.
|
||||||
|
*/
|
||||||
#ifdef TIOCGWINSZ
|
#ifdef TIOCGWINSZ
|
||||||
if (ioctl(fileno(stdout), TIOCGWINSZ, &screen_size) == -1 ||
|
if (ioctl(fileno(stdout), TIOCGWINSZ, &screen_size) == -1 ||
|
||||||
screen_size.ws_col == 0 ||
|
screen_size.ws_col == 0 ||
|
||||||
screen_size.ws_row == 0)
|
screen_size.ws_row == 0)
|
||||||
{
|
{
|
||||||
#endif
|
|
||||||
screen_size.ws_row = 24;
|
screen_size.ws_row = 24;
|
||||||
screen_size.ws_col = 80;
|
screen_size.ws_col = 80;
|
||||||
#ifdef TIOCGWINSZ
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
screen_size.ws_row = 24;
|
||||||
|
screen_size.ws_col = 80;
|
||||||
#endif
|
#endif
|
||||||
pagerenv = getenv("PAGER");
|
pagerenv = getenv("PAGER");
|
||||||
if (pagerenv != NULL &&
|
if (pagerenv != NULL &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user