Spec-Zone.ru › Homebrew

Модуль: OS::Linux::Elf Приватный

Определён в:
os/linux/elf/os.rb

Обзор

Этот модуль является частью приватного API. Этот модуль можно использовать только в репозитории Homebrew/brew. По возможности сторонним разработчикам следует избегать использования этого модуля, поскольку он может быть удалён или изменён без предупреждения.

Вспомогательные функции для работы с объектами ELF.

Краткое описание методов класса свернуть

  • .expand_elf_dst(str, ref, repl) ⇒ String приватный

Подробное описание методов класса

.expand_elf_dst(str, ref, repl) ⇒ String

Этот метод является частью приватного API. Этот метод можно использовать только в репозитории Homebrew/brew. По возможности сторонним разработчикам следует избегать использования этого метода, поскольку он может быть удалён или изменён без предупреждения.

Параметры:

  • str (String)
  • ref (String)
  • repl (String, ::Pathname)

Возвращает:

  • (String)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'os/linux/elf/os.rb', line 11

def self.expand_elf_dst(str, ref, repl)
  # ELF gABI rules for DSTs:
  #   - Longest possible sequence using the rules (greedy).
  #   - Must start with a $ (enforced by caller).
  #   - Must follow $ with one underscore or ASCII [A-Za-z] (caller
  #     follows these rules for REF) or '{' (start curly quoted name).
  #   - Must follow first two characters with zero or more [A-Za-z0-9_]
  #     (enforced by caller) or '}' (end curly quoted name).
  # (from https://github.com/bminor/glibc/blob/41903cb6f460d62ba6dd2f4883116e2a624ee6f8/elf/dl-load.c#L182-L228)

  # In addition to capturing a token, also attempt to capture opening/closing braces and check that they are not
  # mismatched before expanding.
  str.gsub(/\$({?)([a-zA-Z_][a-zA-Z0-9_]*)(}?)/) do |orig_str|
    has_opening_brace = ::Regexp.last_match(1).present?
    matched_text = ::Regexp.last_match(2)
    has_closing_brace = ::Regexp.last_match(3).present?
    if (matched_text == ref) && (has_opening_brace == has_closing_brace)
      repl
    else
      orig_str
    end
  end
end

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/OS/Linux/Elf.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API