From 298ae7e230a23c70c61f27b0c9e25975f2e716c6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 10 Feb 2006 15:43:52 -0200 Subject: [PATCH] complete support for hexadecimal constants --- lobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lobject.c b/lobject.c index 01a711ab..a7ee87a6 100644 --- a/lobject.c +++ b/lobject.c @@ -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 ** See Copyright Notice in lua.h */ @@ -91,6 +91,8 @@ int luaO_str2d (const char *s, lua_Number *result) { char *endptr; *result = lua_str2number(s, &endptr); 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 */ while (isspace(cast(unsigned char, *endptr))) endptr++; if (*endptr != '\0') return 0; /* invalid trailing characters? */