I've noticed a problem with little endian float parsing in sscanf():
Pike v7.9 release 5 running Hilfe v3.5 (Incremental Pike Frontend)
string f = sprintf("%-8F", 3.25); float z; sscanf(f, "%-8F", z);
(1) Result: 1
z;
(2) Result: 1.29642825468743e-320
The problem exists in 7.8.700 as well, but not 7.6.128.
The problem is that the "-" is not implemented for sscanf %F, and never was AFAIK. You need to do
sscanf(reverse(f), "%8F", z);
instead.
Yes, that's what I've been doing. It appears that my example works on 7.6 because sprint doesn't implement %-F, thus decoding properly.
I guess at this point it would be a compat problem to fix. Perhaps I'll add a note to the autodoc about it. On a side note, it's pretty frustrating that sscanf/sprintf don't complain when an unsupported/unimplemented format is used.
Bill
On Feb 18, 2013, at 11:05 AM, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se wrote:
The problem is that the "-" is not implemented for sscanf %F, and never was AFAIK. You need to do
sscanf(reverse(f), "%8F", z);
instead.
I think sprint and sscanf should be symmetric, so I guess it's time to fix sscanf %-8F?
pike-devel@lists.lysator.liu.se