|
10 | 10 | * didn't really belong there.
|
11 | 11 | *
|
12 | 12 | * IDENTIFICATION
|
13 |
| - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.38 2000/05/29 21:25:04 momjian Exp $ |
| 13 | + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.39 2001/01/06 17:43:01 tgl Exp $ |
14 | 14 | *
|
15 | 15 | *-------------------------------------------------------------------------
|
16 | 16 | */
|
17 | 17 | #include"postgres.h"
|
18 | 18 |
|
19 | 19 | #include<signal.h>
|
20 |
| -#include"libpq-fe.h" |
21 |
| -#include"libpq-int.h" |
22 |
| -#include"pqsignal.h" |
23 | 20 |
|
24 | 21 | #ifdefWIN32
|
25 | 22 | #include"win32.h"
|
|
36 | 33 | #endif
|
37 | 34 | #endif
|
38 | 35 |
|
39 |
| -#ifdefTIOCGWINSZ |
40 |
| -staticstructwinsizescreen_size; |
41 |
| - |
42 |
| -#else |
43 |
| -staticstructwinsize |
44 |
| -{ |
45 |
| -intws_row; |
46 |
| -intws_col; |
47 |
| -}screen_size; |
48 |
| - |
49 |
| -#endif |
| 36 | +#include"libpq-fe.h" |
| 37 | +#include"libpq-int.h" |
| 38 | +#include"pqsignal.h" |
50 | 39 |
|
51 | 40 |
|
52 | 41 | staticvoiddo_field(constPQprintOpt*po,constPGresult*res,
|
@@ -103,6 +92,15 @@ PQprint(FILE *fout,
|
103 | 92 | intusePipe=0;
|
104 | 93 | pqsigfuncoldsigpipehandler=NULL;
|
105 | 94 | char*pagerenv;
|
| 95 | +#ifdefTIOCGWINSZ |
| 96 | +structwinsizescreen_size; |
| 97 | +#else |
| 98 | +structwinsize |
| 99 | +{ |
| 100 | +intws_row; |
| 101 | +intws_col; |
| 102 | +}screen_size; |
| 103 | +#endif |
106 | 104 |
|
107 | 105 | nTups=PQntuples(res);
|
108 | 106 | if (!(fieldNames= (constchar**)calloc(nFields,sizeof(char*))))
|
@@ -151,17 +149,21 @@ PQprint(FILE *fout,
|
151 | 149 | #endif
|
152 | 150 | )
|
153 | 151 | {
|
154 |
| -/* try to pipe to the pager program if possible */ |
| 152 | +/* |
| 153 | + * If we think there'll be more than one screen of output, |
| 154 | + * try to pipe to the pager program. |
| 155 | + */ |
155 | 156 | #ifdefTIOCGWINSZ
|
156 | 157 | if (ioctl(fileno(stdout),TIOCGWINSZ,&screen_size)==-1||
|
157 | 158 | screen_size.ws_col==0||
|
158 | 159 | screen_size.ws_row==0)
|
159 | 160 | {
|
160 |
| -#endif |
161 | 161 | screen_size.ws_row=24;
|
162 | 162 | screen_size.ws_col=80;
|
163 |
| -#ifdefTIOCGWINSZ |
164 | 163 | }
|
| 164 | +#else |
| 165 | +screen_size.ws_row=24; |
| 166 | +screen_size.ws_col=80; |
165 | 167 | #endif
|
166 | 168 | pagerenv=getenv("PAGER");
|
167 | 169 | if (pagerenv!=NULL&&
|
|