diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-26 12:27:56 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-26 12:27:56 -0300 |
| commit | c6c41e85b2992bba41cac23ac8bab32e29553e84 (patch) | |
| tree | d48b427016446604131f730f016bceb90463777d /lobject.c | |
| parent | 87c930676f4aef54054024b73a245a24747aa163 (diff) | |
| download | lua-c6c41e85b2992bba41cac23ac8bab32e29553e84.tar.gz lua-c6c41e85b2992bba41cac23ac8bab32e29553e84.tar.bz2 lua-c6c41e85b2992bba41cac23ac8bab32e29553e84.zip | |
more uniformity for defining system-dependent features
Diffstat (limited to 'lobject.c')
| -rw-r--r-- | lobject.c | 20 |
1 files changed, 14 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.72 2014/01/27 13:34:32 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.73 2014/02/06 15:59:24 roberto Exp $ |
| 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 | */ |
| @@ -159,22 +159,26 @@ static int isneg (const char **s) { | |||
| 159 | 159 | ||
| 160 | 160 | ||
| 161 | /* | 161 | /* |
| 162 | ** {====================================================== | ||
| 162 | ** lua_strx2number converts an hexadecimal numeric string to a number. | 163 | ** lua_strx2number converts an hexadecimal numeric string to a number. |
| 163 | ** In C99, 'strtod' does both conversions. C89, however, has no function | 164 | ** In C99, 'strtod' does both conversions. C89, however, has no function |
| 164 | ** to convert floating hexadecimal strings to numbers. For these | 165 | ** to convert floating hexadecimal strings to numbers. For these |
| 165 | ** systems, you can leave 'lua_strx2number' undefined and Lua will | 166 | ** systems, you can leave 'lua_strx2number' undefined and Lua will |
| 166 | ** provide its own implementation. | 167 | ** provide its own implementation. |
| 168 | ** ======================================================= | ||
| 167 | */ | 169 | */ |
| 168 | #if defined(LUA_USE_STRTODHEX) | 170 | #if !defined(lua_strx2number) /* { */ |
| 171 | |||
| 172 | #if defined(LUA_USE_C99) /* { */ | ||
| 173 | |||
| 169 | #define lua_strx2number(s,p) lua_str2number(s,p) | 174 | #define lua_strx2number(s,p) lua_str2number(s,p) |
| 170 | #endif | ||
| 171 | 175 | ||
| 176 | #else /* }{ */ | ||
| 172 | 177 | ||
| 173 | #if !defined(lua_strx2number) | 178 | /* Lua's implementation for 'lua_strx2number' */ |
| 174 | 179 | ||
| 175 | #include <math.h> | 180 | #include <math.h> |
| 176 | 181 | ||
| 177 | |||
| 178 | /* maximum number of significant digits to read (to avoid overflows | 182 | /* maximum number of significant digits to read (to avoid overflows |
| 179 | even with single floats) */ | 183 | even with single floats) */ |
| 180 | #define MAXSIGDIG 30 | 184 | #define MAXSIGDIG 30 |
| @@ -237,7 +241,11 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
| 237 | return l_mathop(ldexp)(r, e); | 241 | return l_mathop(ldexp)(r, e); |
| 238 | } | 242 | } |
| 239 | 243 | ||
| 240 | #endif | 244 | #endif /* } */ |
| 245 | |||
| 246 | #endif /* } */ | ||
| 247 | |||
| 248 | /* }====================================================== */ | ||
| 241 | 249 | ||
| 242 | 250 | ||
| 243 | int luaO_str2d (const char *s, size_t len, lua_Number *result) { | 251 | int luaO_str2d (const char *s, size_t len, lua_Number *result) { |
