lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Many error msgs for all user-documents in lout 3.38 (MS Vista + Cygw


From: KHMan
Subject: Re: Many error msgs for all user-documents in lout 3.38 (MS Vista + Cygwin)
Date: Wed, 28 Jan 2009 23:21:57 +0800
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

Jeff Kingston wrote:
Could you explain what the issue is?  What is wrong, or ambiguous,
about %f in a scanf format?  It seems totally normal and unambiguous.

An update. As far as I can tell, it's a Cygwin bug, and I've posted a query on the Cygwin list.

For the following test cases:

#include <stdio.h>
int main()
{
    char *foo1 = "10i";
    char *foo2 = "0i";
    char *foo3 = "0.0i";
    char *foo4 = "1.0i";
    char *foo5 = "0.1i";
    float f;
    printf("%d ", sscanf(foo1, "%f", &f)); printf("%f\n", f);
    printf("%d ", sscanf(foo2, "%f", &f)); printf("%f\n", f);
    printf("%d ", sscanf(foo3, "%f", &f)); printf("%f\n", f);
    printf("%d ", sscanf(foo4, "%f", &f)); printf("%f\n", f);
    printf("%d ", sscanf(foo5, "%f", &f)); printf("%f\n", f);
}

On Cygwin:
$ ./test
1 10.000000
0 10.000000
1 0.000000
1 1.000000
1 0.100000

So it works fine for most things except '0'. Looks like a Cygwin bug for sure. Once there is more information from the Cygwin people, I will put up a brief wiki page on this for the Lout wiki.

On Mon, Jan 26, 2009 at 09:17:01PM +0800, KHMan wrote:
I'm not really sure if newlib's sscanf is really at fault, because its behaviour sounds wrong if we use "man scanf", but sounds right if we use the ISO C draft standard n1256. So it seems all very ambiguous...

-  if( sscanf((char *) str, "%f", &num) != 1 )
+  if( sscanf((char *) str, "%31[0-9.]", &conv) != 1)

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia



reply via email to

[Prev in Thread] Current Thread [Next in Thread]