[Tarantool-patches] [PATCH luajit] Fix binary number literal parsing.

Sergey Kaplun skaplun at tarantool.org
Fri Aug 25 15:01:00 MSK 2023


Hi, Maxim!
Thanks for the review!
Fixed your comments inline, rebased branch on the current master and
force-pushed it.

On 25.08.23, Maxim Kokryashkin wrote:
> 
> Hi, Sergey!
> Thanks for the patch!
> LGTM, except for a few comments below.
>> >>From: Mike Pall <mike>
> >>
> >>Reported by Egor Skriptunoff.
> >>
> >>(cherry-picked from commit 377a8488b62a9f1b589bb68875dd1288aa70e76e)
> >>
> >>Binary number with fractional part is invalid. Parsing of such binary
> >Typo: s/Binary/ A binary/
> >Typo: s/fractional/a fractional/

Fixed.

> >>numbers returns `STRSCAN_ERROR` for any numbers with non-zero fractional
> >Typo: s/with/with a/

Fixed.

> >>part, because it gives non-zero power of the exponent (`ex2`) in
> >Typo: s/part,/part/

Fixed.

> >Typo: s/non-zero/a non-zero/

Fixed.

> >>`strscan_bin()`. But binary numbers with a zero fractional part
> >>considered as valid numbers. To avoid such inconsistency the check, that
> >Typo: s/considered as/are considered/

Fixed, thanks.

> >>the given base doesn't equal 2, is added, when parsing decimal point
> >Typo: s/parsing/parsing the/

Fixed.

> >>part of the literal.
> >>
> >>Sergey Kaplun:
> >>* added the description and the test for the problem
> >>
> >>Part of tarantool/tarantool#8825
> >>---

<snipped>

> >>+
> >>+-- Test that incorrect literal with non-0 fractional part still
> >Typo: s/that/that an/
> >Typo: s/with/with a/

Fixed.

> >>+-- can't be converted to number.
> >Typo: s/number/a number/

Fixed.

> >>+test:is(tonumber('0b.1'), nil, '0b.1 is not converted')
> >>+-- Test that incorrect literal with 0 fractional part can't be
> >Typo: s/that/that an/

Fixed.

> >>+-- converted to number.
> >Typo: s/number/a number/

Fixed.

See the iterative diff below:

===================================================================
diff --git a/test/tarantool-tests/fix-binary-number-parsing.test.lua b/test/tarantool-tests/fix-binary-number-parsing.test.lua
index df82bd0b..9f149082 100644
--- a/test/tarantool-tests/fix-binary-number-parsing.test.lua
+++ b/test/tarantool-tests/fix-binary-number-parsing.test.lua
@@ -7,11 +7,11 @@ local tap = require('tap')
 local test = tap.test('fix-binary-number-parsing')
 test:plan(2)
 
--- Test that incorrect literal with non-0 fractional part still
--- can't be converted to number.
+-- Test that an incorrect literal with a non-0 fractional part
+-- still can't be converted to a number.
 test:is(tonumber('0b.1'), nil, '0b.1 is not converted')
--- Test that incorrect literal with 0 fractional part can't be
--- converted to number.
+-- Test that an incorrect literal with 0 fractional part can't be
+-- converted to a number.
 test:is(tonumber('0b.0'), nil, '0b.0 is not converted')
 
 test:done(true)
===================================================================

> >>+test:is(tonumber('0b.0'), nil, '0b.0 is not converted')
> >>+
> >>+test:done(true)
> >>--
> >>2.41.0
> >--
> >Best regards,
> >Maxim Kokryashkin
>
-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list