lua-users home
lua-l archive

Re: parse hex numerals [PATCH]

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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

AltStyle によって変換されたページ (->オリジナル) /