This file is indexed.

/usr/lib/grass64/tools/g.html2man is in grass-dev 6.4.3-3.

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

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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#!/bin/sh  -- #perl, to stop looping
eval 'exec $GRASS_PERL -S $0 ${1+"$@"}'
    if 0;

############################################################################
#
# MODULE:       g.html2man
# AUTHOR(S):    Daniel Calvelo Aros
# PURPOSE:      convert HTML formatted page to MAN page format
# COPYRIGHT:    (C) 2004 by the GRASS Development Team
#
#               This program is free software under the GNU General Public
#               License (>=v2). Read the file COPYING that comes with GRASS
#               for details.
#
#############################################################################

# Note: the GRASS_PERL variables must be set!
# Usage:
#       perl g.html2man <html file> <man file> <section>

our $preformat, $in_bu, $in_nb, @nb_n;
our $suppress = 0;

sub CvtTable {
#
# converts <table> structures to tbl commands.
#
# limitations: malformed (sloppy html) tables won't convert
# properly, eg no closing tags are bad. 
# <th> headers are handled; nested <table>s are not
#
# since tables may be line-formatted randomly, this function
# works on a full file; thus, the original line-oriented
# unbuffered design had to be changed.
#
# modify $format if centered headings and left-aligned
# contents don't suit you.
#
# also, groff recognizes the tbl commands and preprocesses
# accordingly; for other roff formatters that is uncertain.
# it might be advisable to put a '.\" t' line at the beginning
# of the output file
#
# TODO: rewrite g.html2man using the HTML::Parser module
#
  my $i = shift;
  return $i unless $i =~ m|<table.*?>(.+?)</table>|is;
  my $header = ".TS\nexpand box;\n";
  $_ = $1;
  ($one_row,) = m|<tr.*?>(.+?)</tr>|is ;
  $ncols = -1 + scalar split /<td/i, $one_row;
  $has_header = m|<th|i ;
  s|[\n\r]||g;
  s|</tr.*?>|\n.br\n|gis;
  s|</td.*?>|\t|gis;
  foreach $tag ( qw(<td.*?> <th.*?> </th> <tr.*?>) ){
    s/$tag//gi;
  }
  $format = $has_header
          ? "cb"x$ncols . "\n"."-"x$ncols . "\n"
	  : "";
  $format .= "l"x$ncols . ".\n";
  $i =~ s|<table.*?>.+?<table>|$header$format$_.TE\n|is;
  return CvtTable($i);
}

sub basename {
  $slash = rindex($_[0], "/");
  $suffix = rindex($_[0], $_[1]);
  if ($suffix == -1) {$suffix=length($_[0])};
  return substr($_[0], $slash+1, $suffix-$slash-1);
}                                                                               

sub GetTitle {
  while (<INP>) {
    if (m#<TITLE>.*MAN page for:#i) {
      s#<TITLE>##i;
      s#MAN page for:##i;
      s#</TITLE>##i;
      @TITLE = split;
      return 1;
    }
    if (m#<TITLE>#i) {
      return 1;
    }
  }
  return 0;
}

sub PrintHeader {
      print OUT ".TH $_[0] $_[1] \"\" \"GRASS " . $ENV{'VERSION_NUMBER'} . "\" \"Grass User's Manual\"\n";
##      print OUT ".so /usr/share/lib/tmac/sml\n";
##      print OUT ".so /usr/share/lib/tmac/rsml\n";
}

sub DoStrip {
  if (m#<.*TITLE>#i) { return 1};
  if (m/<.*HEADER>/i) { return 1};
  if (m/<.*HEAD>/i) { return 1};
  if (m/<.*BODY>/i) { return 1};
  if (m/<.*HEADER>/i) { return 1};
  if (m/<.*BLINK>/i) { return 1};
  if (m/^<A HREF="#toc/i) {return 1};
  if (s#<A HREF=".*">##i) {
      s#</A>##i;
  }
  return 0;
}

sub DoLine {

  if (m#</PRE>#i) {
    s#</PRE>#\n.DE\n\\fR#i;
    $preformat = 0;
    return 1;
  }
###  if ($preformat) {return 1};
  if (m#<PRE>#i) {
    s#^.*<PRE>#\\fC\n.DS#i;
    $preformat = 1;
    return 1;
  }
  s#<IMG SRC=.*>##i;
  if (m#<A NAME="toc">#i) {return 2};
  s#<A NAME=".*">##i;
  #s#<\!\-\-#.\\\" #i;
  #s#\-\->##i;
  if (m#^<HR.*>$#i) {return 0};
  s#<HR>##i;
  s#<HR .*>##i;
  if (&DoStrip($_)) {return 0}
  &DoFont($_);
  if (! &DoList($_)) {return 0};
  if (! &DoSection($_)) {return 0}
  &DoEscape($_);
  &DoPara($_);
  if (! $preformat) {
    if (m/^$/) {return 0};
    s#^[ \t]*##;
    s#<[^>]*>##g;
  }
  return 1;
}

sub DoEscape {
  s#&gt;#>#i;
  s#&lt;#<#i;
  s#&amp;#&#i;
  s#&quot;#"#i;
  s#&nbsp;# #i;
  s#&copy;#©#i;
  s#&auml;#ä#i;
  s#&uuml;#ü#i;
  s#&lt;#<#i;
  s#&gt;#>#i;
}

sub DoSection {
  if (m#^ *Table of Contents *$#i) {return 0};
  if (m#^<A NAME=".*">$#i) {return 0;}
  s#<A NAME=".*">##i;
  s#^.*<H2>#.SH #i;
  s#^.*<H3>#.SS #i;
  s#^.*<H4>#.SS #i;
  if (m#^</[^>]*>$#i) {return 0};
  s#</[^>]*>##ig;
  s#^<BR>$#.br#i;
  s#<BR>#\n.br\n#i;
  return 1;
}


#================
# Paragraph breaks: <P>
#
sub DoPara {
  s/^ *<P>/.PP\n/i;
  s/<P>/\n.PP\n/ig;
  return;
}

#================
# Lists
#    <DL><DT><DD>
#
sub DoList {
  if (m#^ *</DT> *$#i) {return 0};
  if (m#<DT> *$#i) {chop};
  s#^ *<DT>#.IP \"#i;
  s#<DT>#\n.IP \"#i;
  s#</DT>#\" 4m#i;

  if (m#^ *<DD> *$#i) {return 0};
  if (m#^ *</DD> *$#i) {return 0};
  if (m#^</LI>$#i) {return 0};
  s#<DD>#\n.br\n#i;
  s#</DD>##i;

  s#^.*<DL> *$##i;
  s#<DL>#\n.VL 4m\n#i;

  s#^.*</DL> *$#.PP#i;
  s#<DL>#\n.IP\n#i;

  s|<UL>|\n.RS\n|i and $in_bu=1;
  s|</UL>|\n.RE\n|i and $in_bu=0;

  s|<OL>|\n..IP\n|i and ($in_nb++,$nb_n[$in_nb]=1); # @nb_n is a stack allowing for nested <ol>'s
  s|</OL>|\n.PP\n|i and ($nb_n[$in_nb]=0,$in_nb--);

  s|</LI>||i;
  if(/<li>/){
    $in_bu and s|<LI>|\n.IP\n|i;
    $in_nb and (                          # since we're hand-composing the ordered lists (not using mm's .AL),
      $n=(join ".", (                     # we use a uniform indentation and x.y.z numbering 
        (map {$_-1} @nb_n[1..($in_nb-1)]) # nb_n's are one beyond the current number for the levels above current
	,
	$nb_n[$in_nb])),                  # and exact for the current level
      s|<li>|\n.IP \\fB$n\\fR\n|i, 
      $nb_n[$in_nb]++                     # because we post-increment after encountering each <li>
      );
  }

  # move into CvtTable()  ??
  s/<TD.*?>/\t| /gi;
  s/<TR.*?>/\n.br\n/i;

  return 1;
}

#================
# Font transitions: 
#   <B>  => \fB
#   </B> => \fR
#   <I>  => \fI
#   </I> => \fR
#
sub DoFont {
  s# *</B> *_ *<B> *#_#ig;
  s#</B> *<B># #ig;
  s#<B>#\\fB#ig;
  s#</B>#\\fR#ig;
  s#<SUP>#\\u#ig;
  s#</SUP>#\\d#ig;

  s# *</I> *_ *<I> *#_#ig;
  s#</I> *<I># #ig;
  s#<I>#\\fI#ig;
  s#</I>#\\fR#ig;
  s# *</CODE> *_ *<CODE> *#_#ig;
  s#</CODE> *<CODE># #ig;
  s#<CODE>#\\fI#ig;
  s#</CODE>#\\fR#ig;
  s# *</EM> *_ *<EM> *#_#ig;
  s#</EM> *<EM># #ig;
  s#<EM>#\\fI#ig;
  s#</EM>#\\fR#ig;
  s/&NBSP;/ /ig;
  return;
}

#==================
# Process HTML file

$infile = $ARGV[0];
$outfile = $ARGV[1];
$preformat = 0;
$page = &basename($ARGV[0], ".html");
$sect = $ARGV[2];
open(INP,$infile) || die "Can't open '$infile' for reading: $!";
if (! &GetTitle($page,$sect)) {  
  print "$infile: Did not find a valid <TITLE> line\n";
  close(INP);
  exit;
}
open(OUT,"> $outfile") || die "Can't open '$outfile' for writing: $!";
print "Converting: $infile to $outfile\n";
&PrintHeader($page,$sect,$TITLE[0]);

while (<INP>) {
  # for intro pages which lack a module NAME (for whois entry)
  if ($_ =~ s/<!-- meta page description:(.*)-->/$1/) {
	print OUT ".SH NAME\n$page \\-$_\n";
  }

  s/\\/\\(rs/g;
  $result = &DoLine($_);
  if ($result == 2) {
    close(INP);
    close(OUT);
    return;
  }

  if (&DoLine($_) == 1) {
    s#&lt#<#g;
    s#&gt#>#g; 
    s#^'#\\(cq#gm;
    s#^"#\\(dq#gm;
    s#`#\\(ga#g;

    #
    # this part removes the comments
    # 
    $line = $_;
    $line =~ s/<!--.*-->//g; # 
    if ($line =~ s/(.*)<!--.*/$1/) {
        $suppress = 1;
        $out .= $line;
    }
    if ($line =~ s/.*\-\-\>(.*)/$1/g) {
        print $line
        $suppress = 0;
    }
    if ($suppress != 0) {
        $line = "";
    }
    #
    # end of comment part
    #
    
    $out .= $line;

    if ($preformat == 1) {
      $out .= ".br\n";
    }
  }
}
$out =~ s/\n+/\n/gm;
print OUT CvtTable($out);
close(INP);
close(OUT);

exit;