This file is indexed.

/usr/lib/ruby/1.8/rd/rd2man-lib.rb is in librd-ruby1.8 0.6.22-1.

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
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
=begin
= rd/rd2man-lib.rb
=end

require "rd/rdvisitor"

unless [].respond_to? :collect!
  class Array
    alias collect! filter
  end
end

module RD
  class RD2MANVisitor < RDVisitor
    include AutoLabel
    include MethodParse

    SYSTEM_NAME = "RDtool -- RD2ManVisitor"
    SYSTEM_VERSION = "$Version: 0.6.21$" #"
    VERSION = Version.new_from_version_string(SYSTEM_NAME, SYSTEM_VERSION)

    def self.version
      VERSION
    end

    # must-have constants
    OUTPUT_SUFFIX = "1"
    INCLUDE_SUFFIX = ["1"]

    def initialize
      @enumcounter = 0
      @index = {}
      @filename = nil
    end

    def visit(tree)
      prepare_labels(tree, "")
      super(tree)
    end

    def apply_to_DocumentElement(element, content)
      content = content.join
      title = @filename || ARGF.filename || "Untitled"
      title = File.basename title
      title = title.sub(/\.rd$/i, '')
      <<"EOT"
.\\" DO NOT MODIFY THIS FILE! it was generated by rd2
.TH #{title} 1 "#{Time.now.strftime '%B %Y'}"
#{content}
EOT
    end # "

    def apply_to_Headline(element, title)
      element.level <= 1 ? ".SH #{title}\n" : ".SS #{title}\n"
    end

    # RDVisitor#apply_to_Include

    def apply_to_TextBlock(element, content)
      if RD::DescListItem === element.parent ||
	 RD::ItemListItem === element.parent ||
	 RD::EnumListItem === element.parent
	return content.join
      else
	return ".PP\n" + content.join
      end
    end

    def apply_to_Verbatim(element)
      content = []
      element.each_line do |i|
	content.push(apply_to_String(i))
      end
      # Can we use BLOCKQUOTE such like?
      %Q[.nf\n\\&    #{content.join("\\&    ")}.fi\n]
    end

    def apply_to_ItemList(element, items)
      items.collect! do |x| x.sub(/\n\n/, "\n") end
      items = items.join(".IP\n.B\n\\(bu\n")  # "\\(bu" -> "" ?
      ".IP\n.B\n\\(bu\n" + items
    end

    def apply_to_EnumList(element, items)
      @enumcounter = 0
      items.join
    end

    def apply_to_DescList(element, items)
      items.map{ |i| i =~ /\n$/ ? i : i + "\n" }.join("")
    end

    def apply_to_MethodList(element, items)
      items.map{ |i| i =~ /\n$/ ? i : i + "\n" }.join("")
    end

    def apply_to_ItemListItem(element, content)
      content.map{ |c| c =~ /\n$/ ? c : c + "\n" }.join("")
    end

    def apply_to_EnumListItem(element, content)
      @enumcounter += 1
      %Q[.TP\n#{@enumcounter}.\n#{content.join("\n")}]
    end

    def apply_to_DescListItem(element, term, description)
      anchor = refer(element)
      if description.empty?
	".TP\n.fi\n.B\n#{term}"
      else
        %[.TP\n.fi\n.B\n#{term}\n#{description.join("\n")}].chomp
      end
    end

    def apply_to_MethodListItem(element, term, description)
      term = parse_method(term)  # maybe: term -> element.term
      anchor = refer(element)
      if description.empty?
	".TP\n.fi\n.B\n#{term}"
      else
        %[.TP\n.fi\n.B\n#{term}\n#{description.join("\n")}]
      end
    end

    def parse_method(method)
      klass, kind, method, args = MethodParse.analize_method(method)
      
      if kind == :function
	klass = kind = nil
      else
	kind = MethodParse.kind2str(kind)
      end
      
      case method
      when "[]"
	args.strip!
	args.sub!(/^\((.*)\)$/, '\\1')
	"#{klass}#{kind}[#{args}]"
      when "[]="
	args.strip!
	args.sub!(/^\((.*)\)$/, '\\1')
	args, val = /^(.*),([^,]*)$/.match(args)[1,2]
	args.strip!
	val.strip!

	"#{klass}#{kind}[#{args}] = #{val}"
      else
	"#{klass}#{kind}#{method}#{args}"
      end
    end
    private :parse_method

    def apply_to_StringElement(element)
      apply_to_String(element.content)
    end

    def apply_to_Emphasis(element, content)
      %Q[\\fI#{content.join}\\fP]
    end

    def apply_to_Code(element, content)
      %{\\&\\fB#{content.join.sub(/\./, '\\.')}\\fP}
    end

    def apply_to_Var(element, content)
      content.join
    end

    def apply_to_Keyboard(element, content)
      content.join
    end

    def apply_to_Index(element, content)
      tmp = []
      element.each do |i|
	tmp.push(i) if i.is_a?(String)
      end
      key = meta_char_escape(tmp.join)
      if @index.has_key?(key)
	# warning?
	""
      else
	num = @index[key] = @index.size
        %{\\&\\fB#{content.join.sub(/\./, '\\.')}\\fP}
      end
    end

    def apply_to_Reference(element, content)
      case element.label
      when Reference::URL
	apply_to_RefToURL(element, content)
      when Reference::RDLabel
	if element.label.filename
	  apply_to_RefToOtherFile(element, content)
	else
	  apply_to_RefToElement(element, content)
	end
      end
    end

    def apply_to_RefToElement(element, content)
      content = content.join
      content.sub(/^function#/, "")
    end

    def apply_to_RefToOtherFile(element, content)
      content.join
    end
  
    def apply_to_RefToURL(element, content)
      content.join
    end

    def apply_to_Footnote(element, content)
      ""
    end

    def apply_to_Verb(element)
      apply_to_String(element.content)
    end

    def apply_to_String(element)
      meta_char_escape(element)
    end

    def meta_char_escape(str)
      str.gsub(/[-\\]/, '\\\\\\&').gsub(/^[.']/, '\\&') # '
    end
    private :meta_char_escape

  end # RD2MANVisitor
end # RD

$Visitor_Class = RD::RD2MANVisitor

=begin
== script info.
 RD to MAN translate library for rdfmt.rb
 $Id: rd2man-lib.rb,v 1.9 2003/08/02 15:45:49 tosh Exp $
 copyright WATANABE Hirofumi <eban@os.rim.or.jp>, 2000
=end