From f7098c70e157309495cbe0064cdc36af2f86aae8 Mon Sep 17 00:00:00 2001 From: Henry Gross-Hellsen <6283258+cowpod@users.noreply.github.com> Date: Sun, 13 Oct 2024 00:20:52 -0700 Subject: [PATCH] Update interval_range_utils.php --- functions/interval_range_utils.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/functions/interval_range_utils.php b/functions/interval_range_utils.php index 84e7c02..bec1172 100644 --- a/functions/interval_range_utils.php +++ b/functions/interval_range_utils.php @@ -71,18 +71,42 @@ function in_range($range, $num) { $matches=[]; if (preg_match("/^(\[)([0-9\.]*),\s?([0-9\.]*)(\])$/", $range, $matches)) { // [, ] [$full,$not1,$low,$high,$not2]=$matches; + if (empty($high)) { + return (version_compare($num, $low, '>=')); + } + if (empty($low)) { + return (version_compare($num, $high, '<=')); + } return (version_compare($num, $low, '>=') && version_compare($num, $high, '<=')); } elseif (preg_match("/^(\[)([0-9\.]*),\s?([0-9\.]*)(\))$/", $range, $matches)) { // [, ) [$full,$not1,$low,$high,$not2]=$matches; + if (empty($high)) { + return (version_compare($num, $low, '>=')); + } + if (empty($low)) { + return (version_compare($num, $high, '<')); + } return (version_compare($num, $low, '>=') && version_compare($num, $high, '<')); } elseif (preg_match("/^(\()([0-9\.]*),\s?([0-9\.]*)(\])$/", $range, $matches)) { // (, ] [$full,$not1,$low,$high,$not2]=$matches; + if (empty($high)) { + return (version_compare($num, $low, '>')); + } + if (empty($low)) { + return (version_compare($num, $high, '<=')); + } return (version_compare($num, $low, '>') && version_compare($num, $high, '<=')); } elseif (preg_match("/^(\()([0-9\.]*),\s?([0-9\.]*)(\))$/", $range, $matches)) { // (, ) [$full,$not1,$low,$high,$not2]=$matches; + if (empty($high)) { + return (version_compare($num, $low, '>')); + } + if (empty($low)) { + return (version_compare($num, $high, '<')); + } return (version_compare($num, $low, '>') && version_compare($num, $high, '<')); } @@ -90,7 +114,6 @@ function in_range($range, $num) { return version_compare($range,$num,'='); } - function parse_interval_range($mcversion) { $min=null; $max=null;