<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] warning cleared



On 2005-09-21 14:36:03 -0700, Brendan Cully wrote:
> On Wednesday, 21 September 2005 at 22:27, David Laight wrote:
> > On Tue, Sep 20, 2005 at 12:40:24AM -0500, David Champion wrote:
> > >     n = atoi(++p);                        /* find pmatch index */
> > > -   while (isdigit(*p))
> > > +   while (isdigit((int)*p))
> > 
> > Use strtoul() instead of either....
> 
> Is strtoul as portable as atoi? Every time I see a nicer interface to
> an old function I assume it means I can't actually use it...

strtoul is standard and was already in K&R C. Moreover, it has a
well-defined behavior (i.e. you can check for errors), contrary to
atoi, which can lead to undefined behaviors. So, it is much better
to use strtoul.

> The patch that went in uses unsigned char, but this particular bug
> seems pretty academic anyway...

Perhaps on this part of code. On other parts of code (concerning
isspace), Mutt had similar bugs in the past. I reported one on
26 June 1997 in Mutt 0.77e, and another one on 3 March 1998 in
Mutt 0.90.6 (at that time, I was under Solaris).

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA