lkml.org 
[lkml]   [2003]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Fix %x parsing in vsscanf()
On Tue, Sep 23, 2003 at 06:02:58PM -0700, Deepak Saxena wrote:
> On Sep 23 2003, at 23:26, viro@parcelfarce.linux.theplanet.co.uk was caught saying:
> > The following, AFAICS, would be correct:
> >
> > if (*cp == '0') {
> > cp++;
> > if (unlikely((*cp == 'x' || *cp == 'X') && isxdigit(cp[1]))) {
> > if (!base || base == 16) {
> > cp++;
> > base = 16;
> > }
> > } else if (!base)
> > base = 8;
> > } else if (!base)
> > base = 10;
>
> We can remove everything but "base = 10;" from the second "else if"
> clause b/c by this point we're guaranteed that it's not a hex or
> octal value.

Bzzert. strtoul() with e.g. base 8 on "1234" should parse it as octal.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.048 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site