bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

glibc: printf bug


From: Bruce Korb
Subject: glibc: printf bug
Date: Sun, 25 May 2003 16:07:03 -0700

Hi all,

I thought that the printf bugs were largely gone in glibc-2.
This has to do with printf argument indexing.  The following
program fails on SuSE 8.2 and works on most any modern UNIX.
It also works if you have the snprintfv library and define
USE_SNPRINTFV :-)

=====================

#include <stdio.h>

#ifdef USE_SNPRINTFV
#include "config.h"
#include <snprintfv/printf.h>
#endif

static const char zSamp[] =
"ch1: 49 ('1') -- ch2: 32 (' ')\n";
static const char zFmt[] =
"ch1: %1$d ('%1$c') -- ch2: %2$d ('%2$c')\n";

static char zBuff[ 128 ];

int
main( int argc, char** argv )
{
    sprintf( zBuff, zFmt, 0x31, 32 );
    fputs( zBuff, stdout );
    return strcmp( zBuff, zSamp ) != 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]