FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Possible mistake in mango.convert.Atoi

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Sun Aug 27, 2006 12:04 am    Post subject: Possible mistake in mango.convert.Atoi Reply with quote

At line 165 of mango.convert.Atoi is the 'parse' function.
Code:

        static long parse (T[] digits, uint radix=0, uint* ate=null)
        {
                uint rdx;
                bool sign;

                int eaten = trim (digits, sign, rdx);

                if (radix)
                    rdx = radix;

                ulong result = convert (digits[eaten..length], rdx, ate);

                if (ate)
                    ate += eaten;

                return cast(long) (sign ? -result : result);
        }


If I'm not mistaken lines 177-178 should instead read:
Code:

                if (ate)
                    *ate += eaten;


Otherwise it is just advancing the pointer into random memory, rather than actually returning the consumption as intended. Smile
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Sun Aug 27, 2006 10:44 am    Post subject: Reply with quote

Yes; thanks Chris
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group