mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Fix printf() quote handling and improper exit(), per Tom.
This commit is contained in:
parent
9a9825f96a
commit
847f8b39d7
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2000 by PostgreSQL Global Development Group
|
* Copyright 2000 by PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.20 2002/09/05 22:05:50 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.21 2002/09/06 02:33:46 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
@ -30,7 +30,7 @@ static void finishInput(void);
|
|||||||
static void finishInput(int, void *);
|
static void finishInput(int, void *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PSQLHISTORY "/.psql_history"
|
#define PSQLHISTORY ".psql_history"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -144,12 +144,12 @@ initializeInput(int flags)
|
|||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
if (home)
|
if (home)
|
||||||
{
|
{
|
||||||
char *psql_history = (char *) malloc(strlen(home) +
|
char *psql_history = (char *) malloc(strlen(home) + 1 +
|
||||||
strlen(PSQLHISTORY) + 1);
|
strlen(PSQLHISTORY) + 1);
|
||||||
|
|
||||||
if (psql_history)
|
if (psql_history)
|
||||||
{
|
{
|
||||||
sprintf(psql_history, "%s" PSQLHISTORY, home);
|
sprintf(psql_history, "%s/%s", home, PSQLHISTORY);
|
||||||
read_history(psql_history);
|
read_history(psql_history);
|
||||||
free(psql_history);
|
free(psql_history);
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ finishInput(int exitstatus, void *arg)
|
|||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
if (home)
|
if (home)
|
||||||
{
|
{
|
||||||
psql_history = (char *) malloc(strlen(home) +
|
psql_history = (char *) malloc(strlen(home) + 1 +
|
||||||
strlen(PSQLHISTORY) + 1);
|
strlen(PSQLHISTORY) + 1);
|
||||||
if (psql_history)
|
if (psql_history)
|
||||||
{
|
{
|
||||||
@ -212,7 +212,7 @@ finishInput(int exitstatus, void *arg)
|
|||||||
|
|
||||||
if (var)
|
if (var)
|
||||||
stifle_history(atoi(var));
|
stifle_history(atoi(var));
|
||||||
sprintf(psql_history, "%s" PSQLHISTORY, home);
|
sprintf(psql_history, "%s/%s", home, PSQLHISTORY);
|
||||||
write_history(psql_history);
|
write_history(psql_history);
|
||||||
free(psql_history);
|
free(psql_history);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2000 by PostgreSQL Global Development Group
|
* Copyright 2000 by PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.65 2002/09/05 22:05:50 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.66 2002/09/06 02:33:47 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
|
|
||||||
@ -42,7 +42,7 @@
|
|||||||
*/
|
*/
|
||||||
PsqlSettings pset;
|
PsqlSettings pset;
|
||||||
|
|
||||||
#define PSQLRC "/.psqlrc"
|
#define PSQLRC ".psqlrc"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structures to pass information between the option parsing routine
|
* Structures to pass information between the option parsing routine
|
||||||
@ -605,7 +605,7 @@ process_psqlrc(void)
|
|||||||
|
|
||||||
if (home)
|
if (home)
|
||||||
{
|
{
|
||||||
psqlrc = malloc(strlen(home) + strlen(PSQLRC) + 1 +
|
psqlrc = malloc(strlen(home) + 1 + strlen(PSQLRC) + 1 +
|
||||||
strlen(PG_VERSION) + 1);
|
strlen(PG_VERSION) + 1);
|
||||||
if (!psqlrc)
|
if (!psqlrc)
|
||||||
{
|
{
|
||||||
@ -613,12 +613,12 @@ process_psqlrc(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(psqlrc, "%s" PSQLRC "-" PG_VERSION, home);
|
sprintf(psqlrc, "%s/%s-%s", home, PSQLRC, PG_VERSION);
|
||||||
if (access(psqlrc, R_OK) == 0)
|
if (access(psqlrc, R_OK) == 0)
|
||||||
process_file(psqlrc);
|
process_file(psqlrc);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(psqlrc, "%s" PSQLRC, home);
|
sprintf(psqlrc, "%s/%s", home, PSQLRC);
|
||||||
if (access(psqlrc, R_OK) == 0)
|
if (access(psqlrc, R_OK) == 0)
|
||||||
process_file(psqlrc);
|
process_file(psqlrc);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.203 2002/09/05 22:24:23 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.204 2002/09/06 02:33:47 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -66,7 +66,7 @@ inet_aton(const char *cp, struct in_addr * inp)
|
|||||||
#define NOTIFYLIST_INITIAL_SIZE 10
|
#define NOTIFYLIST_INITIAL_SIZE 10
|
||||||
#define NOTIFYLIST_GROWBY 10
|
#define NOTIFYLIST_GROWBY 10
|
||||||
|
|
||||||
#define PGPASSFILE "/.pgpass"
|
#define PGPASSFILE ".pgpass"
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
* Definition of the conninfo parameters and their fallback resources.
|
* Definition of the conninfo parameters and their fallback resources.
|
||||||
@ -2927,18 +2927,17 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
|
|||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
if (home)
|
if (home)
|
||||||
{
|
{
|
||||||
pgpassfile = malloc(strlen(home) + strlen(PGPASSFILE) + 1);
|
pgpassfile = malloc(strlen(home) + 1 + strlen(PGPASSFILE) + 1);
|
||||||
if (!pgpassfile)
|
if (!pgpassfile)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||||
exit(EXIT_FAILURE);
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sprintf(pgpassfile, "%s" PGPASSFILE, home);
|
sprintf(pgpassfile, "%s/%s", home, PGPASSFILE);
|
||||||
|
|
||||||
/* If password file cannot be opened, ignore it. */
|
/* If password file cannot be opened, ignore it. */
|
||||||
if (stat(pgpassfile, &stat_buf) == -1)
|
if (stat(pgpassfile, &stat_buf) == -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user