Обсуждение: snprintf improvements

Поиск
Список
Период
Сортировка

snprintf improvements

От
Bruce Momjian
Дата:
This patch uses our own snprintf() only when NLS support is enabled, and
I added support for %qd and %I64d in snprintf.  We might need those in
the final version if it is exported to apps.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: configure
===================================================================
RCS file: /cvsroot/pgsql/configure,v
retrieving revision 1.430
diff -c -c -r1.430 configure
*** configure    28 Feb 2005 20:55:18 -0000    1.430
--- configure    2 Mar 2005 14:30:16 -0000
***************
*** 14527,14533 ****


  # Force use of our snprintf if system's doesn't do arg control
! if 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
--- 14527,14534 ----


  # Force use of our snprintf if system's doesn't do arg control
! # This feature is used by NLS
! if test "$enable_nls" = yes -a $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.403
diff -c -c -r1.403 configure.in
*** configure.in    28 Feb 2005 20:55:18 -0000    1.403
--- configure.in    2 Mar 2005 14:30:20 -0000
***************
*** 1067,1073 ****


  # Force use of our snprintf if system's doesn't do arg control
! if 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
--- 1067,1074 ----


  # Force use of our snprintf if system's doesn't do arg control
! # This feature is used by NLS
! if test "$enable_nls" = yes -a $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/port/snprintf.c
===================================================================
RCS file: /cvsroot/pgsql/src/port/snprintf.c,v
retrieving revision 1.12
diff -c -c -r1.12 snprintf.c
*** src/port/snprintf.c    2 Mar 2005 05:22:22 -0000    1.12
--- src/port/snprintf.c    2 Mar 2005 14:30:26 -0000
***************
*** 259,264 ****
--- 259,281 ----
                          else
                              longflag = 1;
                          goto nextch;
+                     /*
+                      *    We might export this to client apps so we should
+                      *    support 'qd' and 'I64d'(MinGW) also in case the
+                      *    native version does.
+                      */
+                     case 'q':
+                         longlongflag = 1;
+                         longflag = 1;
+                         goto nextch;
+                     case 'I':
+                         if (*(format+1) == '6' && *(format+2) == '4')
+                         {
+                             format += 2;
+                             longlongflag = 1;
+                             longflag = 1;
+                             goto nextch;
+                         }
                      case 'u':
                      case 'U':
                          /* fmtnum(value,base,dosign,ljust,len,zpad,&output) */

Re: snprintf improvements

От
Peter Eisentraut
Дата:
Am Mittwoch, 2. März 2005 15:48 schrieb Bruce Momjian:
> This patch uses our own snprintf() only when NLS support is enabled, and
> I added support for %qd and %I64d in snprintf.  We might need those in
> the final version if it is exported to apps.

test -a is not portable.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: snprintf improvements

От
Bruce Momjian
Дата:
Peter Eisentraut wrote:
> Am Mittwoch, 2. M?rz 2005 15:48 schrieb Bruce Momjian:
> > This patch uses our own snprintf() only when NLS support is enabled, and
> > I added support for %qd and %I64d in snprintf.  We might need those in
> > the final version if it is exported to apps.
>
> test -a is not portable.

Thanks, fixed:

    if test "$enable_nls" = yes && test $pgac_need_repl_snprintf = no; then

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: snprintf improvements

От
Tom Lane
Дата:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> This patch uses our own snprintf() only when NLS support is enabled,

I see no point in this; it does not solve any problem we need solved,
only complicate the configuration behavior even more.

> I added support for %qd and %I64d in snprintf.

I consider this an awful idea as well.

            regards, tom lane

Re: snprintf improvements

От
Peter Eisentraut
Дата:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > This patch uses our own snprintf() only when NLS support is
> > enabled,
>
> I see no point in this; it does not solve any problem we need solved,
> only complicate the configuration behavior even more.

I think this is analogous to checking for snprintf() support of 64-bit
integers only if we previously found 64-bit integers to be supported.
We don't need to include our own snprintf() if we don't need the extra
features it provides.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: snprintf improvements

От
Bruce Momjian
Дата:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > This patch uses our own snprintf() only when NLS support is enabled,
>
> I see no point in this; it does not solve any problem we need solved,
> only complicate the configuration behavior even more.

Peter answered this.

> > I added support for %qd and %I64d in snprintf.
>
> I consider this an awful idea as well.

Moved into a NOT_USED block so we can keep it in case we want it later.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073