avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] strtod() bug fixes (including #2924)


From: Joerg Wunsch
Subject: [avr-libc-dev] strtod() bug fixes (including #2924)
Date: Tue, 20 Jul 2004 22:56:06 +0200
User-agent: Mutt/1.4.2.1i

I just committed the attached patch to the head of CVS.  This patch
contains two bug fixes.  One supposedly fixes savannah bug tracker
#2924, which was obviously a byte-swapped return value in *endp
(albeit the original submitter of the bug tracker never responded
anymore to my inquiry).

It also fixes a long-standing parser bug.  That fix has once been
reviewed by Reiner Patommel, but due to the endp bug it had never been
committed (Reiner noticed the endp bug, but I never really tracked
that one down by that time).  To quote my old bug description I've
once sent to Reiner (only quickly translated into English now -- the
original mail is from early 2003):

``I'm currently working on a scanf() family, I've already made some
progress with it.  I didn't want to reinvent the wheel for the
floating point part, and use the already existing strtod() for that
part (albeit it's a bit inconvenient to me that I have to copy over
all the characters into an intermediate buffer before).  I just
noticed though that strtod() behaves anything but standard-conformant.
If I feed the string "1.234e+", it ought to return 1.234, and set
*endptr to point to the "e".  Instead, it returns 0.0 (*endptr is OK).

I've been digging through all of it using the debugger.  The
subroutine .L_scanExponent is being called.  If this routine did set
the T bit, the parser immediately returns even though it previously
did parse a correct fractional part.  The correct solution would be in
my opinion, to continue after the error parsing the exponent as if
nothing had happened (the exponent is still at 0 anyway), so the
fractional part that had already been parsed correctly will be
returned.

Following this, the entire T bit handling in .L_scanExponent can be
dropped.  (As a side effect, the preceding jump after a T bit in
.L_scanDigits will become directly reachable, close to the limit of a
branch instruction.)''

Rainer reported by that time that it looked OK to him, but noticed the
wrong endptr value.  The issue had been fallen asleep then. ;-)

If no objections arise, I'd also commit that to the 1.0 branch.

-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

Attachment: strtod.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]