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

KHMan <[email protected]>
Newsgroups gmane.comp.type-setting.lout
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.