[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: parse hex numerals [PATCH]
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 09 Feb 2006 13:11:19 -0200
What about this?
char *endptr;
*result = lua_str2number(s, &endptr);
if (endptr == s) return 0; /* conversion failed */
+ if (*endptr == 'x') *result = strtoul(s, &endptr, 16);
if (*endptr == '\0') return 1; /* most common case */
while (isspace(cast(unsigned char, *endptr))) endptr++;
if (*endptr != '\0') return 0; /* invalid trailing characters? */
-- Roberto