Tom Lane wrote:

I'm coming around to thinking that the simple solution is just to use it unconditionally on Windows.

I agree that that's what we should do, but it should be done the same
way we handle other routines from libpgport.  None of those are exported
to our client-side programs via libpq.



OK, eyeball this for the REL8_1_STABLE branch, please. It seems to work for me. No exports necessary.

cheers

andrew
? autom4te.cache
Index: configure
===================================================================
RCS file: /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 22:22:11 -0000
***************
*** 13851,13858 ****
  # is missing.  Yes, there are machines that have only one.  We may
  # also decide to use snprintf.c if snprintf() is present but does not
  # have all the features we need --- see below.
  
! pgac_need_repl_snprintf=no
  
  for ac_func in snprintf
  do
--- 13851,13861 ----
  # is missing.  Yes, there are machines that have only one.  We may
  # also decide to use snprintf.c if snprintf() is present but does not
  # have all the features we need --- see below.
+ # Win32 gets this built unconditionally
  
! if test "$PORTNAME" = "win32"; then
!   pgac_need_repl_snprintf=yes
! else
  
  for ac_func in snprintf
  do
***************
*** 14061,14066 ****
--- 14064,14070 ----
  fi
  done
  
+ fi
  
  
  # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
***************
*** 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
--- 17115,17121 ----
  
  # 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: configure.in
===================================================================
RCS file: /cvsroot/pgsql/configure.in,v
retrieving revision 1.431
diff -c -r1.431 configure.in
*** configure.in	5 Nov 2005 04:01:41 -0000	1.431
--- configure.in	5 Dec 2005 22:22:12 -0000
***************
*** 849,858 ****
  # is missing.  Yes, there are machines that have only one.  We may
  # also decide to use snprintf.c if snprintf() is present but does not
  # have all the features we need --- see below.
  
! pgac_need_repl_snprintf=no
! AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
! AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
  
  
  # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
--- 849,862 ----
  # is missing.  Yes, there are machines that have only one.  We may
  # also decide to use snprintf.c if snprintf() is present but does not
  # have all the features we need --- see below.
+ # Win32 gets this built unconditionally
  
! if test "$PORTNAME" = "win32"; then
!   pgac_need_repl_snprintf=yes
! else
!   AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
!   AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
! fi
  
  
  # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
***************
*** 1046,1058 ****
  
  # 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
    PGAC_FUNC_PRINTF_ARG_CONTROL
    if test $pgac_cv_printf_arg_control != yes ; then
      pgac_need_repl_snprintf=yes
--- 1050,1056 ----
  
  # 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
    PGAC_FUNC_PRINTF_ARG_CONTROL
    if test $pgac_cv_printf_arg_control != yes ; then
      pgac_need_repl_snprintf=yes
Index: src/include/c.h
===================================================================
RCS file: /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 22:22:16 -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/ecpglib/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/Makefile,v
retrieving revision 1.33
diff -c -r1.33 Makefile
*** src/interfaces/ecpg/ecpglib/Makefile	14 Mar 2005 17:27:50 -0000	1.33
--- src/interfaces/ecpg/ecpglib/Makefile	5 Dec 2005 22:22:17 -0000
***************
*** 33,38 ****
--- 33,40 ----
  ifeq ($(PORTNAME), win32)
  # Link to shfolder.dll instead of shell32.dll
  SHLIB_LINK += -lshfolder
+ # and use our snprintf
+ OBJS += snprintf.o
  endif
  
  all: all-lib
***************
*** 51,56 ****
--- 53,61 ----
  exec.c: % : $(top_srcdir)/src/port/%
  	rm -f $@ && $(LN_S) $< .
  
+ snprintf.c: % : $(top_srcdir)/src/port/%
+ 	rm -f $@ && $(LN_S) $< .
+ 
  path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
  
  $(top_builddir)/src/port/pg_config_paths.h:
Index: src/interfaces/ecpg/pgtypeslib/extern.h
===================================================================
RCS file: /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 22:22:17 -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/win32.h
===================================================================
RCS file: /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 22:22:18 -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 5: don't forget to increase your free space map settings

Reply via email to