From 1e9199e84c26eca7bdd49b47c1c627d4f3a60747 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 12 May 2008 22:59:58 +0000 Subject: Improve psql's internal print.c code by introducing an actual print API. Provides for better code readability, but mainly this is infrastructure changes to allow further changes such as arbitrary footers on printed tables. Also, the translation status of each element in the table is more easily customized. Brendan Jurd, with some editorialization by me. --- src/bin/scripts/common.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/bin/scripts/common.c') diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index b1ca5bb71d5..ea1fa0f2762 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.31 2008/01/01 19:45:56 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.32 2008/05/12 22:59:58 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -229,6 +229,27 @@ executeMaintenanceCommand(PGconn *conn, const char *query, bool echo) return r; } +/* + * "Safe" wrapper around strdup(). Pulled from psql/common.c + */ +char * +pg_strdup(const char *string) +{ + char *tmp; + + if (!string) + { + fprintf(stderr, _("pg_strdup: cannot duplicate null pointer (internal error)\n")); + exit(EXIT_FAILURE); + } + tmp = strdup(string); + if (!tmp) + { + fprintf(stderr, _("out of memory\n")); + exit(EXIT_FAILURE); + } + return tmp; +} /* * Check yes/no answer in a localized way. 1=yes, 0=no, -1=neither. @@ -274,7 +295,6 @@ yesno_prompt(const char *question) } } - /* * SetCancelConn * -- cgit v1.2.3