is_valid_feature_name Function

public function is_valid_feature_name(name) result(valid)

Check if feature name is valid (alphanumeric, underscore, dash allowed)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Return Value logical


Source Code

logical function is_valid_feature_name(name) result(valid)
    character(len=*), intent(in) :: name
    integer :: i
    character :: c
    
    valid = .false.
    
    ! Must not be empty and not too long
    if (len_trim(name) == 0 .or. len_trim(name) > 64) return
    
    ! First character must be alphabetic or underscore
    c = name(1:1)
    if (.not. ((c >= 'a' .and. c <= 'z') .or. (c >= 'A' .and. c <= 'Z') .or. c == '_')) return
    
    ! Remaining characters can be alphanumeric, underscore, or dash
    do i = 2, len_trim(name)
        c = name(i:i)
        if (.not. ((c >= 'a' .and. c <= 'z') .or. (c >= 'A' .and. c <= 'Z') .or. &
                  (c >= '0' .and. c <= '9') .or. c == '_' .or. c == '-')) then
            return
        end if
    end do
    
    valid = .true.
    
end function is_valid_feature_name