[PD] Bug in pool?

Frank Barknecht fbar at footils.org
Tue Apr 19 14:35:18 CEST 2005


Hallo,
Frank Barknecht hat gesagt: // Frank Barknecht wrote:

> attached is an example of a possible bug in the way, [pool] saves
> symbols starting with a number. This seems to be a new bug, as it was
> working in previous versions of pool, but is not in current CVS pool. 
> 
> The correct data is stored, but loading seems to go wrong.

Hm, I found, where it goes wrong:

In pool.cpp, method: "static char *ReadAtom(char *c,A *a)" there is a
check if a key is a float, which also detects strings like "10x20" as
floats: 

    // ...
    // save character and set delimiter

    float fres;
    // first try float
    if(sscanf(tmp,"%f",&fres) == 1) {
        if(a) {
            int ires = (int)fres; // try a cast
            if(fres == ires)
                flext::SetInt(*a,ires);
            else
                flext::SetFloat(*a,fres);
        }
    }
    // no, it's a symbol
    else {
        if(a) flext::SetString(*a,tmp);
    }
    // ...


"sscanf(tmp,"%f",&fres)" returns "1" for all strings which *start* with a
digit, even if they later include alphabetic characters. 

Now, does anyone know, how to better check for real floats? 

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
          _ __latest track: "scans" _ http://footils.org/cms/show/41




More information about the Pd-list mailing list