Messages in this thread | | | Date | Wed, 24 Sep 2003 01:55:26 +0100 | From | viro@parcelfa ... | Subject | Re: [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/
| |