Re: [PATCHES] snprintf() argument reordering not working

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: [PATCHES] snprintf() argument reordering not working
Дата
Msg-id 439376D9.9080708@dunslane.net
обсуждение исходный текст
Ответ на Re: [PATCHES] snprintf() argument reordering not working  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: [PATCHES] snprintf() argument reordering not working  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers

Bruce Momjian wrote:

>Tom Lane wrote:
>
>
>>Andrew Dunstan <andrew@dunslane.net> writes:
>>
>>
>>>That got me through the backend compile and through libpq to ecpg, which
>>>fell over at the link stage complaining about missing references to
>>>pg_sprintf and pg_snprintf ... not sure how to fix that - windows
>>>experts, please advise.
>>>
>>>
>>Plan A would be to make libpq export pg_snprintf and friends, Plan B
>>would be to give ecpg its own copy of snprintf.o.  Plan A is probably
>>better since you're going to hit the same issue no doubt in all of the
>>src/bin programs.
>>
>>
>
>I am confused why we would need either of these.  All apps use
>libpgport, and that pg_*printf should be in that library.  The original
>work Andrew did has problems particularly with ecpg, but why does ecpg
>cause problems?  Doesn't it link in pgport?
>
>
>



libpgtypes doesn't link with either libpgport or libpq.

What I have done to get a working build in addition to the previous
report is to undef snprintf and sprintf in
interfaces/pgtypeslib/extern.h (instead of creating an additional link
burden), and to add entries for pg_snprintf, pg_sprintf and pg_fprintf
to interfaces/libpq/exports.txt. That let me get a clean compile and
regression run. The diff against 8.1 is attached for comment.

I suspect we should probably add all the pg_*printf functions to
exports.txt.

(Of course, first you need to install gettext and libintl from the
gnuwin32 project, or you can't even configure with --enable-nls)

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    4 Dec 2005 22:56:58 -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    4 Dec 2005 22:57:02 -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    4 Dec 2005 22:57:05 -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/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    4 Dec 2005 22:57:06 -0000
***************
*** 125,127 ****
--- 125,130 ----
  lo_create                 123
  PQinitSSL                 124
  PQregisterThreadLock      125
+ pg_sprintf          126
+ pg_snprintf          127
+ pg_fprintf          128
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    4 Dec 2005 22:57:06 -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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Zoltan Boszormenyi
Дата:
Сообщение: Re: SERIAL type feature request
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: SERIAL type feature request