www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/03/15/11:13:45

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <38CFB1CC.2387C34E@Sparta.Com>
Date: Wed, 15 Mar 2000 10:52:44 -0500
From: Mark Rahner <mark_rahner AT Sparta DOT Com>
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en,pdf
MIME-Version: 1.0
To: cygwin AT sourceware DOT cygnus DOT com
Subject: sscanf() %n Bug Introduced in 20000221 Snapshot

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi Folks,
<p>This message documents a problem with sscanf() %n format specification
which began, to the best of my knowledge, with the 20000221 snapshot.&nbsp;
This problem did not exist in the 20000211 snapshot.&nbsp; I'm using Windows98
and Cygwin Beta 20.1 with upgrades consisting of Mumit's 2.95.2 compiler
and the 200000221 snapshot.
<p>Compiling the following using "g++ sscanfBug.C -o sscanfBug.exe"
<blockquote>#include &lt;stdio.h>
<br>#include &lt;iostream>
<p>int main () {
<p>&nbsp;&nbsp;&nbsp; const char *str = "0.02";
<br>&nbsp;&nbsp;&nbsp; double num;
<br>&nbsp;&nbsp;&nbsp; int len;
<p>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "str is &lt;" &lt;&lt; str &lt;&lt;
">\n";
<p>&nbsp;&nbsp;&nbsp; sscanf( str, "%lf%n", &amp;num, &amp;len );
<p>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "num is &lt;" &lt;&lt; num &lt;&lt;
">\n";
<br>&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "len is &lt;" &lt;&lt; len &lt;&lt;
">\n";
<br>}</blockquote>
produces an executable which, when run, writes the following to standard
error:
<blockquote>str is &lt;0.02>
<br>num is &lt;0.02>
<br>len is &lt;2></blockquote>
The correct value for len is 4.&nbsp; Please note that this is not the
same problem discussed on this mailing list last June.&nbsp; Specifically,
there is no space preceding %n.&nbsp; 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.
<p>Hope this helps,
<br>Mark Rahner</html>


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019