dgd icon indicating copy to clipboard operation
dgd copied to clipboard

sscanf() not handling %f floats correctly.

Open geirpg opened this issue 1 year ago • 3 comments

On VikingMud, we're running version 1.7.1.

We noticed a rare bug (we rarely use %f in sscanf) where the floating point number isn't picked up.

Example code: void runme(string arg) { string s; int i; float f;

if(!arg) return; //Handling as string sscanf(arg, "%s",s); printf("String: %s\n",s);

//Handling as int sscanf(arg, "%d",i); printf("Int: %d\n",i);

//Handling as float: sscanf(arg,"%f",f); printf("Float: %f\n",f); }

Doing runme("4.3") will return: String: 4.3 Int: 4 Float: 0.000000

This is consistent.

Maybe related to https://github.com/dworkin/dgd/issues/63?

-Geirpg/Moreldir@VikingMud

geirpg avatar Apr 12 '24 09:04 geirpg

I can reproduce this when DGD is compiled with -DLARGENUM.

dworkin avatar Apr 13 '24 20:04 dworkin

Should be fixed by b380133ea98147dce448fe19fa3b65da89fcc782.

dworkin avatar Apr 13 '24 20:04 dworkin

We'll have a look. And yes - we have it compiled with -DLARGENUM

geirpg avatar Apr 13 '24 20:04 geirpg

So, I can finally confirm that this solved our issue.

geirpg avatar Apr 20 '24 19:04 geirpg