[Tarantool-patches] [PATCH luajit] Give expected results for negative non-base-10 numbers in tonumber().
imun at tarantool.org
Thu Jun 30 15:09:47 MSK 2022
I've checked the patch into all long-term branches in tarantool/luajit
and bumped a new version in master, 2.10 and 1.10.
On 27.12.21, Sergey Kaplun wrote:
> From: Mike Pall <mike>
> This was undefined in Lua 5.1, but it's defined in 5.2.
> (cherry picked from f3cf0d6e15240098147437fed7bd436ff55fdf8c)
> `strtoul()` considers negative values as a valid input and silently
> converts them to the equivalent unsigned long value. As a result yielded
> value is unexpected to the user.
> This patch adds reading of a sign (if exists) from argument and provide
> the remaining part of the string as is if it starts with a digit or
> alphabetical symbol to be consistent with Lua 5.2.
> Sergey Kaplun:
> * added the description and the test for the problem
> Part of tarantool/tarantool#6548
> Issue: https://github.com/tarantool/tarantool/issues/6548
> Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-noticket-tonumber-expected-results-full-ci
> Tarantool branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-noticket-tonumber-expected-results-full-ci
> CI is red due to integration tests failes (same as on master) or due to
> connection errors.
> Side note: I suppose that undefinence Mike talking about is the
> following lines in the Lua 5.1 Reference manual :
> | In base 10 (the default), the number can have a decimal part, as well
> | as an optional exponent part (see paragraph 2.1). In other bases, only
> | unsigned integers are accepted.
> In the Lua 5.2 Reference manual  they are deleted.
> src/lib_base.c | 27 +++++++++++------
> ...onumber-negative-non-decimal-base.test.lua | 29 +++++++++++++++++++
> 2 files changed, 47 insertions(+), 9 deletions(-)
> create mode 100644 test/tarantool-tests/tonumber-negative-non-decimal-base.test.lua
> : http://www.lua.org/manual/5.1/manual.html#pdf-tonumber
> : http://www.lua.org/manual/5.2/manual.html#pdf-tonumber
More information about the Tarantool-patches