Skip to content

Commit

Permalink
Issue #679 Update range testing in MName:isloaded() and MName:prereq()
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Mar 26, 2024
1 parent d130c7d commit 8201a97
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/MName.lua
Expand Up @@ -578,10 +578,15 @@ function M.isloaded(self)
local status = mt:status(sn)
local sn_status = ((status == "active") or (status == "pending"))
if (sn_status and self.__have_range) then
local pV = parseVersion(mt:version(sn))
if ((self.__range[1] <= pV) and (pV <= self.__range[2])) then
local lowerBound = self.__range[1]
local upperBound = self.__range[2]
local lowerFn = self.__range_fnA[1]
local upperFn = self.__range_fnA[2]
local pV = parseVersion(mt:version(sn))
if (lowerFn(lowerBound, pV) and upperFn(pV, upperBound)) then
return sn_status
end
return false
end

local userName = self:userName()
Expand Down Expand Up @@ -641,10 +646,15 @@ function M.prereq(self)
end

if (self.__have_range) then
local pV = parseVersion(mt:version(sn))
if ((self.__range[1] <= pV) and (pV <= self.__range[2])) then
local lowerBound = self.__range[1]
local upperBound = self.__range[2]
local lowerFn = self.__range_fnA[1]
local upperFn = self.__range_fnA[2]
local pV = parseVersion(mt:version(sn))
if (lowerFn(lowerBound, pV) and upperFn(pV, upperBound)) then
return false
end
return userName
end

if (userName == sn or userName == fullName) then
Expand All @@ -666,11 +676,8 @@ function M.conflictCk(self, mt)
dbg.start{"MName:conflictCk(mt)"}
local userName = self:userName()
local sn = self:sn()
dbg.print{"(0) sn: ",sn,"\n"}
dbg.print{"(0) userName: ",userName,"\n"}
if (not (sn and mt:have(sn,"active"))) then
userName = false
dbg.print{"(1) userName: ",userName,"\n"}
dbg.fini("MName:conflictCk")
return false
end
Expand All @@ -682,27 +689,21 @@ function M.conflictCk(self, mt)
local upperFn = self.__range_fnA[2]
local pV = parseVersion(mt:version(sn))

dbg.print{"pV: ",pV,", lowerBound: ",lowerBound,", upperBound: ",upperBound,"\n"}

if (lowerFn(lowerBound, pV) and upperFn(pV, upperBound)) then
local userName = mt:fullName(sn)
dbg.print{"(2) userName: ",userName,"\n"}
dbg.fini("MName:conflictCk")
return userName
end
userName = false
dbg.print{"(3) userName: ",userName,"\n"}
dbg.fini("MName:conflictCk")
return userName
end

if (self:userName() == sn or extractVersion(userName, sn) == mt:version(sn)) then
dbg.print{"(4) userName: ",userName,"\n"}
dbg.fini("MName:conflictCk")
return userName
end
userName = false
dbg.print{"(5) userName: ",userName,"\n"}
dbg.fini("MName:conflictCk")
return userName
end
Expand Down

0 comments on commit 8201a97

Please sign in to comment.