From bdb7345a28f9b8d3edba46ac0dc5cfbd57cb92e8 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 26 Aug 2024 12:05:01 -0300 Subject: fix: patch: check array indices correctly --- src/luarocks/tools/patch.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 6f36d713..10654e06 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -11,7 +11,6 @@ local patch = {} local fs = require("luarocks.fs") -local fun = require("luarocks.fun") local io = io local os = os @@ -255,7 +254,7 @@ function patch.read_patch(filename, data) local advance if state == 'filenames' then if startswith(line, "--- ") then - if fun.contains(files.source, nextfileno) then + if files.source[nextfileno] then all_ok = false warning(format("skipping invalid patch for %s", files.source[nextfileno+1])) @@ -278,7 +277,7 @@ function patch.read_patch(filename, data) table.insert(files.source, match) end elseif not startswith(line, "+++ ") then - if fun.contains(files.source, nextfileno) then + if files.source[nextfileno] then all_ok = false warning(format("skipping invalid patch with no target for %s", files.source[nextfileno+1])) @@ -289,7 +288,7 @@ function patch.read_patch(filename, data) end state = 'header' else - if fun.contains(files.target, nextfileno) then + if files.target[nextfileno] then all_ok = false warning(format("skipping invalid patch - double target at line %d", lineno+1)) @@ -331,7 +330,7 @@ function patch.read_patch(filename, data) if not advance and state == 'hunkhead' then local m1, m2, m3, m4 = match_linerange(line) if not m1 then - if not fun.contains(files.hunks, nextfileno-1) then + if not files.hunks[nextfileno-1] then all_ok = false warning(format("skipping invalid patch with no hunks for file %s", files.target[nextfileno])) -- cgit v1.2.3-55-g6feb