1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-27 22:56:53 +03:00

Clean up failure to use ClosePager() where appropriate in help.c.

Also prevent possible repeat opening of pager in helpSQL().
This commit is contained in:
Tom Lane 2010-08-13 20:56:18 +00:00
parent debcec7dc3
commit 36ba263d8f

View File

@ -3,12 +3,10 @@
* *
* Copyright (c) 2000-2010, PostgreSQL Global Development Group * Copyright (c) 2000-2010, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.161 2010/08/12 00:40:59 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.162 2010/08/13 20:56:18 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include <signal.h>
#ifndef WIN32 #ifndef WIN32
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
#include <pwd.h> /* for getpwuid() */ #include <pwd.h> /* for getpwuid() */
@ -27,8 +25,6 @@
#include <termios.h> #include <termios.h>
#endif #endif
#include "pqsignal.h"
#include "common.h" #include "common.h"
#include "help.h" #include "help.h"
#include "input.h" #include "input.h"
@ -271,13 +267,7 @@ slashUsage(unsigned short int pager)
" \\lo_list\n" " \\lo_list\n"
" \\lo_unlink LOBOID large object operations\n")); " \\lo_unlink LOBOID large object operations\n"));
if (output != stdout) ClosePager(output);
{
pclose(output);
#ifndef WIN32
pqsignal(SIGPIPE, SIG_DFL);
#endif
}
} }
@ -334,14 +324,7 @@ helpSQL(const char *topic, unsigned short int pager)
fputc('\n', output); fputc('\n', output);
} }
/* Only close if we used the pager */ ClosePager(output);
if (output != stdout)
{
pclose(output);
#ifndef WIN32
pqsignal(SIGPIPE, SIG_DFL);
#endif
}
} }
else else
{ {
@ -349,7 +332,7 @@ helpSQL(const char *topic, unsigned short int pager)
j, j,
x = 0; x = 0;
bool help_found = false; bool help_found = false;
FILE *output; FILE *output = NULL;
size_t len, size_t len,
wordlen; wordlen;
int nl_count = 0; int nl_count = 0;
@ -376,7 +359,8 @@ helpSQL(const char *topic, unsigned short int pager)
} }
if (wordlen >= len) /* Don't try again if the same word */ if (wordlen >= len) /* Don't try again if the same word */
{ {
output = PageOutput(nl_count, pager); if (!output)
output = PageOutput(nl_count, pager);
break; break;
} }
len = wordlen; len = wordlen;
@ -396,7 +380,8 @@ helpSQL(const char *topic, unsigned short int pager)
} }
} }
output = PageOutput(nl_count, pager); if (!output)
output = PageOutput(nl_count, pager);
for (i = 0; QL_HELP[i].cmd; i++) for (i = 0; QL_HELP[i].cmd; i++)
{ {
@ -426,14 +411,7 @@ helpSQL(const char *topic, unsigned short int pager)
if (!help_found) if (!help_found)
fprintf(output, _("No help available for \"%s\".\nTry \\h with no arguments to see available help.\n"), topic); fprintf(output, _("No help available for \"%s\".\nTry \\h with no arguments to see available help.\n"), topic);
/* Only close if we used the pager */ ClosePager(output);
if (output != stdout)
{
pclose(output);
#ifndef WIN32
pqsignal(SIGPIPE, SIG_DFL);
#endif
}
} }
} }