Re: [HACKERS] snprintf causes regression tests

Bruce Momjian <[email protected]> Wed, 16 Mar 2005 10:07:28 -0500 (EST)
Newsgroups gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.devel.general,gmane.comp.db.postgresql.devel.patches
Message-ID <[email protected]>
Nicolai Tufar wrote:
> On Wed, 16 Mar 2005 01:00:21 -0500 (EST), Bruce Momjian
> <[email protected]> wrote:
> > 
> > I have applied a modified version of your patch, attached.
> 

Here is a patch that fixes the %*$ case.

FYI, I am going to pgindent snprintf.c to make it consistent so please
us CVS for your next patch.

I will work on your Win32 compile problem next.

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


---------------------------(end of broadcast)---------------------------
TIP 3: 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
/bjm/diff (text/plain, 1.3 KB)
Index: src/port/snprintf.c
===================================================================
RCS file: /cvsroot/pgsql/src/port/snprintf.c,v
retrieving revision 1.20
diff -c -c -r1.20 snprintf.c
*** src/port/snprintf.c	16 Mar 2005 06:00:58 -0000	1.20
--- src/port/snprintf.c	16 Mar 2005 14:59:00 -0000
***************
*** 467,481 ****
  			fmtparptr[i]->charvalue = va_arg(args, int);
  			break;
  		case FMTLEN:
! 			if (i + 1 < fmtpos && fmtpar[i + 1].func != FMTWIDTH)
! 				fmtpar[i + 1].len = va_arg(args, int);
  			/* For "%*.*f", use the second arg */
! 			if (i + 2 < fmtpos && fmtpar[i + 1].func == FMTWIDTH)
! 				fmtpar[i + 2].len = va_arg(args, int);
  			break;
  		case FMTWIDTH:
  			if (i + 1 < fmtpos)
! 				fmtpar[i + 1].maxwidth = fmtpar[i + 1].precision =
  														va_arg(args, int);
  			break;
  		}
--- 467,481 ----
  			fmtparptr[i]->charvalue = va_arg(args, int);
  			break;
  		case FMTLEN:
! 			if (i + 1 < fmtpos && fmtparptr[i + 1]->func != FMTWIDTH)
! 				fmtparptr[i + 1]->len = va_arg(args, int);
  			/* For "%*.*f", use the second arg */
! 			if (i + 2 < fmtpos && fmtparptr[i + 1]->func == FMTWIDTH)
! 				fmtparptr[i + 2]->len = va_arg(args, int);
  			break;
  		case FMTWIDTH:
  			if (i + 1 < fmtpos)
! 				fmtparptr[i + 1]->maxwidth = fmtparptr[i + 1]->precision =
  														va_arg(args, int);
  			break;
  		}