<commit_before>-module(yaws_dynopts).

-include("../include/yaws.hrl").
-include("../include/yaws_api.hrl").

-export([
         have_bad_unicode/0,
         have_bad_wildcard/0,
         have_ssl_honor_cipher_order/0,
         have_ssl_client_renegotiation/0,
         have_ssl_sni/0,
         have_ssl_log_alert/0,
         have_erlang_sendfile/0,
         have_crypto_hash/0,
         have_crypto_strong_rand_bytes/0,
         have_inet_parse_strict_address/0,
         have_erlang_now/0,
         have_rand/0,

         rand_bytes/1,
         hash/1,
         unique_triple/0,
         get_time_tuple/0,
         now_secs/0,
         parse_strict_address/1,
         random_seed/3,
         random_uniform/1,

         generate/1,
         is_generated/0
        ]).

%% Unicode module is buggy for R14B04 and previous (ERTS <= 5.8.5)
have_bad_unicode() ->
    is_less_or_equal(erlang:system_info(version), "5.8.5").

%% filelib:wildcard/2 is buggy for R15B03 and previous (ERTS <= 5.9.3)
have_bad_wildcard() ->
    is_less_or_equal(erlang:system_info(version), "5.9.3").

%% SSL option honor_cipher_order was added in release 17 (ERTS >= 6.0)
have_ssl_honor_cipher_order() ->
    is_greater_or_equal(erlang:system_info(version), "6.0").

%% SSL option client_renegotiation was added in release 18 (ERTS >= 7.0)
have_ssl_client_renegotiation() ->
    is_greater_or_equal(erlang:system_info(version), "7.0").

%% SSL sni support was added in release 18  (ERTS >= 7.0)
have_ssl_sni() ->
    is_greater_or_equal(erlang:system_info(version), "7.0").

%% SSL option log_alert SSL was added in R16B02 (ERTS >= 5.10.3)
have_ssl_log_alert() ->
    is_greater_or_equal(erlang:system_info(version), "5.10.3").

%% erlang:sendfile/5 is buggy for R15 & R16 releases (ERTS < 6.0)
have_erlang_sendfile() ->
    is_greater_or_equal(erlang:system_info(version), "6.0").

%% crypto:sha/1 is deprecated since R16B01 (ERTS >= 5.10.2)
have_crypto_hash() ->
    erlang:function_exported(crypto, hash, 2).

%% crypto:rand_bytes/1 is deprecated since releases 19 (ERTS >= 8.0)
have_crypto_strong_rand_bytes() ->
    erlang:function_exported(crypto, strong_rand_bytes, 1).

%% inet:parse_strict_address was exported in R16A (ERTS >= 5.10)
have_inet_parse_strict_address() ->
    erlang:function_exported(inet, parse_strict_address, 1).

%% erlang:now/0 is deprecated since releases 18 (ERTS >= 7.0)<commit_msg>Use MOD:module_info/1 instead of erlang:function_exported/3 in yaws_dynopts<commit_after>-module(yaws_dynopts).

-include("../include/yaws.hrl").
-include("../include/yaws_api.hrl").

-export([
         have_bad_unicode/0,
         have_bad_wildcard/0,
         have_ssl_honor_cipher_order/0,
         have_ssl_client_renegotiation/0,
         have_ssl_sni/0,
         have_ssl_log_alert/0,
         have_erlang_sendfile/0,
         have_crypto_hash/0,
         have_crypto_strong_rand_bytes/0,
         have_inet_parse_strict_address/0,
         have_erlang_now/0,
         have_rand/0,

         rand_bytes/1,
         hash/1,
         unique_triple/0,
         get_time_tuple/0,
         now_secs/0,
         parse_strict_address/1,
         random_seed/3,
         random_uniform/1,

         generate/1,
         is_generated/0
        ]).

%% Unicode module is buggy for R14B04 and previous (ERTS <= 5.8.5)
have_bad_unicode() ->
    is_less_or_equal(erlang:system_info(version), "5.8.5").

%% filelib:wildcard/2 is buggy for R15B03 and previous (ERTS <= 5.9.3)
have_bad_wildcard() ->
    is_less_or_equal(erlang:system_info(version), "5.9.3").

%% SSL option honor_cipher_order was added in release 17 (ERTS >= 6.0)
have_ssl_honor_cipher_order() ->
    is_greater_or_equal(erlang:system_info(version), "6.0").

%% SSL option client_renegotiation was added in release 18 (ERTS >= 7.0)
have_ssl_client_renegotiation() ->
    is_greater_or_equal(erlang:system_info(version), "7.0").

%% SSL sni support was added in release 18  (ERTS >= 7.0)
have_ssl_sni() ->
    is_greater_or_equal(erlang:system_info(version), "7.0").

%% SSL option log_alert SSL was added in R16B02 (ERTS >= 5.10.3)
have_ssl_log_alert() ->
    is_greater_or_equal(erlang:system_info(version), "5.10.3").

%% erlang:sendfile/5 is buggy for R15 & R16 releases (ERTS < 6.0)
have_erlang_sendfile() ->
    is_greater_or_equal(erlang:system_info(version), "6.0").

%% crypto:sha/1 is deprecated since R16B01 (ERTS >= 5.10.2)
have_crypto_hash() ->
    lists:member({hash, 2}, crypto:module_info(exports)).

%% crypto:rand_bytes/1 is deprecated since releases 19 (ERTS >= 8.0)
have_crypto_strong_rand_bytes() ->
    lists:member({strong_rand_bytes, 1}, crypto:module_info(exports)).

%% inet:parse_strict_address was exported in R16A (ERTS >= 5.10)
have_inet_parse_strict_address() ->
    lists:member({parse_strict_address, 1}, inet:module_info(exports)).

%% erlang:now/0 is deprecated since releases 18 (ERTS >= 7.0)
{'fraction_non_alphanumeric': 0.12738461538461537, 'fraction_numerical': 0.04512820512820513, 'mean_word_length': 3.4611161939615736, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 39, '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': '4513408', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1796, 'n_words': 319}