Re: Bug in scanf?

Crystal Kolipe <[email protected]> Wed, 10 Dec 2025 15:36:55 +0000
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
On Wed, Dec 10, 2025 at 04:03:08PM +0100, Martin Husemann wrote:
> With two chars lookahead the parser can realize the e is not start of an
> exponent expression

Surely you need three chars lookahead for that, because the exponent can be
signed.

So given the string: 123e+foo if you are parsing the 3 and the intention is to
return 123 as the float and then parse e+foo as just text rather than
indicating an exponent part of the number 123, then you need to process both
e and +, (which at that point could still be a valid exponent), and return
failure only when you reach the f.