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 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/

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