diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-28 16:51:47 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-28 16:51:47 -0200 |
| commit | 96ec8671b1174ba2110c5a36d993a96921511b20 (patch) | |
| tree | c569391ee45e1a78d3789b2246db4f80b7012bfc | |
| parent | cc3a42b1909c2c2cac2086fa10fea8d212d174ad (diff) | |
| download | lua-96ec8671b1174ba2110c5a36d993a96921511b20.tar.gz lua-96ec8671b1174ba2110c5a36d993a96921511b20.tar.bz2 lua-96ec8671b1174ba2110c5a36d993a96921511b20.zip | |
macro 'buff2num' replaced by its body (it caused more harm than good
to readability)
| -rw-r--r-- | llex.c | 8 |
1 files changed, 3 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 2.92 2015/04/03 18:41:57 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.93 2015/05/22 17:45:56 roberto Exp roberto $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -220,8 +220,6 @@ static void buffreplace (LexState *ls, char from, char to) { | |||
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | 222 | ||
| 223 | #define buff2num(b,o) (luaO_str2num(luaZ_buffer(b), o) != 0) | ||
| 224 | |||
| 225 | /* | 223 | /* |
| 226 | ** in case of format error, try to change decimal point separator to | 224 | ** in case of format error, try to change decimal point separator to |
| 227 | ** the one defined in the current locale and check again | 225 | ** the one defined in the current locale and check again |
| @@ -230,7 +228,7 @@ static void trydecpoint (LexState *ls, TValue *o) { | |||
| 230 | char old = ls->decpoint; | 228 | char old = ls->decpoint; |
| 231 | ls->decpoint = lua_getlocaledecpoint(); | 229 | ls->decpoint = lua_getlocaledecpoint(); |
| 232 | buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ | 230 | buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ |
| 233 | if (!buff2num(ls->buff, o)) { | 231 | if (luaO_str2num(luaZ_buffer(ls->buff), o) == 0) { |
| 234 | /* format error with correct decimal point: no more options */ | 232 | /* format error with correct decimal point: no more options */ |
| 235 | buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ | 233 | buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ |
| 236 | lexerror(ls, "malformed number", TK_FLT); | 234 | lexerror(ls, "malformed number", TK_FLT); |
| @@ -262,7 +260,7 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) { | |||
| 262 | } | 260 | } |
| 263 | save(ls, '\0'); | 261 | save(ls, '\0'); |
| 264 | buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ | 262 | buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ |
| 265 | if (!buff2num(ls->buff, &obj)) /* format error? */ | 263 | if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */ |
| 266 | trydecpoint(ls, &obj); /* try to update decimal point separator */ | 264 | trydecpoint(ls, &obj); /* try to update decimal point separator */ |
| 267 | if (ttisinteger(&obj)) { | 265 | if (ttisinteger(&obj)) { |
| 268 | seminfo->i = ivalue(&obj); | 266 | seminfo->i = ivalue(&obj); |
