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;