This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/11344] Precision in printf family of routines


------- Additional Comments From drepper at redhat dot com  2010-04-05 19:44 -------
The mentioned test program, unfortunately sent to me.


#include <stdlib.h>
#include <stdio.h>
#include <printf.h>

int main()
{
int args[2], narg, size ;
char *format_pos_prec = "%10.2f",
     *format_neg_prec = "%10.-2f",
     *format_nul_prec = "10.0f",
     *format_dot_prec = "%10.f" ;
char buffer[32] ;

// print all four formats with the same argument

size = sprintf(buffer,format_pos_prec,2.51) ;
printf("format=%s ; size is %d ; result is \"%s\"\n",
    format_pos_prec,size,buffer) ;

size = sprintf(buffer,format_neg_prec,2.51) ;
printf("format=%s ; size is %d ; result is \"%s\"\n",
    format_neg_prec,size,buffer) ;

size = sprintf(buffer,format_nul_prec,2.51) ;
printf("format=%s ; size is %d ; result is \"%s\"\n",
    format_nul_prec,size,buffer) ;

size = sprintf(buffer,format_dot_prec,2.51) ;
printf("format=%s ; size is %d ; result is \"%s\"\n",
    format_dot_prec,size,buffer) ;

// try parse_print_format

narg = parse_printf_format(format_pos_prec,2,args) ;
printf("parse_printf_format() on %s : number of arguments is %d\n",
    format_pos_prec,narg) ;

narg = parse_printf_format(format_neg_prec,2,args) ;
printf("parse_printf_format() on %s : number of arguments is %d\n",
    format_neg_prec,narg) ;

narg = parse_printf_format(format_nul_prec,2,args) ;
printf("parse_printf_format() on %s : number of arguments is %d\n",
    format_nul_prec,narg) ;

narg = parse_printf_format(format_dot_prec,2,args) ;
printf("parse_printf_format() on %s : number of arguments is %d\n",
    format_dot_prec,narg) ;

exit(0) ;
}

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11344

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]