3
3
*
4
4
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.161 2010/08/12 00:40:59 tgl Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.162 2010/08/13 20:56:18 tgl Exp $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
10
- #include <signal.h>
11
-
12
10
#ifndef WIN32
13
11
#ifdef HAVE_PWD_H
14
12
#include <pwd.h> /* for getpwuid() */
27
25
#include <termios.h>
28
26
#endif
29
27
30
- #include "pqsignal.h"
31
-
32
28
#include "common.h"
33
29
#include "help.h"
34
30
#include "input.h"
@@ -271,13 +267,7 @@ slashUsage(unsigned short int pager)
271
267
" \\lo_list\n"
272
268
" \\lo_unlink LOBOID large object operations\n" ));
273
269
274
- if (output != stdout )
275
- {
276
- pclose (output );
277
- #ifndef WIN32
278
- pqsignal (SIGPIPE , SIG_DFL );
279
- #endif
280
- }
270
+ ClosePager (output );
281
271
}
282
272
283
273
@@ -334,22 +324,15 @@ helpSQL(const char *topic, unsigned short int pager)
334
324
fputc ('\n' , output );
335
325
}
336
326
337
- /* Only close if we used the pager */
338
- if (output != stdout )
339
- {
340
- pclose (output );
341
- #ifndef WIN32
342
- pqsignal (SIGPIPE , SIG_DFL );
343
- #endif
344
- }
327
+ ClosePager (output );
345
328
}
346
329
else
347
330
{
348
331
int i ,
349
332
j ,
350
333
x = 0 ;
351
334
bool help_found = false;
352
- FILE * output ;
335
+ FILE * output = NULL ;
353
336
size_t len ,
354
337
wordlen ;
355
338
int nl_count = 0 ;
@@ -376,7 +359,8 @@ helpSQL(const char *topic, unsigned short int pager)
376
359
}
377
360
if (wordlen >= len ) /* Don't try again if the same word */
378
361
{
379
- output = PageOutput (nl_count , pager );
362
+ if (!output )
363
+ output = PageOutput (nl_count , pager );
380
364
break ;
381
365
}
382
366
len = wordlen ;
@@ -396,7 +380,8 @@ helpSQL(const char *topic, unsigned short int pager)
396
380
}
397
381
}
398
382
399
- output = PageOutput (nl_count , pager );
383
+ if (!output )
384
+ output = PageOutput (nl_count , pager );
400
385
401
386
for (i = 0 ; QL_HELP [i ].cmd ; i ++ )
402
387
{
@@ -426,14 +411,7 @@ helpSQL(const char *topic, unsigned short int pager)
426
411
if (!help_found )
427
412
fprintf (output , _ ("No help available for \"%s\".\nTry \\h with no arguments to see available help.\n" ), topic );
428
413
429
- /* Only close if we used the pager */
430
- if (output != stdout )
431
- {
432
- pclose (output );
433
- #ifndef WIN32
434
- pqsignal (SIGPIPE , SIG_DFL );
435
- #endif
436
- }
414
+ ClosePager (output );
437
415
}
438
416
}
439
417
0 commit comments