<commit_before>class Keg
  def fix_install_names options={}
    mach_o_files.each do |file|
      install_names_for(file, options) do |id, bad_names|
        file.ensure_writable do
          change_dylib_id(id, file) if file.dylib?

          bad_names.each do |bad_name|
            new_name = fixed_name(file, bad_name)
            unless new_name == bad_name
              change_install_name(bad_name, new_name, file)
            end
          end
        end
      end
    end
  end

  def relocate_install_names old_prefix, new_prefix, old_cellar, new_cellar, options={}
    mach_o_files.each do |file|
      install_names_for(file, options, relocate_reject_proc(old_prefix)) do |id, old_prefix_names|
        file.ensure_writable do
          new_prefix_id = id.to_s.gsub old_prefix, new_prefix
          change_dylib_id(new_prefix_id, file) if file.dylib?

          old_prefix_names.each do |old_prefix_name|
            new_prefix_name = old_prefix_name.to_s.gsub old_prefix, new_prefix
            change_install_name(old_prefix_name, new_prefix_name, file)
          end
        end
      end

      install_names_for(file, options, relocate_reject_proc(old_cellar)) do |id, old_cellar_names|
        file.ensure_writable do
          old_cellar_names.each do |old_cellar_name|
            new_cellar_name = old_cellar_name.to_s.gsub old_cellar, new_cellar
            change_install_name(old_cellar_name, new_cellar_name, file)
          end
        end
      end
    end

    # Search for pkgconfig .pc files and relocate references to the cellar
    old_cellar = "#{old_prefix}/Cellar" if old_cellar == :any

    pkgconfig_files.each do |pcfile|<commit_msg>relocate_install_names: rewrite cellar names before prefix names<commit_after>class Keg
  def fix_install_names options={}
    mach_o_files.each do |file|
      install_names_for(file, options) do |id, bad_names|
        file.ensure_writable do
          change_dylib_id(id, file) if file.dylib?

          bad_names.each do |bad_name|
            new_name = fixed_name(file, bad_name)
            unless new_name == bad_name
              change_install_name(bad_name, new_name, file)
            end
          end
        end
      end
    end
  end

  def relocate_install_names old_prefix, new_prefix, old_cellar, new_cellar, options={}
    mach_o_files.each do |file|
      install_names_for(file, options, relocate_reject_proc(old_cellar)) do |id, old_cellar_names|
        file.ensure_writable do
          old_cellar_names.each do |old_cellar_name|
            new_cellar_name = old_cellar_name.to_s.gsub old_cellar, new_cellar
            change_install_name(old_cellar_name, new_cellar_name, file)
          end
        end
      end

      install_names_for(file, options, relocate_reject_proc(old_prefix)) do |id, old_prefix_names|
        file.ensure_writable do
          new_prefix_id = id.to_s.gsub old_prefix, new_prefix
          change_dylib_id(new_prefix_id, file) if file.dylib?

          old_prefix_names.each do |old_prefix_name|
            new_prefix_name = old_prefix_name.to_s.gsub old_prefix, new_prefix
            change_install_name(old_prefix_name, new_prefix_name, file)
          end
        end
      end
    end

    # Search for pkgconfig .pc files and relocate references to the cellar
    old_cellar = "#{old_prefix}/Cellar" if old_cellar == :any

    pkgconfig_files.each do |pcfile|
{'fraction_non_alphanumeric': 0.06505740359140418, 'fraction_numerical': 0.0, 'mean_word_length': 2.7055616139585603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6527876', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1119, 'n_words': 239}