<commit_before># -- <NAME>, realXtend -- 2009

# parse a keyword delimited list of arguments into single list
# results are in OUT
function (sagase_parse_arguments BEGIN END ARGS)
    set (take FALSE)
    foreach (var ${ARGN})
        if (${var} STREQUAL ${BEGIN})
            set (take TRUE)
        elseif (${var} STREQUAL ${END})
            set (take FALSE)
        else ()
            if (take)
                set (out ${out} ${var})
            endif ()
        endif ()
    endforeach ()

    set (${ARGS} ${out} PARENT_SCOPE)
endfunction (sagase_parse_arguments)


# generates a set of likely paths for a files (includes or libraries)
# "NAMES" is a list of names by which the package is known
# "PREFIXES" is a list of path prefixes where the components might be found
# results are in INCLUDE_PATHS, LIBRARY_PATHS  
function (sagase_generate_paths INCLUDE_PATHS LIBRARY_PATHS)
    sagase_parse_arguments ("NAMES" "PREFIXES" path_names ${ARGN})
    sagase_parse_arguments ("PREFIXES" none path_prefixes ${ARGN})

    if (MSVC)
        set (path_prefixes ${path_prefixes} "C:/")
    elseif (APPLE)
        message (FATAL_ERROR "sagase: MacOS Support incomplete")
    elseif (UNIX)
        set (path_prefixes ${path_prefixes} "/usr" "/usr/local" "/opt")
    else ()
        message (FATAL_ERROR "sagase: Unable to detect OS type")
    endif ()

    # add prefix paths
    foreach (prefix ${path_prefixes})

        set (includes ${includes} 
            ${prefix}/includes)

        set (libraries ${libraries} 
            ${prefix}/lib 
            ${prefix}/bin 
            ${prefix}/dll)

    endforeach ()

    # add prefix+name paths
    foreach (prefix ${path_prefixes})
        foreach (pkgname ${path_names})

            set (includes ${includes} 
                ${prefix}/${pkgname}/includes 
                ${prefix}/includes/${pkgname})

            set (libraries ${libraries} 
                ${prefix}/${pkgname}/lib ${prefix}/lib/${pkgname}
                ${prefix}/${pkgname}/bin ${prefix}/bin/${pkgname}
                ${prefix}/${pkgname}/dll ${prefix}/dll/${pkgname})

        endforeach ()
    endforeach ()

    set (${INCLUDE_PATHS} ${includes} PARENT_SCOPE)
    set (${LIBRARY_PATHS} ${libraries} PARENT_SCOPE)

endfunction (sagase_generate_paths)

# tries a series of methods to find correct compile and link info.
# "NAMES" is a list of names by which the package is known. used by
# find_package and in constructing search path names.
# "COMPONENTS" is a list of sub-components that are required. used by
# find_package and by pkg-config.<commit_msg>convert cmake build to sagase/use_package: fixed typeo<commit_after># -- <NAME>, realXtend -- 2009

# parse a keyword delimited list of arguments into single list
# results are in OUT
function (sagase_parse_arguments BEGIN END ARGS)
    set (take FALSE)
    foreach (var ${ARGN})
        if (${var} STREQUAL ${BEGIN})
            set (take TRUE)
        elseif (${var} STREQUAL ${END})
            set (take FALSE)
        else ()
            if (take)
                set (out ${out} ${var})
            endif ()
        endif ()
    endforeach ()

    set (${ARGS} ${out} PARENT_SCOPE)
endfunction (sagase_parse_arguments)


# generates a set of likely paths for a files (includes or libraries)
# "NAMES" is a list of names by which the package is known
# "PREFIXES" is a list of path prefixes where the components might be found
# results are in INCLUDE_PATHS, LIBRARY_PATHS  
function (sagase_generate_paths INCLUDE_PATHS LIBRARY_PATHS)
    sagase_parse_arguments ("NAMES" "PREFIXES" path_names ${ARGN})
    sagase_parse_arguments ("PREFIXES" none path_prefixes ${ARGN})

    if (MSVC)
        set (path_prefixes ${path_prefixes} "C:/")
    elseif (APPLE)
        message (FATAL_ERROR "sagase: MacOS Support incomplete")
    elseif (UNIX)
        set (path_prefixes ${path_prefixes} "/usr" "/usr/local" "/opt")
    else ()
        message (FATAL_ERROR "sagase: Unable to detect OS type")
    endif ()

    # add prefix paths
    foreach (prefix ${path_prefixes})

        set (includes ${includes} 
            ${prefix}/includes)

        set (libraries ${libraries} 
            ${prefix}/lib 
            ${prefix}/bin 
            ${prefix}/dll)

    endforeach ()

    # add prefix+name paths
    foreach (prefix ${path_prefixes})
        foreach (pkgname ${path_names})

            set (includes ${includes} 
                ${prefix}/${pkgname}/include 
                ${prefix}/include/${pkgname})

            set (libraries ${libraries} 
                ${prefix}/${pkgname}/lib ${prefix}/lib/${pkgname}
                ${prefix}/${pkgname}/bin ${prefix}/bin/${pkgname}
                ${prefix}/${pkgname}/dll ${prefix}/dll/${pkgname})

        endforeach ()
    endforeach ()

    set (${INCLUDE_PATHS} ${includes} PARENT_SCOPE)
    set (${LIBRARY_PATHS} ${libraries} PARENT_SCOPE)

endfunction (sagase_generate_paths)

# tries a series of methods to find correct compile and link info.
# "NAMES" is a list of names by which the package is known. used by
# find_package and in constructing search path names.
# "COMPONENTS" is a list of sub-components that are required. used by
# find_package and by pkg-config.
{'fraction_non_alphanumeric': 0.11568665006703696, 'fraction_numerical': 0.0015322735108216816, 'mean_word_length': 2.61134163208852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4790514', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1533, 'n_words': 499}