mirror of https://github.com/rusefi/lua.git
complete support for hexadecimal constants
This commit is contained in:
parent
6316a866a3
commit
298ae7e230
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lobject.c,v 2.20 2005/12/22 16:19:56 roberto Exp roberto $
|
** $Id: lobject.c,v 2.21 2006/01/10 12:50:00 roberto Exp roberto $
|
||||||
** Some generic functions over Lua objects
|
** Some generic functions over Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -91,6 +91,8 @@ int luaO_str2d (const char *s, lua_Number *result) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
*result = lua_str2number(s, &endptr);
|
*result = lua_str2number(s, &endptr);
|
||||||
if (endptr == s) return 0; /* conversion failed */
|
if (endptr == s) return 0; /* conversion failed */
|
||||||
|
if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
|
||||||
|
*result = cast_num(strtoul(s, &endptr, 16));
|
||||||
if (*endptr == '\0') return 1; /* most common case */
|
if (*endptr == '\0') return 1; /* most common case */
|
||||||
while (isspace(cast(unsigned char, *endptr))) endptr++;
|
while (isspace(cast(unsigned char, *endptr))) endptr++;
|
||||||
if (*endptr != '\0') return 0; /* invalid trailing characters? */
|
if (*endptr != '\0') return 0; /* invalid trailing characters? */
|
||||||
|
|
Loading…
Reference in New Issue