This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] Parse hex and octal strings correctly in __strtoul_internal


On Tue, Apr 24, 2012 at 10:27 PM, Siddhesh Poyarekar
<siddhesh@redhat.com> wrote:

> Ugh, no I did not. Here's the right patch.

Looks good to me. Minor nits:

  while (1)
    {
      unsigned long int digval;
      unsigned max_digit = (base <= 10) ? base - 1 : 9;
      if (*nptr >= '0' && *nptr <= '0' + max_digit)

max_digit computation could be moved out of the loop, as base is
constant after this point.

It may make sense to set max_digit when base is set (a couple lines
earlier), and avoid extra conditionals (as in attached patch).

-- 
Paul Pluzhnikov

Attachment: glibc-parse-hex-20120424.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]