Messages in this thread | | | Date | Tue, 23 Sep 2003 23:26:32 +0100 | From | viro@parcelfa ... | Subject | Re: [PATCH] Fix %x parsing in vsscanf() |
| |
On Tue, Sep 23, 2003 at 03:16:11PM -0700, Deepak Saxena wrote: > { > unsigned long result = 0,value; > > + if ((base == 16) && (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X'))) > + cp += 2; > if (!base) { > base = 10; > if (*cp == '0') {
Not quite right. a) on "0xZ" correct reaction is to eat '0' and stop. b) while we are at it, might as well fix the case of 0X<...> with base 0.
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;
- 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/
| |