Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3bc6bdf

Browse files
committed
Define snprintf() to call pg_snprintf() so our own snprintf-like
implementation doesn't export out via libpq and get used by a userapplication.
1 parent6521cd9 commit3bc6bdf

File tree

7 files changed

+52
-23
lines changed

7 files changed

+52
-23
lines changed

‎configure

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14973,6 +14973,11 @@ _ACEOF
1497314973

1497414974
# Now we have checked all the reasons to replace snprintf
1497514975
if test $pgac_need_repl_snprintf = yes; then
14976+
14977+
cat >>confdefs.h <<\_ACEOF
14978+
#define USE_SNPRINTF 1
14979+
_ACEOF
14980+
1497614981
LIBOBJS="$LIBOBJS snprintf.$ac_objext"
1497714982
fi
1497814983

‎configure.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.405 2005/03/02 15:42:35 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.406 2005/03/11 17:20:33 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1143,6 +1143,7 @@ AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT,
11431143

11441144
# Now we have checked all the reasons to replace snprintf
11451145
if test $pgac_need_repl_snprintf = yes; then
1146+
AC_DEFINE(USE_SNPRINTF, 1, [Use replacement snprintf() functions.])
11461147
AC_LIBOBJ(snprintf)
11471148
fi
11481149

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.54 2005/02/22 04:39:22 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.55 2005/03/11 17:20:33 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -337,19 +337,23 @@ start_postmaster(void)
337337
if (log_file!=NULL)
338338
#ifndefWIN32/* Cygwin doesn't have START */
339339
snprintf(cmd,MAXPGPATH,"%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
340+
SYSTEMQUOTE,postgres_path,pgdata_opt,post_opts,
341+
DEVNULL,log_file,SYSTEMQUOTE);
340342
#else
341343
snprintf(cmd,MAXPGPATH,"%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
342-
#endif
343344
SYSTEMQUOTE,postgres_path,pgdata_opt,post_opts,
344345
DEVNULL,log_file,SYSTEMQUOTE);
346+
#endif
345347
else
346348
#ifndefWIN32/* Cygwin doesn't have START */
347349
snprintf(cmd,MAXPGPATH,"%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
350+
SYSTEMQUOTE,postgres_path,pgdata_opt,post_opts,
351+
DEVNULL,SYSTEMQUOTE);
348352
#else
349353
snprintf(cmd,MAXPGPATH,"%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
350-
#endif
351354
SYSTEMQUOTE,postgres_path,pgdata_opt,post_opts,
352355
DEVNULL,SYSTEMQUOTE);
356+
#endif
353357

354358
returnsystem(cmd);
355359
}

‎src/bin/psql/command.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.140 2005/02/22 04:40:51 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.141 2005/03/11 17:20:34 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -1175,13 +1175,13 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
11751175
*supplied path unless we use only backslashes, so we do that.
11761176
*/
11771177
#endif
1178-
snprintf(fnametmp,sizeof(fnametmp),"%s%spsql.edit.%d",tmpdir,
11791178
#ifndefWIN32
1180-
"/",
1179+
snprintf(fnametmp,sizeof(fnametmp),"%s%spsql.edit.%d",tmpdir,
1180+
"/", (int)getpid());
11811181
#else
1182-
"",/* trailing separator already present */
1182+
snprintf(fnametmp,sizeof(fnametmp),"%s%spsql.edit.%d",tmpdir,
1183+
""/* trailing separator already present */, (int)getpid());
11831184
#endif
1184-
(int)getpid());
11851185

11861186
fname= (constchar*)fnametmp;
11871187

‎src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@
648648
/* Define to 1 to build with Rendezvous support. (--with-rendezvous) */
649649
#undef USE_RENDEZVOUS
650650

651+
/* Use replacement snprintf() functions. */
652+
#undef USE_SNPRINTF
653+
651654
/* Define to build with (Open)SSL support. (--with-openssl) */
652655
#undef USE_SSL
653656

‎src/include/port.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.70 2005/02/27 00:53:29 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.71 2005/03/11 17:20:34 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -107,6 +107,26 @@ extern intpg_strncasecmp(const char *s1, const char *s2, size_t n);
107107
externunsignedcharpg_toupper(unsignedcharch);
108108
externunsignedcharpg_tolower(unsignedcharch);
109109

110+
#ifdefUSE_SNPRINTF
111+
externintpg_vsnprintf(char*str,size_tcount,constchar*fmt,va_listargs);
112+
externintpg_snprintf(char*str,size_tcount,constchar*fmt,...)
113+
/* This extension allows gcc to check the format string */
114+
__attribute__((format(printf,3,4)));
115+
externintpg_printf(constchar*fmt,...)
116+
/* This extension allows gcc to check the format string */
117+
__attribute__((format(printf,1,2)));
118+
119+
#ifdef__GNUC__
120+
#definevsnprintf(...)pg_vsnprintf(__VA_ARGS__)
121+
#definesnprintf(...)pg_snprintf(__VA_ARGS__)
122+
#defineprintf(...)pg_printf(__VA_ARGS__)
123+
#else
124+
#definevsnprintfpg_vsnprintf
125+
#definesnprintfpg_snprintf
126+
#defineprintfpg_printf
127+
#endif
128+
#endif
129+
110130
/* Portable prompt handling */
111131
externchar*simple_prompt(constchar*prompt,intmaxlen,boolecho);
112132

‎src/port/snprintf.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,15 @@
6565
* causing nasty effects.
6666
**************************************************************/
6767

68-
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.16 2005/03/02 23:56:53 momjian Exp $";*/
68+
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.17 2005/03/11 17:20:35 momjian Exp $";*/
6969

70-
intsnprintf(char*str,size_tcount,constchar*fmt,...);
71-
intvsnprintf(char*str,size_tcount,constchar*fmt,va_listargs);
72-
intprintf(constchar*format, ...);
70+
intpg_snprintf(char*str,size_tcount,constchar*fmt,...);
71+
intpg_vsnprintf(char*str,size_tcount,constchar*fmt,va_listargs);
72+
intpg_printf(constchar*format, ...);
7373
staticvoiddopr(char*buffer,constchar*format,va_listargs,char*end);
7474

75-
/*
76-
*If vsnprintf() is not before snprintf() in this file, snprintf()
77-
*will call the system vsnprintf() on MinGW.
78-
*/
7975
int
80-
vsnprintf(char*str,size_tcount,constchar*fmt,va_listargs)
76+
pg_vsnprintf(char*str,size_tcount,constchar*fmt,va_listargs)
8177
{
8278
char*end;
8379
str[0]='\0';
@@ -89,27 +85,27 @@ vsnprintf(char *str, size_t count, const char *fmt, va_list args)
8985
}
9086

9187
int
92-
snprintf(char*str,size_tcount,constchar*fmt,...)
88+
pg_snprintf(char*str,size_tcount,constchar*fmt,...)
9389
{
9490
intlen;
9591
va_listargs;
9692

9793
va_start(args,fmt);
98-
len=vsnprintf(str,count,fmt,args);
94+
len=pg_vsnprintf(str,count,fmt,args);
9995
va_end(args);
10096
returnlen;
10197
}
10298

10399
int
104-
printf(constchar*fmt,...)
100+
pg_printf(constchar*fmt,...)
105101
{
106102
intlen;
107103
va_listargs;
108104
char*buffer[4096];
109105
char*p;
110106

111107
va_start(args,fmt);
112-
len=vsnprintf((char*)buffer, (size_t)4096,fmt,args);
108+
len=pg_vsnprintf((char*)buffer, (size_t)4096,fmt,args);
113109
va_end(args);
114110
p= (char*)buffer;
115111
for(;*p;p++)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp