Skip to content

Commit e0e7589

Browse files
committed
Make Win32 build use our port/snprintf.c routines, instead of depending
on libintl which may or may not provide what we need. Make a few marginal cleanups to ensure this works. Andrew Dunstan and Tom Lane.
1 parent 1daac8e commit e0e7589

File tree

8 files changed

+57
-47
lines changed

8 files changed

+57
-47
lines changed

configure

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13893,7 +13893,11 @@ fi
1389313893
# also decide to use snprintf.c if snprintf() is present but does not
1389413894
# have all the features we need --- see below.
1389513895

13896-
pgac_need_repl_snprintf=no
13896+
if test "$PORTNAME" = "win32"; then
13897+
# Win32 gets this built unconditionally
13898+
pgac_need_repl_snprintf=yes
13899+
else
13900+
pgac_need_repl_snprintf=no
1389713901

1389813902
for ac_func in snprintf
1389913903
do
@@ -14102,6 +14106,7 @@ else
1410214106
fi
1410314107
done
1410414108

14109+
fi
1410514110

1410614111

1410714112
# Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
@@ -17151,14 +17156,8 @@ fi
1715117156

1715217157

1715317158
# Force use of our snprintf if system's doesn't do arg control
17154-
# This feature is used by NLS
17155-
if test "$enable_nls" = yes &&
17156-
test $pgac_need_repl_snprintf = no &&
17157-
# On Win32, libintl replaces snprintf() with its own version that
17158-
# understands arg control, so we don't need our own. In fact, it
17159-
# also uses macros that conflict with ours, so we _can't_ use
17160-
# our own.
17161-
test "$PORTNAME" != "win32"; then
17159+
# This feature is needed by NLS
17160+
if test "$enable_nls" = yes -a "$pgac_need_repl_snprintf" = no; then
1716217161
echo "$as_me:$LINENO: checking whether printf supports argument control" >&5
1716317162
echo $ECHO_N "checking whether printf supports argument control... $ECHO_C" >&6
1716417163
if test "${pgac_cv_printf_arg_control+set}" = set; then
@@ -17645,7 +17644,7 @@ _ACEOF
1764517644
if test $pgac_need_repl_snprintf = yes; then
1764617645

1764717646
cat >>confdefs.h <<\_ACEOF
17648-
#define USE_SNPRINTF 1
17647+
#define USE_REPL_SNPRINTF 1
1764917648
_ACEOF
1765017649

1765117650
case $LIBOBJS in

configure.in

Lines changed: 12 additions & 13 deletions
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.433 2005/12/04 03:52:24 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.434 2005/12/06 02:29:03 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -857,9 +857,14 @@ fi
857857
# also decide to use snprintf.c if snprintf() is present but does not
858858
# have all the features we need --- see below.
859859

860-
pgac_need_repl_snprintf=no
861-
AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
862-
AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
860+
if test "$PORTNAME" = "win32"; then
861+
# Win32 gets this built unconditionally
862+
pgac_need_repl_snprintf=yes
863+
else
864+
pgac_need_repl_snprintf=no
865+
AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
866+
AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
867+
fi
863868

864869

865870
# Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
@@ -1052,14 +1057,8 @@ AC_MSG_ERROR([[
10521057

10531058

10541059
# Force use of our snprintf if system's doesn't do arg control
1055-
# This feature is used by NLS
1056-
if test "$enable_nls" = yes &&
1057-
test $pgac_need_repl_snprintf = no &&
1058-
# On Win32, libintl replaces snprintf() with its own version that
1059-
# understands arg control, so we don't need our own. In fact, it
1060-
# also uses macros that conflict with ours, so we _can't_ use
1061-
# our own.
1062-
test "$PORTNAME" != "win32"; then
1060+
# This feature is needed by NLS
1061+
if test "$enable_nls" = yes -a "$pgac_need_repl_snprintf" = no; then
10631062
PGAC_FUNC_PRINTF_ARG_CONTROL
10641063
if test $pgac_cv_printf_arg_control != yes ; then
10651064
pgac_need_repl_snprintf=yes
@@ -1134,7 +1133,7 @@ AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT,
11341133

11351134
# Now we have checked all the reasons to replace snprintf
11361135
if test $pgac_need_repl_snprintf = yes; then
1137-
AC_DEFINE(USE_SNPRINTF, 1, [Use replacement snprintf() functions.])
1136+
AC_DEFINE(USE_REPL_SNPRINTF, 1, [Use replacement snprintf() functions.])
11381137
AC_LIBOBJ(snprintf)
11391138
fi
11401139

src/include/c.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/include/c.h,v 1.191 2005/11/17 22:14:54 tgl Exp $
15+
* $PostgreSQL: pgsql/src/include/c.h,v 1.192 2005/12/06 02:29:03 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -101,9 +101,8 @@
101101
#endif
102102

103103
/*
104-
* These strings are to be translation via xgettext. We can't
105-
* call gettext() because it is located in variable initialization and
106-
* a function call can not be used.
104+
* Use this to mark strings to be translated by gettext, in places where
105+
* you don't want an actual function call to occur (eg, constant tables).
107106
*/
108107
#define gettext_noop(x) (x)
109108

src/include/pg_config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@
640640
#undef USE_PAM
641641

642642
/* Use replacement snprintf() functions. */
643-
#undef USE_SNPRINTF
643+
#undef USE_REPL_SNPRINTF
644644

645645
/* Define to build with (Open)SSL support. (--with-openssl) */
646646
#undef USE_SSL

src/include/pg_config.h.win32

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#define HAVE_RANDOM
2424
#endif
2525

26-
/* use _snprintf instead of snprintf */
27-
#define HAVE_DECL_SNPRINTF 1
28-
#define snprintf _snprintf
29-
3026
/* defines for dynamic linking on Win32 platform */
3127
#ifdef __CYGWIN__
3228

src/include/port.h

Lines changed: 25 additions & 3 deletions
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.84 2005/10/15 02:49:41 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.85 2005/12/06 02:29:03 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -112,7 +112,8 @@ extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
112112
extern unsigned char pg_toupper(unsigned char ch);
113113
extern unsigned char pg_tolower(unsigned char ch);
114114

115-
#ifdef USE_SNPRINTF
115+
#ifdef USE_REPL_SNPRINTF
116+
116117
extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
117118
extern int
118119
pg_snprintf(char *str, size_t count, const char *fmt,...)
@@ -131,6 +132,26 @@ pg_printf(const char *fmt,...)
131132
/* This extension allows gcc to check the format string */
132133
__attribute__((format(printf, 1, 2)));
133134

135+
/*
136+
* Some versions of libintl try to replace printf and friends with macros;
137+
* if we are doing likewise, make sure our versions win.
138+
*/
139+
#ifdef vsnprintf
140+
#undef vsnprintf
141+
#endif
142+
#ifdef snprintf
143+
#undef snprintf
144+
#endif
145+
#ifdef sprintf
146+
#undef sprintf
147+
#endif
148+
#ifdef fprintf
149+
#undef fprintf
150+
#endif
151+
#ifdef printf
152+
#undef printf
153+
#endif
154+
134155
/*
135156
* The GCC-specific code below prevents the __attribute__(... 'printf')
136157
* above from being replaced, and this is required because gcc doesn't
@@ -149,7 +170,8 @@ __attribute__((format(printf, 1, 2)));
149170
#define fprintf pg_fprintf
150171
#define printf pg_printf
151172
#endif
152-
#endif
173+
174+
#endif /* USE_REPL_SNPRINTF */
153175

154176
/* Portable prompt handling */
155177
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);

src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.34 2005/11/30 12:49:49 meskes Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.35 2005/12/06 02:29:04 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -21,11 +21,12 @@ override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \
2121
-I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)
2222
override CFLAGS += $(PTHREAD_CFLAGS)
2323

24-
# Need to recomple any libpgport object files
25-
LIBS := $(patsubst -lpgport,, $(LIBS))
24+
# Need to recompile any libpgport object files
25+
LIBS := $(filter-out -lpgport, $(LIBS))
2626

2727
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
28-
connect.o misc.o path.o exec.o
28+
connect.o misc.o path.o exec.o \
29+
$(filter snprintf.o, $(LIBOBJS))
2930

3031
SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) \
3132
$(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lm, $(LIBS)) $(PTHREAD_LIBS)
@@ -45,10 +46,7 @@ include $(top_srcdir)/src/Makefile.shlib
4546
# necessarily use the same object files as the backend uses. Instead,
4647
# symlink the source files in here and build our own object file.
4748

48-
path.c: % : $(top_srcdir)/src/port/%
49-
rm -f $@ && $(LN_S) $< .
50-
51-
exec.c: % : $(top_srcdir)/src/port/%
49+
path.c exec.c snprintf.c: % : $(top_srcdir)/src/port/%
5250
rm -f $@ && $(LN_S) $< .
5351

5452
path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
@@ -64,7 +62,7 @@ installdirs:
6462
uninstall: uninstall-lib
6563

6664
clean distclean maintainer-clean: clean-lib
67-
rm -f $(OBJS) path.c exec.c
65+
rm -f $(OBJS) path.c exec.c snprintf.c
6866

6967
depend dep:
7068
$(CC) -MM $(CFLAGS) *.c >depend

src/interfaces/libpq/win32.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#define write(a,b,c) _write(a,b,c)
1717
#endif
1818

19-
#define vsnprintf(a,b,c,d) _vsnprintf(a,b,c,d)
20-
#define snprintf _snprintf
21-
2219
#undef EAGAIN /* doesn't apply on sockets */
2320
#undef EINTR
2421
#define EINTR WSAEINTR

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy