From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C75DA6E210; Fri, 24 Jul 2026 13:09:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C75DA6E210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1784887746; bh=7X4mvkp1KAFyZN9ccsfQ2ka7sJS6z7VvfnLAWhLiiXo=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=J1TMErjSPo9I6q5p3OA7pLdIpKPEqGOtZggjV62OR37Q/yiK7F3rp9CGMyMeafY2I 2YPUSl2cVu794Isg1VJycLeTlma+qWJwKhqz8im3dRFzYNJBcdRDf1LZ1gio8TWbDX hNu0eO6U44SsQ7fG8gnIXU/CZMaCeMdCyfFdbtOM= Received: from send241.i.mail.ru (send241.i.mail.ru [95.163.59.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 149286E210 for ; Fri, 24 Jul 2026 13:09:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 149286E210 Received: by exim-smtp-6c76488b9f-hs8wc with esmtpa (envelope-from ) id 1wnCpx-00000000EfL-3PdQ; Fri, 24 Jul 2026 13:09:02 +0300 Content-Type: multipart/alternative; boundary="------------IgnxYjBIflVpaHPnMtMPy0we" Message-ID: <4302e748-bdff-4201-bb17-fbce9813d79d@tarantool.org> Date: Fri, 24 Jul 2026 13:08:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Evgeniy Temirgaleev Cc: tarantool-patches@dev.tarantool.org References: <20260721075939.2894880-1-skaplun@tarantool.org> In-Reply-To: <20260721075939.2894880-1-skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD93ED3C6BF6FFA701FE67FE95904114F2D75212608AF50F68E182A05F5380850402E55F3F7BC446FE83DE06ABAFEAF67053711679BDC99E3F77EC1506C8F585ED7AF5C6C36E0A87868 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7233EAFDDCC869EB0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566DDF253B6BCADDB7951CF7928C60C0088F6A334426C26C257B8A97EA251DC9D6D389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0DEC8C2C8BCD2534D8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6D6FBC3EC642A93BBCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE77DCDFB3399A2F72843847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A528FCA617C89E3D885002B1117B3ED696196A1D402FA0CF05B74D9144D44E4FCF823CB91A9FED034534781492E4B8EEAD27E9584FBD6BDD31BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659A87AD0EADAD36F494A01526EA4511CB18A2B5A604B8A7A84A44186172BF10749380B78CB741EEE3FB8341EE9D5BE9A0AEAD3E0624DB33396178438D4DA48641F144371F8422AEC766536EB022892E5344C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVWmxowtcrDwU39ArOuNhPek= X-DA7885C5: 8006DF8974598452F255D290C0D534F9CC7D4D7ABE4DAD3E94EA28285698C2A2D7E1683F607480DF5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE2546833B072818CE23DB1332D3AA2EF2A2376E5944EFE618CEF86D5F70DA33880E41E8EF7A07863ECB274557F927329BE2DDF8182D28ACDB545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Add compatibility string coercion for fp:seek() argument. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------IgnxYjBIflVpaHPnMtMPy0we Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello, thanks for the patch! LGTM Sergey On 7/21/26 10:59, Sergey Kaplun wrote: > From: Mike Pall > > Reported by Magnus Wibeck. > > (cherry picked from commit d508715ab657261e8437a52c1b1966c20ab1631d) > > In LuaJIT the second `fp:seek()` argument (offset) doesn't coerce from a > string to an integer value, unlike PUC-Rio Lua 5.1 does. > > This patch adds missing coercion. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#12880 > --- > > Branch:https://github.com/tarantool/luajit/tree/skaplun/lj-1343-fseek-offset-coercion > Related issues: > *https://github.com/LuaJIT/LuaJIT/issues/1343 > *https://github.com/tarantool/tarantool/issues/12880 > > src/Makefile.dep.original | 2 +- > src/lib_io.c | 4 +++- > .../lj-1343-fseek-offset-coercion.test.lua | 23 +++++++++++++++++++ > 3 files changed, 27 insertions(+), 2 deletions(-) > create mode 100644 test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua > > diff --git a/src/Makefile.dep.original b/src/Makefile.dep.original > index 436685f5..acc6b3ba 100644 > --- a/src/Makefile.dep.original > +++ b/src/Makefile.dep.original > @@ -21,7 +21,7 @@ lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ > lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lmisclib.h lj_arch.h > lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ > lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_state.h \ > - lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h > + lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_strscan.h lj_libdef.h > lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ > lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ > lj_state.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h \ > diff --git a/src/lib_io.c b/src/lib_io.c > index ef39e535..2d0abf78 100644 > --- a/src/lib_io.c > +++ b/src/lib_io.c > @@ -25,6 +25,7 @@ > #include "lj_strfmt.h" > #include "lj_ff.h" > #include "lj_lib.h" > +#include "lj_strscan.h" > > /* Userdata payload for I/O file. */ > typedef struct IOFileUD { > @@ -317,13 +318,14 @@ LJLIB_CF(io_method_seek) > FILE *fp = io_tofile(L)->fp; > int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end"); > int64_t ofs = 0; > - cTValue *o; > + TValue *o; > int res; > if (opt == 0) opt = SEEK_SET; > else if (opt == 1) opt = SEEK_CUR; > else if (opt == 2) opt = SEEK_END; > o = L->base+2; > if (o < L->top) { > + if (tvisstr(o)) lj_strscan_num(strV(o), o); > if (tvisint(o)) > ofs = (int64_t)intV(o); > else if (tvisnum(o)) > diff --git a/test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua b/test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua > new file mode 100644 > index 00000000..fdfc6ce5 > --- /dev/null > +++ b/test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua > @@ -0,0 +1,23 @@ > +local tap = require('tap') > + > +-- The test file to demonstrate LuaJIT's missing coercion for the > +-- `io.fseek()` offset argument. > +-- See also:https://github.com/LuaJIT/LuaJIT/issues/1343. > + > +local test = tap.test('lj-1343-fseek-offset-coercion') > + > +test:plan(2) > + > +local f = io.tmpfile() > + > +f:write('12345') > + > +f:seek('set', 0) > +f:seek('set', '1') > +test:is(f:read('*all'), '2345', 'base coercion test') > + > +f:seek('set', 0) > +f:seek('set', '1.9') > +test:is(f:read('*all'), '2345', 'coercion test for non-integer value') > + > +test:done(true) --------------IgnxYjBIflVpaHPnMtMPy0we Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hello,

thanks for the patch! LGTM

Sergey

On 7/21/26 10:59, Sergey Kaplun wrote:
From: Mike Pall <mike>

Reported by Magnus Wibeck.

(cherry picked from commit d508715ab657261e8437a52c1b1966c20ab1631d)

In LuaJIT the second `fp:seek()` argument (offset) doesn't coerce from a
string to an integer value, unlike PUC-Rio Lua 5.1 does.

This patch adds missing coercion.

Sergey Kaplun:
* added the description and the test for the problem

Part of tarantool/tarantool#12880
---

Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1343-fseek-offset-coercion
Related issues:
* https://github.com/LuaJIT/LuaJIT/issues/1343
* https://github.com/tarantool/tarantool/issues/12880

 src/Makefile.dep.original                     |  2 +-
 src/lib_io.c                                  |  4 +++-
 .../lj-1343-fseek-offset-coercion.test.lua    | 23 +++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua

diff --git a/src/Makefile.dep.original b/src/Makefile.dep.original
index 436685f5..acc6b3ba 100644
--- a/src/Makefile.dep.original
+++ b/src/Makefile.dep.original
@@ -21,7 +21,7 @@ lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
 lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lmisclib.h lj_arch.h
 lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
  lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_state.h \
- lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h
+ lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_strscan.h lj_libdef.h
 lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
  lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
  lj_state.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h \
diff --git a/src/lib_io.c b/src/lib_io.c
index ef39e535..2d0abf78 100644
--- a/src/lib_io.c
+++ b/src/lib_io.c
@@ -25,6 +25,7 @@
 #include "lj_strfmt.h"
 #include "lj_ff.h"
 #include "lj_lib.h"
+#include "lj_strscan.h"
 
 /* Userdata payload for I/O file. */
 typedef struct IOFileUD {
@@ -317,13 +318,14 @@ LJLIB_CF(io_method_seek)
   FILE *fp = io_tofile(L)->fp;
   int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end");
   int64_t ofs = 0;
-  cTValue *o;
+  TValue *o;
   int res;
   if (opt == 0) opt = SEEK_SET;
   else if (opt == 1) opt = SEEK_CUR;
   else if (opt == 2) opt = SEEK_END;
   o = L->base+2;
   if (o < L->top) {
+    if (tvisstr(o)) lj_strscan_num(strV(o), o);
     if (tvisint(o))
       ofs = (int64_t)intV(o);
     else if (tvisnum(o))
diff --git a/test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua b/test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua
new file mode 100644
index 00000000..fdfc6ce5
--- /dev/null
+++ b/test/tarantool-tests/lj-1343-fseek-offset-coercion.test.lua
@@ -0,0 +1,23 @@
+local tap = require('tap')
+
+-- The test file to demonstrate LuaJIT's missing coercion for the
+-- `io.fseek()` offset argument.
+-- See also: https://github.com/LuaJIT/LuaJIT/issues/1343.
+
+local test = tap.test('lj-1343-fseek-offset-coercion')
+
+test:plan(2)
+
+local f = io.tmpfile()
+
+f:write('12345')
+
+f:seek('set', 0)
+f:seek('set', '1')
+test:is(f:read('*all'), '2345', 'base coercion test')
+
+f:seek('set', 0)
+f:seek('set', '1.9')
+test:is(f:read('*all'), '2345', 'coercion test for non-integer value')
+
+test:done(true)
--------------IgnxYjBIflVpaHPnMtMPy0we--