From b1717345d3e814829f6591751994bfedcdf876b9 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 17 May 2025 17:47:29 -0300 Subject: updates for latest Teal (#1796) --- src/luarocks/cmd/upload.lua | 5 +++-- src/luarocks/cmd/upload.tl | 3 ++- src/luarocks/deps.lua | 10 +++++----- src/luarocks/deps.tl | 14 +++++++------- src/luarocks/tools/patch.lua | 11 +++++------ src/luarocks/tools/patch.tl | 13 ++++++------- 6 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.lua index 755dd4e7..e4319bb1 100644 --- a/src/luarocks/cmd/upload.lua +++ b/src/luarocks/cmd/upload.lua @@ -1,4 +1,4 @@ -local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local string = _tl_compat and _tl_compat.string or string +local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string local upload = { Response = { version = {} } } @@ -132,7 +132,8 @@ function upload.command(args) return nil, "Invalid response from server." end util.printout(("Sending " .. tostring(rock_fname) .. " ...")) - res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, { + local id = math.tointeger(res.version.id) + res, err = api:method("upload_rock/" .. ("%d"):format(id), nil, { rock_file = multipart.new_file(rock_fname), rock_sig = rock_sigfname and multipart.new_file(rock_sigfname), }) diff --git a/src/luarocks/cmd/upload.tl b/src/luarocks/cmd/upload.tl index 5b6e3314..a12b30c0 100644 --- a/src/luarocks/cmd/upload.tl +++ b/src/luarocks/cmd/upload.tl @@ -132,7 +132,8 @@ function upload.command(args: Args): boolean, string, string return nil, "Invalid response from server." end util.printout(("Sending " .. tostring(rock_fname) .. " ...")) - res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, { + local id = math.tointeger(res.version.id) + res, err = api:method("upload_rock/" .. ("%d"):format(id), nil, { rock_file = multipart.new_file(rock_fname), rock_sig = rock_sigfname and multipart.new_file(rock_sigfname), }) as (Response, string) diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index e02d4694..19cf6936 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -1,4 +1,4 @@ -local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local assert = _tl_compat and _tl_compat.assert or assert; local io = _tl_compat and _tl_compat.io or io; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local pairs = _tl_compat and _tl_compat.pairs or pairs; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table; local type = type +local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local assert = _tl_compat and _tl_compat.assert or assert; local io = _tl_compat and _tl_compat.io or io; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local math = _tl_compat and _tl_compat.math or math; local pairs = _tl_compat and _tl_compat.pairs or pairs; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table; local type = type local deps = {} @@ -201,7 +201,7 @@ function deps.report_missing_dependencies(name, version, dependencies, deps_mode first_missing_dep = false end - util.printout((" %s (%s)"):format(tostring(depq), rock_status(depq, get_versions))) + util.printout((" %s (%s)"):format(tostring(depq), (rock_status(depq, get_versions)))) end end end @@ -301,7 +301,7 @@ function deps.fulfill_dependencies(rockspec, depskey, deps_mode, verify, deplock local depq = queries.new(dname, dnamespace, dversion) util.printout(("%s %s is pinned to %s (%s)"):format( - name, version, tostring(depq), rock_status(depq, get_versions))) + name, version, tostring(depq), (rock_status(depq, get_versions)))) local okfullfill, errfullfill = deps.fulfill_dependency(depq, "none", rocks_provided, verify, depskey) if not okfullfill then @@ -327,7 +327,7 @@ function deps.fulfill_dependencies(rockspec, depskey, deps_mode, verify, deplock for _, depq in ipairs((rockspec)[depskey].queries) do util.printout(("%s %s depends on %s (%s)"):format( - name, version, tostring(depq), rock_status(depq, get_versions))) + name, version, tostring(depq), (rock_status(depq, get_versions)))) local okfulfill, found_or_err, _ = deps.fulfill_dependency(depq, deps_mode, rocks_provided, verify, depskey) if okfulfill then @@ -703,7 +703,7 @@ end local function lua_h_exists(d, luaver) local major, minor = luaver:match("(%d+)%.(%d+)") - local luanum = ("%s%02d"):format(major, tonumber(minor)) + local luanum = ("%s%02d"):format(major, math.tointeger(minor)) local lua_h = dir.path(d, "lua.h") local fd = io.open(lua_h) diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl index 5ca9c879..f6a6642f 100644 --- a/src/luarocks/deps.tl +++ b/src/luarocks/deps.tl @@ -201,7 +201,7 @@ function deps.report_missing_dependencies(name: string, version: string, depende first_missing_dep = false end - util.printout((" %s (%s)"):format(tostring(depq), rock_status(depq, get_versions))) + util.printout((" %s (%s)"):format(tostring(depq), (rock_status(depq, get_versions)))) end end end @@ -301,7 +301,7 @@ function deps.fulfill_dependencies(rockspec: Rockspec, depskey: DepsKey, deps_mo local depq = queries.new(dname, dnamespace, dversion) util.printout(("%s %s is pinned to %s (%s)"):format( - name, version, tostring(depq), rock_status(depq, get_versions))) + name, version, tostring(depq), (rock_status(depq, get_versions)))) local okfullfill, errfullfill = deps.fulfill_dependency(depq, "none", rocks_provided, verify, depskey) if not okfullfill then @@ -327,7 +327,7 @@ function deps.fulfill_dependencies(rockspec: Rockspec, depskey: DepsKey, deps_mo for _, depq in ipairs((rockspec as {string: Dependencies})[depskey].queries) do util.printout(("%s %s depends on %s (%s)"):format( - name, version, tostring(depq), rock_status(depq, get_versions))) + name, version, tostring(depq), (rock_status(depq, get_versions)))) local okfulfill, found_or_err, _ = deps.fulfill_dependency(depq, deps_mode, rocks_provided, verify, depskey) if okfulfill then @@ -703,7 +703,7 @@ end local function lua_h_exists(d: string, luaver: string): boolean, string, string, integer local major, minor = luaver:match("(%d+)%.(%d+)") - local luanum = ("%s%02d"):format(major, tonumber(minor)) + local luanum = ("%s%02d"):format(major, math.tointeger(minor)) local lua_h = dir.path(d, "lua.h") local fd = io.open(lua_h) @@ -749,7 +749,7 @@ local function find_lua_incdir(prefix: string, luaver: string, luajitver: string end function deps.check_lua_incdir(vars: {string: string}): boolean, string, string - if vars.LUA_INCDIR_OK == "ok" + if vars.LUA_INCDIR_OK == "ok" then return true end @@ -777,7 +777,7 @@ function deps.check_lua_incdir(vars: {string: string}): boolean, string, string end function deps.check_lua_libdir(vars: {string: string}): boolean, string, string, {string : {string}} - if vars.LUA_LIBDIR_OK == "ok" + if vars.LUA_LIBDIR_OK == "ok" then return true end @@ -814,7 +814,7 @@ function deps.check_lua_libdir(vars: {string: string}): boolean, string, string, -- if filename isn't versioned, check file contents local txt = fd:read("*a") ok = txt:find("Lua " .. cfg.lua_version, 1, true) - or txt:find("lua" .. (cfg.lua_version:gsub("%.", "")), 1, true) + or txt:find("lua" .. (cfg.lua_version:gsub("%.", "")), 1, true) and true if not ok then err = "Lua library at " .. filename .. " does not match Lua version " .. cfg.lua_version .. ". You can use `luarocks config variables.LUA_LIBDIR ` to set the correct location." diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 8dc188a6..d1575cb0 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -129,14 +129,13 @@ local function file_lines(f) end end end - local posi = math.tointeger(pos) - if not posi then - posi = #buffer + if not pos then + pos = #buffer elseif chars == '\r\n' then - posi = posi + 1 + pos = pos + 1 end - local line = buffer:sub(pos_beg, posi) - pos_beg = posi + 1 + local line = buffer:sub(pos_beg, pos) + pos_beg = pos + 1 if #line > 0 then return line end diff --git a/src/luarocks/tools/patch.tl b/src/luarocks/tools/patch.tl index 83c16ab7..553964e3 100644 --- a/src/luarocks/tools/patch.tl +++ b/src/luarocks/tools/patch.tl @@ -114,7 +114,7 @@ local function file_lines(f: FILE): function(): string local buffer = "" local pos_beg = 1 return function(): string - local pos, chars: string, string + local pos, chars: integer, string while 1 do pos, chars = buffer:match('()([\r\n].)', pos_beg) if pos or not f then @@ -129,14 +129,13 @@ local function file_lines(f: FILE): function(): string end end end - local posi = math.tointeger(pos) - if not posi then - posi = #buffer + if not pos then + pos = #buffer elseif chars == '\r\n' then - posi = posi + 1 + pos = pos + 1 end - local line = buffer:sub(pos_beg, posi) - pos_beg = posi + 1 + local line = buffer:sub(pos_beg, pos) + pos_beg = pos + 1 if #line > 0 then return line end -- cgit v1.2.3-55-g6feb