Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 7813 - scanf() %2f directive skips leading zeros
Summary: scanf() %2f directive skips leading zeros
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 6.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-12-15 13:44 UTC by sandlass
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2000-05-22 14:53:20 UTC


Attachments (Terms of Use)

Description sandlass 1999-12-15 13:44:43 UTC
To reproduce the problem compile an run the followin little program:

#include <stdio.h>

int main (int argc, char **argv)
{
    float f1, f2, f3, f4;

    printf ("scanf = %d\n", scanf ("%2f%2f%2f%2f", &f1, &f2, &f3, &f4));
    printf ("f1 = %f\n", f1);
    printf ("f2 = %f\n", f2);
    printf ("f3 = %f\n", f3);
    printf ("f4 = %f\n", f4);

    return 0;
}

running the program with an input of "01020304" gives:

01020304
scanf = 4
f1 = 10.000000
f2 = 20.000000
f3 = 30.000000
f4 = 4.000000

It should be:

01020304
scanf = 4
f1 = 1.000000
f2 = 2.000000
f3 = 3.000000
f4 = 4.000000

Comment 1 Riley H Williams 1999-12-16 00:23:59 UTC
Just tried it here...

[rhw@ps rhw]$ gcc -Wall -o x x.c
[rhw@ps rhw]$ ./x
01020304
scanf = 4
f1 = 1.000000
f2 = 2.000000
f3 = 3.000000
f4 = 4.000000
[rhw@ps rhw]$

Looks  fine to me.

For reference...

Kernel                 2.2.13 (SMP - Dual P2/350)
Kernel modules         2.1.121
Gnu C                  2.7.2.3
Binutils               2.9.1.0.4
Linux C Library        0.7.so*
Dynamic linker         ldd (GNU libc) 2.0.7
Linux C++ Library      2.8.0*
Procps                 1.2.9
Mount                  2.7l
Net-tools              1.50
Kbd                    0.94
Sh-utils               1.16

Comment 2 Cristian Gafton 2000-05-22 14:53:59 UTC
assign to jakub

Comment 3 Jakub Jelinek 2000-08-09 13:35:33 UTC
Fixed in glibc 2.1.92


Note You need to log in before you can comment on or make changes to this bug.