Date: Thu, 6 Dec 2012 16:36:43 -0800 From: Isaac Dunham <idunham@...abit.com> To: musl@...ts.openwall.com Subject: Re: Fix strverscmp On Wed, 5 Dec 2012 23:14:56 -0500 Rich Felker <dalias@...ifal.cx> wrote: > All that means is that you missed testing any case where it differs. > > ./a.out s10212 s102102 > 2 > -1 I realized what you meant just after sending the last email... Anyhow, after working out how the state should change and a little bit of testing, I arrived at the attached version. Logic for the upper part: Start, assuming a non-numeric char (1) --if initialized to 0, it will break the case where the first 2 characters are differing digits! while walking down to the difference, -record 0 if char was last -record 2 for any other digit if char was last -Reset to 1 if a non-digit is found. This records the leading digit of a sequence. When the difference is reached, record 0 if one branch contains a leading zero. -- Isaac Dunham <idunham@...abit.com> View attachment "strvers.c" of type "text/x-csrc" (934 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.