This file is indexed.

/usr/lib/ruby/vendor_ruby/kakasi/fiddle.rb is in ruby-kakasi-ffi 1.0.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module Kakasi
  module Lib
    require 'fiddle/import' unless defined?(Fiddle::Importer)

    extend Fiddle::Importer
    include Fiddle

    case SIZEOF_VOIDP
    when 4
      PackPointers = 'L*'
    when 8
      PackPointers = 'Q*'
    else
      raise 'Unsupported pointer size: %u' % SIZEOF_VOIDP
    end

    require 'kakasi/platform'

    try_load { |lib|
      dlload lib
    }

    extern 'int kakasi_getopt_argv(int, char **)'
    extern 'char *kakasi_do(char *)'
    extern 'int kakasi_close_kanwadict()'
    extern 'int kakasi_free(char *)'

    INTERNAL_ENCODING = Encoding::CP932

    @mutex = Mutex.new
    @options = nil

    def kakasi(options, string)
      @mutex.synchronize {
        if options != @options
          kakasi_close_kanwadict() if @options

          args = ['kakasi', *options.split]

          argc = args.size
          argv = Pointer.malloc(argc * SIZEOF_VOIDP)
          argv[0, argv.size] = args.map { |x|
            Pointer[x].to_i
          }.pack(PackPointers)

          kakasi_getopt_argv(argc, argv).zero? or
            raise "failed to initialize kakasi"

          @options = options.dup
        end

        encoding = string.encoding
        result = ''.force_encoding(INTERNAL_ENCODING)
        string.encode(INTERNAL_ENCODING).split(/(\0+)/).each { |str, nul|
          buf = kakasi_do(str)
          result << buf.to_s.force_encoding(INTERNAL_ENCODING)
          kakasi_free(buf)
          result << nul if nul
        }
        result.encode(encoding)
      }
    end
    module_function :kakasi
  end
end