<commit_before>require 'formula'

class Lua < Formula
  url 'http://www.lua.org/ftp/lua-5.1.4.tar.gz'
  homepage 'http://www.lua.org/'
  md5 'd0870f2de55d59c1c8419f36e8fac150'

  fails_with_llvm "Lua itself compiles with LLVM, but may fail when other software tries to link.",
                  :build => 2326

  # Skip cleaning both empty folders and bin/libs so external symbols still work.
  skip_clean :all

  # Be sure to build a dylib, or else runtime modules will pull in another static copy of liblua = crashy
  # See: https://github.com/mxcl/homebrew/pull/5043
  def patches
    DATA
  end


  def install
    # Apply patch-level 2
    curl "http://www.lua.org/ftp/patch-lua-5.1.4-3", "-O"
    safe_system '/usr/bin/patch', '-d', 'src', '-i', '../patch-lua-5.1.4-3'
    # we could use the patches method if it supported additional arguments (-d in our case)

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

    # Fix path in the config header
    inreplace 'src/luaconf.h', '/usr/local', HOMEBREW_PREFIX<commit_msg>Add option for advanced readline support in Lua<commit_after>require 'formula'

class Lua < Formula
  url 'http://www.lua.org/ftp/lua-5.1.4.tar.gz'
  homepage 'http://www.lua.org/'
  md5 'd0870f2de55d59c1c8419f36e8fac150'

  fails_with_llvm "Lua itself compiles with LLVM, but may fail when other software tries to link.",
                  :build => 2326

  # Skip cleaning both empty folders and bin/libs so external symbols still work.
  skip_clean :all

  # Be sure to build a dylib, or else runtime modules will pull in another static copy of liblua = crashy
  # See: https://github.com/mxcl/homebrew/pull/5043
  def patches
    # completion provided by advanced readline power patch from
    # http://lua-users.org/wiki/LuaPowerPatches
    if ARGV.include? '--completion'
      [DATA, 'http://luajit.org/patches/lua-5.1.4-advanced_readline.patch']
    else
      DATA
    end
  end

  def options
    [['--completion', 'Enables advanced readline support']]
  end

  def install
    # Apply patch-level 2
    curl "http://www.lua.org/ftp/patch-lua-5.1.4-3", "-O"
    safe_system '/usr/bin/patch', '-d', 'src', '-i', '../patch-lua-5.1.4-3'
    # we could use the patches method if it supported additional arguments (-d in our case)

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

    # Fix path in the config header
    inreplace 'src/luaconf.h', '/usr/local', HOMEBREW_PREFIX
{'fraction_non_alphanumeric': 0.12344749717726759, 'fraction_numerical': 0.031990967256304105, 'mean_word_length': 2.914580265095729, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, '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': '773143', 'n_tokens_mistral': 971, 'n_tokens_neox': 908, 'n_words': 274}