<commit_before>{ lib, stdenv, fetchurl
, pcre, windows ? null
, variant ? null
}:

with lib;

assert elem variant [ null "cpp" "pcre16" "pcre32" ];

let
  version = "8.44";
  pname = if (variant == null) then "pcre"
    else  if (variant == "cpp") then "pcre-cpp"
    else  variant;

in stdenv.mkDerivation {
  name = "${pname}-${version}";

  src = fetchurl {
    url = "https://ftp.pcre.org/pub/pcre/pcre-${version}.tar.bz2";
    sha256 = "0v9nk51wh55pcbnf2jr36yarz8ayajn6d7ywiq2wagivn9c8c40r";
  };

  outputs = [ "bin" "dev" "out" "doc" "man" ];

  # Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51
  configureFlags = optional (!stdenv.hostPlatform.isRiscV && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--enable-jit" ++ [
    "--enable-unicode-properties"
    "--disable-cpp"
  ]
    ++ optional (variant != null) "--enable-${variant}";

  # https://bugs.exim.org/show_bug.cgi?id=2173
  patches = [ ./stacksize-detection.patch ];

  preCheck = ''
    patchShebangs RunGrepTest
  '';

  doCheck = !(with stdenv.hostPlatform; isCygwin || isFreeBSD) && stdenv.hostPlatform == stdenv.buildPlatform;
    # XXX: test failure on Cygwin
    # we are running out of stack on both freeBSDs on Hydra
<commit_msg>pcre: ftp.pcre.org defunct<commit_after>{ lib, stdenv, fetchurl
, pcre, windows ? null
, variant ? null
}:

with lib;

assert elem variant [ null "cpp" "pcre16" "pcre32" ];

let
  version = "8.44";
  pname = if (variant == null) then "pcre"
    else  if (variant == "cpp") then "pcre-cpp"
    else  variant;

in stdenv.mkDerivation {
  name = "${pname}-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/project/pcre/pcre/${version}/pcre-${version}.tar.bz2";
    sha256 = "0v9nk51wh55pcbnf2jr36yarz8ayajn6d7ywiq2wagivn9c8c40r";
  };

  outputs = [ "bin" "dev" "out" "doc" "man" ];

  # Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51
  configureFlags = optional (!stdenv.hostPlatform.isRiscV && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--enable-jit" ++ [
    "--enable-unicode-properties"
    "--disable-cpp"
  ]
    ++ optional (variant != null) "--enable-${variant}";

  # https://bugs.exim.org/show_bug.cgi?id=2173
  patches = [ ./stacksize-detection.patch ];

  preCheck = ''
    patchShebangs RunGrepTest
  '';

  doCheck = !(with stdenv.hostPlatform; isCygwin || isFreeBSD) && stdenv.hostPlatform == stdenv.buildPlatform;
    # XXX: test failure on Cygwin
    # we are running out of stack on both freeBSDs on Hydra

{'fraction_non_alphanumeric': 0.16122689736531656, 'fraction_numerical': 0.028313016122689737, 'mean_word_length': 3.600361663652803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 5, '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': '122710', 'n_tokens_mistral': 1024, 'n_tokens_neox': 970, 'n_words': 198}