source: rtems/doc/tools/src2html1.4a/src2html @ bf09257a

4.104.114.84.95
Last change on this file since bf09257a was 52461c5, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/98 at 16:03:45

New files

  • Property mode set to 100644
File size: 19.6 KB
Line 
1#!/usr/local/bin/perl
2# Src2html: Take a source tree and generate Html documents that have hyperlinks
3# to the definition of structures, variables, functions, and preprocessor
4# definitions. Read the manual page for details on how to use the program.
5#
6# Version 1.4-alpha. Written by Warren Toomey wkt@cs.adfa.oz.au
7#
8# 19th January 1996
9#
10
11if ($#ARGV <= 0 || $#ARGV > 4) {                # Check arg count
12    print(STDERR "Usage: $0 [-na] [-nl] [-d num] input_description\n");
13    print(STDERR "           -na: Don't produce top-level category files\n");
14    print(STDERR "           -nl: Don't produce per-letter files\n");
15    print(STDERR "            -d: Set debugging to given number (0-3)\n");
16    exit(1);
17}
18
19# Set up default option values
20$NoLetters= 0;
21$NoAll= 0;
22$Debug=0;
23$Top= $ARGV[$#ARGV];
24$Top=~ s/\.s2h$//;
25
26# Parse the options
27for ($i=0; $i<= $#ARGV; $i++) {
28        if ($ARGV[$i] eq "-na") { $NoAll= 1; next; }
29        if ($ARGV[$i] eq "-nl") { $NoLetters= 1; next; }
30        if ($ARGV[$i] eq "-d") { $i++; $Debug= $ARGV[$i]; next; }
31}
32
33$Title{"m"}= "Macros";
34$Title{"d"}= "Defines";
35$Title{"f"}= "Functions";
36$Title{"v"}= "Variables";
37$Title{"s"}= "Structs";
38$Title{"u"}= "Unions";
39$Title{"t"}= "Typedefs";
40$Title{"e"}= "Enums";
41$Title{"g"}= "All symbols";
42
43&get_s2h;                               # Read the description file
44&make_dirs;                             # Make directories as needed
45&make_ctags;                            # Generate ctags for all src
46&parse_ctags;                           # Parse ctags, generate html ptr files
47foreach $i (keys(%Dirinfo))
48{ &rewrite_src($i); }                   # Rewrite the src code
49exit(0);                                # and exit
50 
51
52## get_s2h: Opens the source description file, reads it, and sets up some
53## variables describing where some directories are, and the source directories
54## to process. Variables used are:
55## Srctree - The root of the source tree we are processing
56## Htmlroot - The directory where all WWW documents are kept
57## Htmldir -  The directory under Htmlroot for this source tree
58## Htmltree - The root of the destination tree for the Html code
59## Newsrctree - The directory in Htmltree to store the new Htmlised code
60## Headers - The directory where we keep information to prepend in some docs
61## Formdir - The place to put the index searching script
62## Dirinfo{} - The list of dirs and the info about the directory
63## Dotdir{} - The directory name with /'s -> .'s
64
65sub get_s2h {
66    $Newsrctree= 'newsrc';                      # Set up as default
67    $Headers= '.';
68
69
70    #########################################################
71    # make sure we dump out the last bit of the last file....
72
73                        # Print out the remainder of the
74                        # current file, incl. the buffered line
75    if ($In_file == 1) {
76      if ("$line" ne "") { print OUT $line; }
77      while (<IN>) {
78              s/\&/&amp;/g; s/\</&lt;/g; s/\>/&gt;/g; print OUT;
79        }
80      print OUT "\n\n\n\n\n\n\n\n</pre></body>\n";
81      close(IN); close(OUT);
82    }
83    #########################################################
84
85    open(S2H,$ARGV[$#ARGV])                             # Open descript
86        || die "$0: can't open $ARGV[$#ARGV]: $!\n";
87
88    while(<S2H>) {                              # Read in input lines
89        next if /^#/;                           # Skip comments
90        if ( /^set\s+Srctree\s+(\S+)/ ) {
91            $Srctree = $1; next;                # Set the variable
92        }
93        if ( /^set\s+Htmlroot\s+(\S+)/ ) {
94            $Htmlroot = $1; next;               # Set the variable
95        }
96        if ( /^set\s+Htmldir\s+(\S+)/ ) {
97            $Htmldir = $1; next;                # Set the variable
98        }
99        if ( /^set\s+Newsrctree\s+(\S+)/ ) {
100            $Newsrctree = $1; next;             # Set the variable
101        }
102        if ( /^set\s+Headers\s+(\S+)/ ) {
103            $Headers = $1; next;                # Set the variable
104        }
105        if ( /^set\s+Formdir\s+(\S+)/ ) {
106            $Formdir = $1; next;                # Set the variable
107        }
108        if ( /^dir\s+(\S+)\s+(.*)/ ) {
109            $Dirinfo{$1}= $2; $Dotdir{$1}=$1;
110            $Dotdir{$1}=~ s/\//./g;
111            next;                               # Get dir commands
112        }
113        if ( /^\n/ ) { next; }                  # Ignore blank lines
114                                                # Bad input line, give warning
115        chop; print "$_: Bad line, ignoring\n"; next;
116    }
117    close(S2H);
118    if (!defined($Srctree)) { die "$0: Srctree undefined in $ARGV[$#ARGV]\n"; }
119    if (!defined($Htmlroot)) { die "$0: Htmlroot undefined in $ARGV[$#ARGV]\n"; }
120    if (!defined($Htmldir)) { die "$0: Htmldir undefined in $ARGV[$#ARGV]\n"; }
121    $Htmltree= "$Htmlroot/$Htmldir";
122}
123
124## make_dirs: Make the directories need to store the Html documents, and also
125## check to make sure that the input directories exist. We depend upon mkdir(1)
126## having the -p option to make intermediate directories as needed.
127
128sub make_dirs {
129    local($i);
130
131    foreach $i (keys(%Dirinfo)) {            # Check that the directories exist
132        if (! -e "$Srctree/$i") {
133            die "$0: Input dir $Srctree/$i doesn't exist\n";
134        }
135        if (! -d "$Srctree/$i") {
136            die "$0: Input dir $Srctree/$i is not a directory\n";
137        }
138    }
139    if (! -e "$Htmltree") {
140        system("mkdir -p $Htmltree") && die "$0: Can't mkdir $Htmltree\n";
141    }
142    if (! -e "$Htmltree/$Newsrctree") {
143        system("mkdir -p $Htmltree/$Newsrctree")
144                && die "$0: Can't mkdir $Htmltree/$Newsrctree\n";
145    }
146    if (! -e "$Htmltree/ctags") {
147        system("mkdir -p $Htmltree/ctags") && die "$0: Can't mkdir ctags\n";
148    }
149    foreach $i (keys(%Dirinfo)) {
150        if (! -e "$Htmltree/$Newsrctree/$i") {
151            system("mkdir -p $Htmltree/$Newsrctree/$i")
152                && die "$0: Can't mkdir $Htmltree/$Newsrctree/$i\n";
153        }
154    }
155}
156
157## make_ctags: Process all the source code, creating the ctags files.
158## The Ctagsfile{} array is set up to hold the name of the ctags files
159## created.
160
161sub make_ctags {
162    local($i);
163
164    foreach $i (keys(%Dirinfo)) {
165        $Ctagsfile{$i}= "$Htmltree/ctags/$Dotdir{$i}.ctags";
166        if ($Debug > 0 ) { print "Generating ctags for $Ctagsfile{$i}\n"; }
167        system("(cd $Srctree; ctags-new -d -t -w -y $i/*) > $Ctagsfile{$i}")
168        && print "$0: ctags failed on $Srctree/$i\n";
169    }
170}
171
172
173## parse_ctags: Parse the ctags file produced by make_ctags, creating several
174## arrays of information. The arrays created are:
175## Macro{} - The name of every macro and its name lowercased
176## Def{} - The name of every define and its name lowercased
177## Func{} - The name of every function and its name lowercased
178## Var{} - The name of every variable and its name lowercased
179## Struct{} - The name of every struct and its name lowercased
180## Union{} - The name of every union and its name lowercased
181## Type{} - The name of every typedef and its name lowercased
182## Enum{} - The name of every enum and its name lowercased
183## Nfile{} - The directory in which the symbol was found
184## Nline{} - The line number where the symbol was found
185
186sub parse_ctags {
187    local($i);
188    local($low);
189
190    foreach $i (keys(%Dirinfo)) {
191        open(CTAGS,$Ctagsfile{$i}) || die "$0: Can't open $Ctagsfile{$i}, $!\n";
192        if ($Debug > 0) { print "Parsing $Ctagsfile{$i} to build ptr files\n"; }
193        while (<CTAGS>) {
194            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+Preprocessor macro/ ) {
195                ($low=$1)=~tr/A-Z_/a-z/d; $Macro{$low}=$1;
196                $Nfile{$1}= $3; $Nline{$1}= $2; next;
197            }
198            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+Preprocessor define/ ) {
199                ($low=$1)=~tr/A-Z_/a-z/d; $Def{$low}=$1;
200                $Nfile{$1}= $3; $Nline{$1}= $2; next;
201            }
202            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C struct/ ) {
203                ($low=$1)=~tr/A-Z_/a-z/d; $Struct{$low}=$1;
204                $Nfile{$1}= $3; $Nline{$1}= $2; next;
205            }
206            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C union/ ) {
207                ($low=$1)=~tr/A-Z_/a-z/d; $Union{$low}=$1;
208                $Nfile{$1}= $3; $Nline{$1}= $2; next;
209            }
210            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C typedef/ ) {
211                ($low=$1)=~tr/A-Z_/a-z/d; $Type{$low}=$1;
212                $Nfile{$1}= $3; $Nline{$1}= $2; next;
213            }
214            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C enum/ ) {
215                ($low=$1)=~tr/A-Z_/a-z/d; $Enum{$low}=$1;
216                $Nfile{$1}= $3; $Nline{$1}= $2; next;
217            }
218            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C function/ ) {
219                ($low=$1)=~tr/A-Z_/a-z/d; $Func{$low}=$1;
220                $Nfile{$1}= $3; $Nline{$1}= $2; next;
221            }
222            if ( /^(\w+)\s+(\d+)\s+(\S+)\s+C variable/ ) {
223                ($low=$1)=~tr/A-Z_/a-z/d; $Var{$low}=$1;
224                $Nfile{$1}= $3; $Nline{$1}= $2; next;
225            }
226            print "$0: In Ctagsfile{$i}, don't recognise $_";
227        }
228        close(CTAGS);
229        &make_dir_html($i);
230        undef %Macro; undef %Def; undef %Func; undef %Var;
231        undef %Struct; undef %Union; undef %Type; undef %Enum;
232    }
233  &make_top_html;
234}
235
236## make_letters_html: Make the lowest HTML documents, i.e those per-directory
237## per-type per-letter Htmls that point directly at the source code.
238## Arguments are:  Dir name, prefix, title, Name/dir list
239## If the file is created, set $Exists(letter) positive, else to 0.
240
241sub make_letters_html {
242    local($dir)= $_[0];
243    local($pref)= $_[1];
244    local($title)= $_[2];
245    local(*type)= $_[3];
246    local($htmlfile);
247    local($let)="@";
248 
249    foreach $i ( "a".."z" ) { $Exists{$i}=0; }
250    foreach $name (sort keys( %type )) {
251        if (substr($name,0,1) ne $let) {
252            if ($let ne "@") {
253                print HTML "</ul></body>\n";
254                close(HTML);
255                $Exists{$let}= 1;
256            }
257            $let= substr($name, 0, 1);
258            $htmlfile= "$Htmltree/$Dotdir{$dir}.$pref$let.html";
259            open(HTML, "> $htmlfile") || die "$0: Can't open $htmlfile, $!\n";
260 
261            print HTML "<head>\n<title>$title starting with ";
262            print HTML "`$let' in $dir</title>\n";
263            print HTML "</head><body><h1>$title starting with ";
264            print HTML "`$let' in $dir</h1><p>\n";
265            print HTML "<ul>\n";
266        }
267        print HTML "<li><a href=\"$Newsrctree/$Nfile{$type{$name}}";
268        print HTML ".html#$type{$name}\">$type{$name}</a> ";
269        print HTML "$Nfile{$type{$name}}:$Nline{$type{$name}}\n"; next;
270    }
271    print HTML "</ul></body>\n";
272    close(HTML);
273    $Exists{$let}= 1;
274}
275
276## make_type_html: Make the type htmls. If there are <50 symbols for the
277## directory, create the per-directory per-type html document only. Otherwise
278## for every letter grep symbols, call make_lowest_letter_html, and
279## finally create the per-directory per-type html document that points only
280## at the letter files created.
281## Arguments are:  Dir name, prefix, title, Name/dir list
282
283sub make_type_html {
284    local($dir)= $_[0];
285    local($pref)= $_[1];
286    local($title)= $_[2];
287    local(*type)= $_[3];
288    local($i);
289    local($htmlfile);
290    local(@keys)= keys(%type);
291    local($name);
292
293    $Exists{$title}=0;
294    if ( $#keys < 0 ) { return; }
295    if ($Debug > 0) {
296        $i= $#keys + 1;
297        print "The associative array for $dir $title has $i elements\n";
298    }
299    if ( ($#keys < 50) || ($NoLetters == 1) ) {
300        $htmlfile= "$Htmltree/$Dotdir{$dir}.$pref.html";
301        open(HTML, "> $htmlfile") || die "$0: Can't open $htmlfile, $!\n";
302        print HTML "<head>\n<title>$title in $dir</title>\n";
303        print HTML "</head><body><h1>$title in $dir</h1>\n";
304        print HTML "<ul>\n";
305        foreach $name (sort keys( %type )) {
306            print HTML "<li><a href=\"$Newsrctree/$Nfile{$type{$name}}";
307            print HTML ".html#$type{$name}\">$type{$name}</a> ";
308            print HTML "$Nfile{$type{$name}}:$Nline{$type{$name}}\n"; next;
309        }
310        print HTML "</ul></body>\n";
311        close(HTML);
312        $Exists{$title}=1;
313    }
314    else {
315        &make_letters_html($dir, $pref, $title, *type);
316
317        open(HTML, "> $Htmltree/$Dotdir{$dir}.$pref.html")
318                || die "$0: Can't open $htmlfile.$pref.html, $!\n";
319        print HTML "<head>\n<title>$title in $dir</title>\n";
320        print HTML "</head><body><h1>$title in $dir</h1><p>\n";
321        print HTML "<ul>\n";
322   
323        foreach $i ( "a".."z" ) {
324            if ($Exists{$i} > 0) {                      # A file exists
325                print HTML "<li><a href=\"$Dotdir{$dir}.$pref$i.html\">";
326                print HTML "$i</a>\n"; $Exists{$title}++; $Exists{$i}=0;
327            }
328        }
329        print HTML "</ul></body>\n";
330        close(HTML);
331        if ($Exists{$title} == 0) { unlink($htmlfile); }
332    }
333}
334
335## asappend: Append the contents of the second associative array to the
336## first.
337
338sub asappend {
339    local(*To)= $_[0];
340    local(*From)= $_[1];
341    local($i);
342
343    foreach $i (keys(%From)) { $To{$i}= $From{$i} ; }
344}
345
346## make_dir_html: Make the html document for the directory. Use the
347## Exist{} array to determine what types to include on the document.
348## Arguments are:  Dir name
349
350sub make_dir_html {
351    local($dir)= $_[0];
352    local($i);
353    local(@keys);
354
355    if ($Debug > 1) { print"In makedir, dir is $dir\n"; }
356    &make_type_html($dir, "f", $Title{"f"}, *Func);
357    &make_type_html($dir, "m", $Title{"m"}, *Macro);
358    &make_type_html($dir, "d", $Title{"d"}, *Def);
359    &make_type_html($dir, "v", $Title{"v"}, *Var);
360    &make_type_html($dir, "s", $Title{"s"}, *Struct);
361    &make_type_html($dir, "u", $Title{"u"}, *Union);
362    &make_type_html($dir, "t", $Title{"t"}, *Type);
363    &make_type_html($dir, "e", $Title{"e"}, *Enum);
364
365    if ($NoAll != 1) {
366        &asappend(*GFunc, *Func);
367        &asappend(*GMacro, *Macro);
368        &asappend(*GDef, *Def);
369        &asappend(*GVar, *Var);
370        &asappend(*GStruct, *Struct);
371        &asappend(*GUnion, *Union);
372        &asappend(*GType, *Type);
373        &asappend(*GEnum, *Enum);
374    }
375
376    &asappend(*Alldir, *Func);
377    &asappend(*Alldir, *Macro);
378    &asappend(*Alldir, *Def);
379    &asappend(*Alldir, *Var);
380    &asappend(*Alldir, *Struct);
381    &asappend(*Alldir, *Union);
382    &asappend(*Alldir, *Type);
383    &asappend(*Alldir, *Enum);
384    if ($NoLetters != 1) {
385        &make_letters_html($dir, "g", $Title{"g"}, *Alldir);
386    }
387    undef %Alldir;
388
389    open(HTML, "> $Htmltree/$Dotdir{$dir}.html")
390        || die "$0: Can't open $Htmltree/$Dotdir{$dir}.html, $!\n";
391    print HTML "<head>\n<title>Cross-references for $dir</title>\n";
392    print HTML "</head><body><h1>Cross-references for $dir</h1><p>\n";
393    if (-f "$Headers/$Dotdir{$dir}.hdr" ) {
394        open(TOPHDR, "$Headers/$Dotdir{$dir}.hdr");
395        while (<TOPHDR>) { print HTML; }
396        close(TOPHDR);
397    }
398
399    if (defined($Formdir)) {
400        print HTML "<hr><form action=\"$Formdir/src2html.cgi\" ";
401        print HTML "method=\"POST\">\n";
402        print HTML "<input type=\"submit\" value=\"Search\">\n";
403        print HTML "<input type= \"text\" ";
404        print HTML "name=\"$Htmldir/$Newsrctree\">\n";
405        print HTML "Enter a symbol's name here to quickly find it.\n";
406        print HTML "</form><hr>\n";
407    }
408    print HTML "<h1>Cross-references for $dir by type</h1><p><ul>\n";
409   
410    foreach $i ( "f","m","d","v","s","u","t","e" ) {
411        if ($Exists{$Title{$i}} > 0) {          # A type exists
412            print HTML "<li><a href=\"$Dotdir{$dir}.$i.html\">";
413            print HTML "$Title{$i}</a>\n";
414            $Exists{$dir}++; $Exists{$Title{$i}}=0;
415        }
416    }
417    print HTML "</ul><p>\n";
418    if ($NoLetters != 1) {
419        print HTML "<h1>Cross-references for $dir by letter</h1><p><ul>\n";
420        foreach $i ( "a".."z" ) {
421            if ($Exists{$i} > 0) {                      # A letter exists
422                print HTML "<li><a href=\"$Dotdir{$dir}.g$i.html\">";
423                print HTML "$i</a>\n"; $Exists{$i}=0;
424            }
425        }
426    }
427    print HTML "</ul></body>\n";
428    close(HTML);
429}
430
431## Make_top_html: Make the top html document by making the ones below
432## it and then adding links to them.
433
434sub make_top_html {
435    local($i);
436    local(@keys);
437
438    $Dotdir{$Top}=$Top;
439    &make_type_html($Top, "f", $Title{"f"}, *GFunc);
440    &make_type_html($Top, "m", $Title{"m"}, *GMacro);
441    &make_type_html($Top, "d", $Title{"d"}, *GDef);
442    &make_type_html($Top, "v", $Title{"v"}, *GVar);
443    &make_type_html($Top, "s", $Title{"s"}, *GStruct);
444    &make_type_html($Top, "u", $Title{"u"}, *GUnion);
445    &make_type_html($Top, "t", $Title{"t"}, *GType);
446    &make_type_html($Top, "e", $Title{"e"}, *GEnum);
447
448    open(HTMLTOP, "> $Htmltree/$Top.html")
449        || die "$0: Can't open $Htmltree/$Top.html, $!\n";
450    print HTMLTOP "<head>\n<title>Cross-references for $Top</title>\n";
451    print HTMLTOP "</head><body><h1>Cross-references for $Top</h1><p>\n";
452
453    if (-f "$Headers/$Top.hdr" ) {
454        open(TOPHDR, "$Headers/$Top.hdr");
455        while (<TOPHDR>) { print HTMLTOP; }
456        close(TOPHDR);
457    }
458
459    if (defined($Formdir)) {
460        print HTMLTOP "<hr><form action=\"$Formdir/src2html.cgi\" ";
461        print HTMLTOP "method=\"POST\">\n";
462        print HTMLTOP "<input type=\"submit\" value=\"Search\">\n";
463        print HTMLTOP "<input type= \"text\" ";
464        print HTMLTOP "name=\"$Htmldir/$Newsrctree\">\n";
465        print HTMLTOP "Enter a symbol's name here to quickly find it.\n";
466        print HTMLTOP "</form><hr>\n";
467    }
468    print HTMLTOP "<h2>Cross-references by directory</h2><p>\n";
469    print HTMLTOP "<ul>\n";
470   
471    foreach $i (sort keys(%Dirinfo)) {
472        if ($Exists{$i} > 0) {                  # A dir exists
473            print HTMLTOP "<li><a href=\"$Dotdir{$i}.html\">";
474            print HTMLTOP "$i</a> $Dirinfo{$i}\n"; $Exists{$i}=0;
475        }
476    }
477    if ($NoAll != 1) {
478        print HTMLTOP "</ul><p><h2>Cross-references by type</h2><p><ul>\n";
479        foreach $i ( "f","m","d","v","s","u","t","e" ) {
480            if ($Exists{$Title{$i}} > 0) {              # A type exists
481                print HTMLTOP "<li><a href=\"$Top.$i.html\">";
482                print HTMLTOP "$Title{$i}</a>\n";
483            }
484        }
485        if ($NoLetters != 1) {
486            print HTMLTOP "</ul><p><h2>All Cross-references for $Top";
487            print HTMLTOP "</h2><p><ul>\n";
488            &asappend(*Alltop, *GFunc);
489            &asappend(*Alltop, *GMacro);
490            &asappend(*Alltop, *GDef);
491            &asappend(*Alltop, *GVar);
492            &asappend(*Alltop, *GStruct);
493            &asappend(*Alltop, *GUnion);
494            &asappend(*Alltop, *GType);
495            &asappend(*Alltop, *GEnum);
496   
497            if ($Debug > 0) { print "Making top letters\n"; }
498            &make_letters_html($Top, "g", $Title{"g"}, *Alltop);
499            if ($Debug > 0) { print "Making top letters, part 2\n"; }
500            foreach $i ( "a".."z" ) {
501                    if ($Exists{$i} > 0) {
502                    print HTMLTOP "<li><a href=\"$Dotdir{$Top}.g$i.html\">";
503                    print HTMLTOP "$i</a>\n";
504                    }
505            }
506        }
507    }
508    print HTMLTOP "</ul>\n";
509    print HTMLTOP "<hr>This source tree was made with ";
510    print HTMLTOP "<a href=\"http://minnie.cs.adfa.oz.au/Src2html/index.html";
511    print HTMLTOP "\">src2html</a>.</body>\n";
512    close(HTMLTOP);
513}
514
515
516## rewrite_src: Reread the ctags file for the given directory, and
517## rewrite the source code, adding in anchor points and bolding symbols.
518## This is messy as we can have multiple symbols on a single source line,
519## therefore we must buffer each line while reading from the ctags file.
520##
521sub rewrite_src {
522    local($dir)= $_[0];
523    local($i);
524    local($file)="";
525    local($line)="";
526    local($symb);
527    local($cnt);
528    local($nextcnt);
529
530    $In_file=0;
531    open(CTAGS,"sort +2 -3 +1n -2 $Ctagsfile{$dir} |")
532        || die "$0: Can't open sorted $Ctagsfile{$dir}, $!\n";
533    if ($Debug > 0) { print "Rewriting source in $dir\n"; }
534    while (<CTAGS>) {
535                                        # Get the next file, line, symbol
536        if (/^(\w+)\s+(\d+)\s+([A-Za-z0-9_\+\-\.\/]+)/) {
537            if ($Debug > 2) { print "Symb $1 at $2 in $3\n"; }
538            $nextcnt= $2; $symb=$1;
539                                        # If it's in a new file
540            if ("$file" ne "$3") {
541                                        # Print out the remainder of the
542                                        # current file, incl. the buffered line
543                if ($In_file == 1) {
544                    if ("$line" ne "") { print OUT $line; }
545                    while (<IN>) {
546                        s/\&/&amp;/g; s/\</&lt;/g; s/\>/&gt;/g; print OUT;
547                    }
548                    print OUT "\n\n\n\n\n\n\n\n\n\n</pre></body>\n";
549                    close(IN); close(OUT);
550                }
551                $file= "$3";
552                                        # Open the new file & do the preamble
553                open(IN, "$Srctree/$file") ||
554                    print "Cannot open $Srctree/$file\n";
555                open(OUT, "> $Htmltree/$Newsrctree/$file.html");
556                $In_file=1;
557                print OUT "<head>\n<title>$file Source</title>\n";
558                print OUT "</head><body>\n";
559                print OUT "<h1>Source to $file</h1>\n";
560                if (defined($Formdir)) {
561                    print OUT "<hr><form action=\"$Formdir/src2html.cgi\" ";
562                    print OUT "method=\"POST\">\n";
563                    print OUT "<input type=\"submit\" value=\"Search\">\n";
564                    print OUT "<input type= \"text\" ";
565                    print OUT "name=\"$Htmldir/$Newsrctree\">\n";
566                    print OUT "Enter a symbol's name here to quickly find it.\n";
567                    print OUT "</form><hr>\n";
568                }
569                print OUT "<pre>\n";
570                                        # Get the first line
571                $cnt=1; $line = <IN>;
572                $line=~ s/\&/&amp;/g;
573                $line=~ s/\</&lt;/g;
574                $line=~ s/\>/&gt;/g;
575            }
576        }
577                                        # Print all lines until one with a symb
578        while ($cnt < $nextcnt) {
579            print OUT $line; $cnt++; $line= <IN>;
580            $line=~ s/\&/&amp;/g;
581            $line=~ s/\</&lt;/g;
582            $line=~ s/\>/&gt;/g;
583        }
584                                                # Now rewrite the line
585        $line=~ s/$symb/<a name="$symb"<\/a><b>$symb<\/b>/;
586        next;
587    }
588    close(CTAGS); close(IN); close(OUT);
589}
Note: See TracBrowser for help on using the repository browser.