<commit_before>require "formula"

class Lua < Formula
  homepage "http://www.lua.org/"
  url "http://www.lua.org/ftp/lua-5.2.3.tar.gz"
  mirror "https://mirrors.kernel.org/debian/pool/main/l/lua5.2/lua5.2_5.2.3.orig.tar.gz"
  sha1 "926b7907bc8d274e063d42804666b40a3f3c124c"
  bottle do
    sha1 "febde5bb25ed1a6d7cdf2b1a9ed798f29587f7f4" => :yosemite
    sha1 "10d2bc30697656e6deb6fde98a8fafbd1385681c" => :mavericks
    sha1 "ced438f2c14b0c7e26b356e4e13fb5a47c3c60fc" => :mountain_lion
  end

  revision 1

  fails_with :llvm do
    build 2326
    cause "Lua itself compiles with LLVM, but may fail when other software tries to link."
  end

  option :universal
  option "with-completion", "Enables advanced readline support"
  option "without-sigaction", "Revert to ANSI signal instead of improved POSIX sigaction"

  # Be sure to build a dylib, or else runtime modules will pull in another static copy of liblua = crashy
  # See: https://github.com/Homebrew/homebrew/pull/5043
  patch :DATA if OS.mac?

  # completion provided by advanced readline power patch
  # See http://lua-users.org/wiki/LuaPowerPatches
  patch do
    url "http://luajit.org/patches/lua-5.2.0-advanced_readline.patch"
    sha1 "ca405dbd126bc018980a26c2c766dfb0f82e919e"
  end if build.with? "completion"

  # sigaction provided by posix signalling power patch
  patch do
    url "http://lua-users.org/files/wiki_insecure/power_patches/5.2/lua-5.2.3-sig_catch.patch"
    sha1 "b9a0044eb3c422f8405798c900ce31587156c7dd"
  end if build.with? "sigaction"

  def install
    ENV.universal_binary if build.universal?

    # Use our CC/CFLAGS to compile.
    inreplace "src/Makefile" do |s|
      s.remove_make_var! "CC"
      s.change_make_var! "CFLAGS", "#{ENV.cflags} -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS)"
      s.change_make_var! "MYLDFLAGS", ENV.ldflags
    end

    # Fix path in the config header
    inreplace "src/luaconf.h", "/usr/local", HOMEBREW_PREFIX<commit_msg>Lua depends on readline<commit_after>require "formula"

class Lua < Formula
  homepage "http://www.lua.org/"
  url "http://www.lua.org/ftp/lua-5.2.3.tar.gz"
  mirror "https://mirrors.kernel.org/debian/pool/main/l/lua5.2/lua5.2_5.2.3.orig.tar.gz"
  sha1 "926b7907bc8d274e063d42804666b40a3f3c124c"
  bottle do
    sha1 "febde5bb25ed1a6d7cdf2b1a9ed798f29587f7f4" => :yosemite
    sha1 "10d2bc30697656e6deb6fde98a8fafbd1385681c" => :mavericks
    sha1 "ced438f2c14b0c7e26b356e4e13fb5a47c3c60fc" => :mountain_lion
  end

  revision 1

  fails_with :llvm do
    build 2326
    cause "Lua itself compiles with LLVM, but may fail when other software tries to link."
  end

  option :universal
  option "with-completion", "Enables advanced readline support"
  option "without-sigaction", "Revert to ANSI signal instead of improved POSIX sigaction"

  depends_on "readline" unless OS.mac?

  # Be sure to build a dylib, or else runtime modules will pull in another static copy of liblua = crashy
  # See: https://github.com/Homebrew/homebrew/pull/5043
  patch :DATA if OS.mac?

  # completion provided by advanced readline power patch
  # See http://lua-users.org/wiki/LuaPowerPatches
  patch do
    url "http://luajit.org/patches/lua-5.2.0-advanced_readline.patch"
    sha1 "ca405dbd126bc018980a26c2c766dfb0f82e919e"
  end if build.with? "completion"

  # sigaction provided by posix signalling power patch
  patch do
    url "http://lua-users.org/files/wiki_insecure/power_patches/5.2/lua-5.2.3-sig_catch.patch"
    sha1 "b9a0044eb3c422f8405798c900ce31587156c7dd"
  end if build.with? "sigaction"

  def install
    ENV.universal_binary if build.universal?

    # Use our CC/CFLAGS to compile.
    inreplace "src/Makefile" do |s|
      s.remove_make_var! "CC"
      s.change_make_var! "CFLAGS", "#{ENV.cflags} -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS)"
      s.change_make_var! "MYLDFLAGS", ENV.ldflags
    end

    # Fix path in the config header
    inreplace "src/luaconf.h", "/usr/local", HOMEBREW_PREFIX
{'fraction_non_alphanumeric': 0.10329113924050633, 'fraction_numerical': 0.09012658227848101, 'mean_word_length': 3.8538083538083536, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '2041962', 'n_tokens_mistral': 1721, 'n_tokens_neox': 1530, 'n_words': 334}