summaryrefslogtreecommitdiff
path: root/src/bin/scripts/common.c
diff options
context:
space:
mode:
authorAlvaro Herrera2008-05-12 22:59:58 +0000
committerAlvaro Herrera2008-05-12 22:59:58 +0000
commit1e9199e84c26eca7bdd49b47c1c627d4f3a60747 (patch)
tree26843bb2253a3e61fd97b2d152f529fd6c3799ca /src/bin/scripts/common.c
parent9340c6372f78206cb5769a0ea4e0aa85a7e134e0 (diff)
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.
Diffstat (limited to 'src/bin/scripts/common.c')
-rw-r--r--src/bin/scripts/common.c24
1 files changed, 22 insertions, 2 deletions
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
*