Bug 7813 - scanf() %2f directive skips leading zeros
scanf() %2f directive skips leading zeros
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
6.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-12-15 08:44 EST by sandlass
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-05-22 10:53:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description sandlass 1999-12-15 08:44:43 EST
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-15 19:23:59 EST
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 10:53:59 EDT
assign to jakub
Comment 3 Jakub Jelinek 2000-08-09 09:35:33 EDT
Fixed in glibc 2.1.92

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