This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11344] Precision in printf family of routines
- From: "drepper at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 5 Apr 2010 19:44:55 -0000
- Subject: [Bug libc/11344] Precision in printf family of routines
- References: <20100303134731.11344.lucien@haijen.be>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- 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.