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
commit0d54e9ee3ba4b3c70b80d9d0e87792959672aaa1 (patch)
tree2eddc03e2ed34f0bc00e72eb73c6f9302d878475 /src/bin/scripts/common.c
parent29958153cd796877beb3f5ab4851a9b81f3a7257 (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.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index 47e2a53226..9a022df378 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -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
*