This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

sscanf() %n Bug Introduced in 20000221 Snapshot


Hi Folks,

This message documents a problem with sscanf() %n format specification which began, to the best of my knowledge, with the 20000221 snapshot.  This problem did not exist in the 20000211 snapshot.  I'm using Windows98 and Cygwin Beta 20.1 with upgrades consisting of Mumit's 2.95.2 compiler and the 200000221 snapshot.

Compiling the following using "g++ sscanfBug.C -o sscanfBug.exe"

#include <stdio.h>
#include <iostream>

int main () {

    const char *str = "0.02";
    double num;
    int len;

    cerr << "str is <" << str << ">\n";

    sscanf( str, "%lf%n", &num, &len );

    cerr << "num is <" << num << ">\n";
    cerr << "len is <" << len << ">\n";
}

produces an executable which, when run, writes the following to standard error:
str is <0.02>
num is <0.02>
len is <2>
The correct value for len is 4.  Please note that this is not the same problem discussed on this mailing list last June.  Specifically, there is no space preceding %n.  I apologize in advance for not presenting you with a patch; after briefly attempting to track this bug myself, I realized that I wasn't getting anywhere.

Hope this helps,
Mark Rahner -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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