<HTML><BODY><div>Hi, Sergey!</div><div>Thanks for the patch!</div><div>LGTM, except for a few comments below.</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div> <blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16928716390408379123_BODY">From: Mike Pall <mike><br><br>Reported by Egor Skriptunoff.<br><br>(cherry-picked from commit 377a8488b62a9f1b589bb68875dd1288aa70e76e)<br><br>Binary number with fractional part is invalid. Parsing of such binary</div></div></div></div></blockquote><div>Typo: s/Binary/ A binary/</div><div>Typo: s/fractional/a fractional/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>numbers returns `STRSCAN_ERROR` for any numbers with non-zero fractional</div></div></div></div></blockquote><div>Typo: s/with/with a/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>part, because it gives non-zero power of the exponent (`ex2`) in</div></div></div></div></blockquote><div>Typo: s/part,/part/</div><div>Typo: s/non-zero/a non-zero/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>`strscan_bin()`. But binary numbers with a zero fractional part<br>considered as valid numbers. To avoid such inconsistency the check, that</div></div></div></div></blockquote><div>Typo: s/considered as/are considered/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>the given base doesn't equal 2, is added, when parsing decimal point</div></div></div></div></blockquote><div>Typo: s/parsing/parsing the/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>part of the literal.<br><br>Sergey Kaplun:<br>* added the description and the test for the problem<br><br>Part of tarantool/tarantool#8825<br>---<br><br>Branch: <a href="https://github.com/tarantool/luajit/tree/skaplun/fix-binary-number-parsing" target="_blank">https://github.com/tarantool/luajit/tree/skaplun/fix-binary-number-parsing</a><br>Issue: <a href="https://github.com/tarantool/tarantool/issues/8825" target="_blank">https://github.com/tarantool/tarantool/issues/8825</a><br>ML: <a href="https://www.freelists.org/post/luajit/Fractional-binary-number-literals" target="_blank">https://www.freelists.org/post/luajit/Fractional-binary-number-literals</a><br>Tarantool PR: <a href="https://github.com/tarantool/tarantool/pull/9028" target="_blank">https://github.com/tarantool/tarantool/pull/9028</a><br><br>Tarantool's CI is red, because static build on aarch64 can't fetch the<br>LuaJIT's submodule commit somehow. Looks unrelated to the commit:).<br><br> src/lj_strscan.c | 1 +<br> .../fix-binary-number-parsing.test.lua | 17 +++++++++++++++++<br> 2 files changed, 18 insertions(+)<br> create mode 100644 test/tarantool-tests/fix-binary-number-parsing.test.lua<br><br>diff --git a/src/lj_strscan.c b/src/lj_strscan.c<br>index 11d341ee..a2d92714 100644<br>--- a/src/lj_strscan.c<br>+++ b/src/lj_strscan.c<br>@@ -444,6 +444,7 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o,<br> <br> /* Handle decimal point. */<br> if (dp) {<br>+ if (base == 2) return STRSCAN_ERROR;<br> fmt = STRSCAN_NUM;<br> if (dig) {<br> ex = (int32_t)(dp-(p-1)); dp = p-1;<br>diff --git a/test/tarantool-tests/fix-binary-number-parsing.test.lua b/test/tarantool-tests/fix-binary-number-parsing.test.lua<br>new file mode 100644<br>index 00000000..df82bd0b<br>--- /dev/null<br>+++ b/test/tarantool-tests/fix-binary-number-parsing.test.lua<br>@@ -0,0 +1,17 @@<br>+local tap = require('tap')<br>+<br>+-- Test file to demonstrate incorrect behaviour of binary number<br>+-- parsing with fractional dot.<br>+-- See also:<br>+-- <a href="https://www.freelists.org/post/luajit/Fractional-binary-number-literals" target="_blank">https://www.freelists.org/post/luajit/Fractional-binary-number-literals</a><br>+local test = tap.test('fix-binary-number-parsing')<br>+test:plan(2)<br>+<br>+-- Test that incorrect literal with non-0 fractional part still</div></div></div></div></blockquote><div>Typo: s/that/that an/</div><div>Typo: s/with/with a/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>+-- can't be converted to number.</div></div></div></div></blockquote><div>Typo: s/number/a number/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>+test:is(tonumber('0b.1'), nil, '0b.1 is not converted')<br>+-- Test that incorrect literal with 0 fractional part can't be</div></div></div></div></blockquote><div>Typo: s/that/that an/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>+-- converted to number.</div></div></div></div></blockquote><div>Typo: s/number/a number/</div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div><div class="js-helper js-readmsg-msg"><div><div>+test:is(tonumber('0b.0'), nil, '0b.0 is not converted')<br>+<br>+test:done(true)<br>--<br>2.41.0</div></div></div></div></blockquote><div><div>--<br>Best regards,</div><div>Maxim Kokryashkin</div></div><div> </div></div></blockquote></BODY></HTML>