mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Define snprintf() to call pg_snprintf() so our own snprintf-like
implementation doesn't export out via libpq and get used by a user application.
This commit is contained in:
parent
6521cd9ae1
commit
3bc6bdf322
5
configure
vendored
5
configure
vendored
@ -14973,6 +14973,11 @@ _ACEOF
|
|||||||
|
|
||||||
# Now we have checked all the reasons to replace snprintf
|
# Now we have checked all the reasons to replace snprintf
|
||||||
if test $pgac_need_repl_snprintf = yes; then
|
if test $pgac_need_repl_snprintf = yes; then
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define USE_SNPRINTF 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
LIBOBJS="$LIBOBJS snprintf.$ac_objext"
|
LIBOBJS="$LIBOBJS snprintf.$ac_objext"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
dnl $PostgreSQL: pgsql/configure.in,v 1.405 2005/03/02 15:42:35 momjian Exp $
|
dnl $PostgreSQL: pgsql/configure.in,v 1.406 2005/03/11 17:20:33 momjian Exp $
|
||||||
dnl
|
dnl
|
||||||
dnl Developers, please strive to achieve this order:
|
dnl Developers, please strive to achieve this order:
|
||||||
dnl
|
dnl
|
||||||
@ -1143,6 +1143,7 @@ AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT,
|
|||||||
|
|
||||||
# Now we have checked all the reasons to replace snprintf
|
# Now we have checked all the reasons to replace snprintf
|
||||||
if test $pgac_need_repl_snprintf = yes; then
|
if test $pgac_need_repl_snprintf = yes; then
|
||||||
|
AC_DEFINE(USE_SNPRINTF, 1, [Use replacement snprintf() functions.])
|
||||||
AC_LIBOBJ(snprintf)
|
AC_LIBOBJ(snprintf)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.54 2005/02/22 04:39:22 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.55 2005/03/11 17:20:33 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -337,19 +337,23 @@ start_postmaster(void)
|
|||||||
if (log_file != NULL)
|
if (log_file != NULL)
|
||||||
#ifndef WIN32 /* Cygwin doesn't have START */
|
#ifndef WIN32 /* Cygwin doesn't have START */
|
||||||
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
|
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
|
||||||
#else
|
|
||||||
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
|
|
||||||
#endif
|
|
||||||
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
|
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
|
||||||
DEVNULL, log_file, SYSTEMQUOTE);
|
DEVNULL, log_file, SYSTEMQUOTE);
|
||||||
|
#else
|
||||||
|
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
|
||||||
|
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
|
||||||
|
DEVNULL, log_file, SYSTEMQUOTE);
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
#ifndef WIN32 /* Cygwin doesn't have START */
|
#ifndef WIN32 /* Cygwin doesn't have START */
|
||||||
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
|
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
|
||||||
#else
|
|
||||||
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
|
|
||||||
#endif
|
|
||||||
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
|
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
|
||||||
DEVNULL, SYSTEMQUOTE);
|
DEVNULL, SYSTEMQUOTE);
|
||||||
|
#else
|
||||||
|
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
|
||||||
|
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
|
||||||
|
DEVNULL, SYSTEMQUOTE);
|
||||||
|
#endif
|
||||||
|
|
||||||
return system(cmd);
|
return system(cmd);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.140 2005/02/22 04:40:51 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.141 2005/03/11 17:20:34 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
@ -1175,13 +1175,13 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
|
|||||||
* supplied path unless we use only backslashes, so we do that.
|
* supplied path unless we use only backslashes, so we do that.
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir,
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
"/",
|
snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir,
|
||||||
|
"/", (int)getpid());
|
||||||
#else
|
#else
|
||||||
"", /* trailing separator already present */
|
snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir,
|
||||||
|
"" /* trailing separator already present */, (int)getpid());
|
||||||
#endif
|
#endif
|
||||||
(int)getpid());
|
|
||||||
|
|
||||||
fname = (const char *) fnametmp;
|
fname = (const char *) fnametmp;
|
||||||
|
|
||||||
|
@ -648,6 +648,9 @@
|
|||||||
/* Define to 1 to build with Rendezvous support. (--with-rendezvous) */
|
/* Define to 1 to build with Rendezvous support. (--with-rendezvous) */
|
||||||
#undef USE_RENDEZVOUS
|
#undef USE_RENDEZVOUS
|
||||||
|
|
||||||
|
/* Use replacement snprintf() functions. */
|
||||||
|
#undef USE_SNPRINTF
|
||||||
|
|
||||||
/* Define to build with (Open)SSL support. (--with-openssl) */
|
/* Define to build with (Open)SSL support. (--with-openssl) */
|
||||||
#undef USE_SSL
|
#undef USE_SSL
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/port.h,v 1.70 2005/02/27 00:53:29 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/port.h,v 1.71 2005/03/11 17:20:34 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -107,6 +107,26 @@ extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
|
|||||||
extern unsigned char pg_toupper(unsigned char ch);
|
extern unsigned char pg_toupper(unsigned char ch);
|
||||||
extern unsigned char pg_tolower(unsigned char ch);
|
extern unsigned char pg_tolower(unsigned char ch);
|
||||||
|
|
||||||
|
#ifdef USE_SNPRINTF
|
||||||
|
extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
||||||
|
extern int pg_snprintf(char *str, size_t count, const char *fmt,...)
|
||||||
|
/* This extension allows gcc to check the format string */
|
||||||
|
__attribute__((format(printf, 3, 4)));
|
||||||
|
extern int pg_printf(const char *fmt,...)
|
||||||
|
/* This extension allows gcc to check the format string */
|
||||||
|
__attribute__((format(printf, 1, 2)));
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
|
||||||
|
#define snprintf(...) pg_snprintf(__VA_ARGS__)
|
||||||
|
#define printf(...) pg_printf(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define vsnprintf pg_vsnprintf
|
||||||
|
#define snprintf pg_snprintf
|
||||||
|
#define printf pg_printf
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Portable prompt handling */
|
/* Portable prompt handling */
|
||||||
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
|
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
|
||||||
|
|
||||||
|
@ -65,19 +65,15 @@
|
|||||||
* causing nasty effects.
|
* causing nasty effects.
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
|
|
||||||
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.16 2005/03/02 23:56:53 momjian Exp $";*/
|
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.17 2005/03/11 17:20:35 momjian Exp $";*/
|
||||||
|
|
||||||
int snprintf(char *str, size_t count, const char *fmt,...);
|
int pg_snprintf(char *str, size_t count, const char *fmt,...);
|
||||||
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
||||||
int printf(const char *format, ...);
|
int pg_printf(const char *format, ...);
|
||||||
static void dopr(char *buffer, const char *format, va_list args, char *end);
|
static void dopr(char *buffer, const char *format, va_list args, char *end);
|
||||||
|
|
||||||
/*
|
|
||||||
* If vsnprintf() is not before snprintf() in this file, snprintf()
|
|
||||||
* will call the system vsnprintf() on MinGW.
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
|
pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
str[0] = '\0';
|
str[0] = '\0';
|
||||||
@ -89,19 +85,19 @@ vsnprintf(char *str, size_t count, const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
snprintf(char *str, size_t count, const char *fmt,...)
|
pg_snprintf(char *str, size_t count, const char *fmt,...)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
len = vsnprintf(str, count, fmt, args);
|
len = pg_vsnprintf(str, count, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
printf(const char *fmt,...)
|
pg_printf(const char *fmt,...)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -109,7 +105,7 @@ printf(const char *fmt,...)
|
|||||||
char* p;
|
char* p;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
len = vsnprintf((char*)buffer, (size_t)4096, fmt, args);
|
len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
p = (char*)buffer;
|
p = (char*)buffer;
|
||||||
for(;*p;p++)
|
for(;*p;p++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user