Tom Lane wrote:

Andrew Dunstan <[EMAIL PROTECTED]> writes:
The bad news: if we aren't compiling with NLS enabled, having those entries in exports.txt makes the libpq build blow up. So either we need to use pg_*printf unconditionally on Windows, or we need a little Makefile + sed magic to strip those entries out of exports.txt when it is used, if we're not doing NLS, or something of that kind.

I think it's a bad idea for exports.txt not to be the same in all
builds.  So yeah, if we export these names at all then it has to be
unconditional.

What about Plan B?  Per Bruce's comment, it should really only be ecpg
that needs an extra copy of snprintf.o, and it's not like ecpg doesn't
already pull in various port/ files for itself.



The problem is that the alias will be picked up by every libpq client. I got around the problem with ecpg's libpgtypes by unaliasing sprintf and snprintf. But we can't do that everywhere.

I'm not sure I see the objection to stripping these out of the *.def files.

I can't spend any more time on this now - I have spent far too much on it already. My working patch is attached. Maybe I can look at it again in a few days.

cheers

andrew
Index: configure
===================================================================
RCS file: /projects/cvsroot/pgsql/configure,v
retrieving revision 1.461
diff -c -r1.461 configure
*** configure	5 Nov 2005 04:01:38 -0000	1.461
--- configure	5 Dec 2005 18:56:04 -0000
***************
*** 17111,17123 ****
  
  # Force use of our snprintf if system's doesn't do arg control
  # This feature is used by NLS
! if test "$enable_nls" = yes &&
!    test $pgac_need_repl_snprintf = no &&
! # On Win32, libintl replaces snprintf() with its own version that
! # understands arg control, so we don't need our own.  In fact, it
! # also uses macros that conflict with ours, so we _can't_ use
! # our own.
!    test "$PORTNAME" != "win32"; then
    echo "$as_me:$LINENO: checking whether printf supports argument control" >&5
  echo $ECHO_N "checking whether printf supports argument control... $ECHO_C" >&6
  if test "${pgac_cv_printf_arg_control+set}" = set; then
--- 17111,17117 ----
  
  # Force use of our snprintf if system's doesn't do arg control
  # This feature is used by NLS
! if test "$enable_nls" = yes && test $pgac_need_repl_snprintf = no ; then
    echo "$as_me:$LINENO: checking whether printf supports argument control" >&5
  echo $ECHO_N "checking whether printf supports argument control... $ECHO_C" >&6
  if test "${pgac_cv_printf_arg_control+set}" = set; then
Index: src/include/c.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/c.h,v
retrieving revision 1.190
diff -c -r1.190 c.h
*** src/include/c.h	15 Oct 2005 02:49:41 -0000	1.190
--- src/include/c.h	5 Dec 2005 18:56:23 -0000
***************
*** 96,101 ****
--- 96,122 ----
  
  #ifdef ENABLE_NLS
  #include <libintl.h>
+ #ifdef WIN32
+ #ifdef USE_SNPRINTF
+ 
+ #ifdef printf
+ #undef printf
+ #endif
+ #ifdef fprintf
+ #undef fprintf
+ #endif
+ #ifdef sprintf
+ #undef sprintf
+ #endif
+ #ifdef snprintf
+ #undef snprintf
+ #endif
+ #ifdef vsnprintf
+ #undef vsnprintf
+ #endif
+ 
+ #endif
+ #endif
  #else
  #define gettext(x) (x)
  #endif
Index: src/interfaces/ecpg/pgtypeslib/extern.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/extern.h,v
retrieving revision 1.7
diff -c -r1.7 extern.h
*** src/interfaces/ecpg/pgtypeslib/extern.h	15 Oct 2005 02:49:47 -0000	1.7
--- src/interfaces/ecpg/pgtypeslib/extern.h	5 Dec 2005 18:56:24 -0000
***************
*** 1,6 ****
--- 1,14 ----
  #ifndef __PGTYPES_COMMON_H__
  #define __PGTYPES_COMMON_H__
  
+ 
+ #ifdef sprintf
+ #undef sprintf
+ #endif
+ #ifdef snprintf
+ #undef snprintf
+ #endif
+ 
  #include "pgtypes_error.h"
  
  /* These are the constants that decide which printf() format we'll use in
Index: src/interfaces/libpq/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/Makefile,v
retrieving revision 1.138
diff -c -r1.138 Makefile
*** src/interfaces/libpq/Makefile	29 Aug 2005 00:47:35 -0000	1.138
--- src/interfaces/libpq/Makefile	5 Dec 2005 18:56:24 -0000
***************
*** 25,30 ****
--- 25,34 ----
  override CFLAGS += $(PTHREAD_CFLAGS)
  endif
  
+ ifneq ($(enable_nls), yes)
+ NONLS = -e '/^pg_.*printf/d' 
+ endif
+ 
  # Need to recomple any libpgport object files
  LIBS := $(patsubst -lpgport,, $(LIBS))
  
***************
*** 103,126 ****
  	echo 'LIBRARY LIBPQ' >> $@
  	echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
  	echo 'EXPORTS' >> $@
! 	sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
  
  $(srcdir)/libpqddll.def: exports.txt
  	echo '; DEF file for MS VC++' > $@
  	echo 'LIBRARY LIBPQD' >> $@
  	echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
  	echo 'EXPORTS' >> $@
! 	sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
  
  $(srcdir)/blibpqdll.def: exports.txt
  	echo '; DEF file for Borland C++ Builder' > $@
  	echo 'LIBRARY BLIBPQ' >> $@
  	echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
  	echo 'EXPORTS' >> $@
! 	sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' < $< >> $@
  	echo '' >> $@
  	echo '; Aliases for MS compatible names' >> $@
! 	sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' < $< | sed 's/ *$$//' >> $@
  
  # depend on Makefile.global to force rebuild on re-run of configure
  $(srcdir)/libpq.rc: libpq.rc.in $(top_builddir)/src/Makefile.global
--- 107,130 ----
  	echo 'LIBRARY LIBPQ' >> $@
  	echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
  	echo 'EXPORTS' >> $@
! 	sed $(NONLS) -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
  
  $(srcdir)/libpqddll.def: exports.txt
  	echo '; DEF file for MS VC++' > $@
  	echo 'LIBRARY LIBPQD' >> $@
  	echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
  	echo 'EXPORTS' >> $@
! 	sed $(NONLS) -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
  
  $(srcdir)/blibpqdll.def: exports.txt
  	echo '; DEF file for Borland C++ Builder' > $@
  	echo 'LIBRARY BLIBPQ' >> $@
  	echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
  	echo 'EXPORTS' >> $@
! 	sed $(NONLS) -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' < $< >> $@
  	echo '' >> $@
  	echo '; Aliases for MS compatible names' >> $@
! 	sed $(NONLS) -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' < $< | sed 's/ *$$//' >> $@
  
  # depend on Makefile.global to force rebuild on re-run of configure
  $(srcdir)/libpq.rc: libpq.rc.in $(top_builddir)/src/Makefile.global
Index: src/interfaces/libpq/exports.txt
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/exports.txt,v
retrieving revision 1.5
diff -c -r1.5 exports.txt
*** src/interfaces/libpq/exports.txt	21 Oct 2005 15:21:21 -0000	1.5
--- src/interfaces/libpq/exports.txt	5 Dec 2005 18:56:24 -0000
***************
*** 125,127 ****
--- 125,132 ----
  lo_create                 123
  PQinitSSL                 124
  PQregisterThreadLock      125
+ pg_sprintf                126
+ pg_snprintf               127
+ pg_fprintf                128
+ pg_printf                 129
+ pg_vsnprintf              130
Index: src/interfaces/libpq/win32.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/win32.h,v
retrieving revision 1.27
diff -c -r1.27 win32.h
*** src/interfaces/libpq/win32.h	31 Jul 2004 06:19:23 -0000	1.27
--- src/interfaces/libpq/win32.h	5 Dec 2005 18:56:24 -0000
***************
*** 16,21 ****
--- 16,27 ----
  #define write(a,b,c) _write(a,b,c)
  #endif
  
+ #ifdef vsnprintf
+ #undef vsnprintf
+ #endif
+ #ifdef snprintf
+ #undef snprintf
+ #endif
  #define vsnprintf(a,b,c,d) _vsnprintf(a,b,c,d)
  #define snprintf _snprintf
  
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to