Consolidate various backported functions

This commit is contained in:
Ian Barwick
2016-12-22 12:11:54 +09:00
parent 666e71a589
commit 9da0914976
7 changed files with 44 additions and 42 deletions

View File

@@ -89,37 +89,6 @@ maxlen_snprintf(char *str, const char *format,...)
}
/*
* Adapted from: src/fe_utils/string_utils.c
*
* Function not publicly available before PostgreSQL 9.6.
*/
void
appendShellString(PQExpBuffer buf, const char *str)
{
const char *p;
appendPQExpBufferChar(buf, '\'');
for (p = str; *p; p++)
{
if (*p == '\n' || *p == '\r')
{
fprintf(stderr,
_("shell command argument contains a newline or carriage return: \"%s\"\n"),
str);
exit(ERR_BAD_CONFIG);
}
if (*p == '\'')
appendPQExpBufferStr(buf, "'\"'\"'");
else
appendPQExpBufferChar(buf, *p);
}
appendPQExpBufferChar(buf, '\'');
}
/*
* Escape a string for use as a parameter in recovery.conf
* Caller must free returned value