Skip to content

Commit

Permalink
Remove extend methods
Browse files Browse the repository at this point in the history
  • Loading branch information
minhqdao committed Mar 6, 2024
1 parent 2288f65 commit a142396
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions src/version_f.f90
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ module version_f
contains
generic :: parse => parse_comp_set
procedure, private :: parse_comp_set
generic :: extend_with => extend_comps
procedure, private :: extend_comps
end type

interface comparator_set_t
Expand All @@ -107,8 +105,6 @@ module version_f
contains
generic :: parse => parse_version_range
procedure, private :: parse_version_range
generic :: extend_with => extend_comp_sets
procedure, private :: extend_comp_sets
end type

contains
Expand Down Expand Up @@ -874,28 +870,16 @@ subroutine parse_version_range(this, string, error)
call comp_set%parse_comp_set(str(1:i_sep - 1), error)
if (allocated(error)) return

call this%extend_with(comp_set)
this%comp_sets = [this%comp_sets, comp_set]

str = str(i_sep + 2:)
i_sep = index(str, '||')
end do

call comp_set%parse_comp_set(str, error)
if (allocated(error)) return

call this%extend_with(comp_set)
end

!> Extend array of comparator sets within version range with another comparator.
subroutine extend_comp_sets(range, comp_set)
class(version_range_t), intent(inout) :: range
type(comparator_set_t), intent(in) :: comp_set

type(comparator_set_t), allocatable :: tmp(:)

allocate (tmp(size(range%comp_sets) + 1))
tmp(1:size(range%comp_sets)) = range%comp_sets
tmp(size(tmp)) = comp_set
call move_alloc(tmp, range%comp_sets)
this%comp_sets = [this%comp_sets, comp_set]
end

!> Parse a set of comparators that are separated by ` ` from a string. An
Expand Down Expand Up @@ -953,25 +937,12 @@ subroutine parse_comp_set(this, string, error)
end if

if (allocated(error)) return
call this%extend_with(comp)
this%comps = [this%comps, comp]
if (str == '') return
str = trim(adjustl(str))
end do
end

!> Extend array of comparators within comparator set with another comparator.
subroutine extend_comps(set, comp)
class(comparator_set_t), intent(inout) :: set
type(comparator_t), intent(in) :: comp

type(comparator_t), allocatable :: tmp(:)

allocate (tmp(size(set%comps) + 1))
tmp(1:size(set%comps)) = set%comps
tmp(size(tmp)) = comp
call move_alloc(tmp, set%comps)
end

!> Create a comparator from a string. A comparator consists of an operator and
!> a version. An example of a comparator is `>=1.2.3`.
subroutine parse_comp_and_crop_str(comp, op, str, error)
Expand Down

0 comments on commit a142396

Please sign in to comment.