diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-02-10 15:43:52 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-02-10 15:43:52 -0200 |
| commit | 298ae7e230a23c70c61f27b0c9e25975f2e716c6 (patch) | |
| tree | ccd5415cb725c03aa6c068b23d3b741cfc5f2e8a | |
| parent | 6316a866a3aa55f90c44553542a552e64b56aa68 (diff) | |
| download | lua-298ae7e230a23c70c61f27b0c9e25975f2e716c6.tar.gz lua-298ae7e230a23c70c61f27b0c9e25975f2e716c6.tar.bz2 lua-298ae7e230a23c70c61f27b0c9e25975f2e716c6.zip | |
complete support for hexadecimal constants
| -rw-r--r-- | lobject.c | 4 |
1 files changed, 3 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.20 2005/12/22 16:19:56 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.21 2006/01/10 12:50:00 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -91,6 +91,8 @@ int luaO_str2d (const char *s, lua_Number *result) { | |||
| 91 | char *endptr; | 91 | char *endptr; |
| 92 | *result = lua_str2number(s, &endptr); | 92 | *result = lua_str2number(s, &endptr); |
| 93 | if (endptr == s) return 0; /* conversion failed */ | 93 | if (endptr == s) return 0; /* conversion failed */ |
| 94 | if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ | ||
| 95 | *result = cast_num(strtoul(s, &endptr, 16)); | ||
| 94 | if (*endptr == '\0') return 1; /* most common case */ | 96 | if (*endptr == '\0') return 1; /* most common case */ |
| 95 | while (isspace(cast(unsigned char, *endptr))) endptr++; | 97 | while (isspace(cast(unsigned char, *endptr))) endptr++; |
| 96 | if (*endptr != '\0') return 0; /* invalid trailing characters? */ | 98 | if (*endptr != '\0') return 0; /* invalid trailing characters? */ |
