Add lib/w32sock.h as dependency of close module.
[gnulib.git] / build-aux / pmccabe2html
1 #!/usr/bin/awk -f
2 # pmccabe2html - pmccabe to html converter
3
4 # Copyright (C) 2007, 2008 Free Software Foundation, Inc.
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 # Written by Jose E. Marchesi <jemarch@gnu.org>.
20 # Adapted for gnulib by Simon Josefsson <simon@josefsson.org>.
21
22 # Typical Invocation is from a Makefile.am:
23 #
24 # cyclo-libidn.html:
25 #       $(PMCCABE) ${top_srcdir}/lib/*.[ch] \
26 #               | sort -nr \
27 #               | $(AWK) -f ${top_srcdir}/build-aux/pmccabe2html \
28 #                       -v lang=html -v name="$(PACKAGE_NAME)" \
29 #                       -v vcurl="http://git.savannah.gnu.org/gitweb/?p=libidn.git;a=blob;f=%FILENAME%;hb=HEAD" \
30 #                       -v url="http://www.gnu.org/software/libidn/" \
31 #                       -v css=../../build-aux/pmccabe.css \
32 #                       > tmp
33 #       mv tmp $@
34 #
35 # The variables available are:
36 #   lang     output language, either 'html' or 'wiki'
37 #   name     project name
38 #   url      link to project's home page
39 #   vcurl    URL to version controlled source code browser,
40 #            a %FILENAME% in the string is replaced with the relative
41 #            source filename
42 #   css      CSS stylesheet filename, included verbatim in HTML output
43 #   css_url  link to CSS stylesheet, an URL
44
45 # Prologue & configuration
46 BEGIN {
47     section_global_stats_p = 1
48     section_function_cyclo_p = 1
49
50     # "html" or "wiki"
51     package_name = name
52     output_lang = lang
53
54     # General Options
55     cyclo_simple_max = 10
56     cyclo_moderate_max = 20
57     cyclo_high_max = 50
58     cut_dir = "/../"
59     source_file_link_tmpl = vcurl
60
61     # HTML options
62     if (url != "")
63     {
64         html_prolog = "<a href=\"" url "\">Back to " package_name " Homepage</a><br/><br/>"
65     }
66     html_epilog = "<hr color=\"black\" size=\"2\"/> \
67 Copyright (c) 2007, 2008 Free Software Foundation Inc."
68     html_doctype = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \
69 \"http://www.w3.org/TR/html401/loose.dtd\">"
70     html_comment = "<!-- Generated by gnulib's pmccabe2html at " systime() " -->"
71     html_title = "Cyclomatic Complexity report for " package_name
72
73     # Wiki options
74     wiki_prolog = "{{Note|This page has been automatically generated}}"
75     wiki_epilog = ""
76
77     # Internal variables
78     nfuncs = 0;
79 }
80
81 # Functions
82
83 function build_stats()
84 {
85     # Maximum modified cyclo
86     for (fcn in mcyclo)
87     {
88         num_of_functions++
89         if (mcyclo[fcn] > max_mcyclo)
90         {
91             max_mcyclo = mcyclo[fcn]
92         }
93
94         if (mcyclo[fcn] > cyclo_high_max)
95         {
96             num_of_untestable_functions++
97         }
98         else if (mcyclo[fcn] > cyclo_moderate_max)
99         {
100             num_of_high_functions++
101         }
102         else if (mcyclo[fcn] > cyclo_simple_max)
103         {
104             num_of_moderate_functions++
105         }
106         else
107         {
108             num_of_simple_functions++
109         }
110     }
111 }
112
113 function html_fnc_table_complete (caption)
114 {
115     html_fnc_table(caption, 1, 0, 1, 1, 1, 0, 1)
116 }
117
118 function html_fnc_table_abbrev (caption)
119 {
120     html_fnc_table(caption, 1, 0, 0, 0, 0, 0, 0)
121 }
122
123
124 function html_fnc_table (caption,
125                          fname_p,
126                          mcyclo_p,
127                          cyclo_p,
128                          num_statements_p,
129                          num_lines_p,
130                          first_line_p,
131                          file_p)
132 {
133     print "<table width=\"90%\" class=\"function_table\" cellpadding=\"0\" cellspacing=\"0\">"
134     if (caption != "")
135     {
136         print "<caption class=\"function_table_caption\">" caption "</caption>"
137     }
138     html_fnc_header(fname_p, 
139                     mcyclo_p, 
140                     cyclo_p, 
141                     num_statements_p, 
142                     num_lines_p, 
143                     first_line_p, 
144                     file_p)
145     for (nfnc = 1; nfnc < nfuncs; nfnc++)
146     {
147         fnc = fnames[nfnc]
148         html_fnc(fnc, 
149                  fname_p, 
150                  mcyclo_p, 
151                  cyclo_p, 
152                  num_statements_p, 
153                  num_lines_p, 
154                  first_line_p, 
155                  file_p)
156     }
157     print "</table>"
158 }
159
160 function html_header ()
161 {
162     print html_doctype
163     print "<html>"
164     print html_comment
165     print "<head>"
166     print "<title>" html_title "</title>"
167     print ""
168     print "<meta name=\"description\" content=\"" html_title "\">"
169     print "<meta name=\"keywords\" content=\"" html_title "\">"
170     print "<meta name=\"resource-type\" content=\"document\">"
171     print "<meta name=\"distribution\" content=\"global\">"
172     print "<meta name=\"Generator\" content=\"pmccabe2html\">"
173     print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
174     print "<script language=\"javascript\" type=\"text/javascript\">"
175     print "function show_hide(idCapa, idButton, fuerzaVisibilidad)\
176 {\
177         var button = document.getElementById(idButton);\
178         var capa = document.getElementById(idCapa);\
179         if (capa)\
180         {\
181                 if (fuerzaVisibilidad && fuerzaVisibilidad!=\"\") {\
182                         if (fuerzaVisibilidad==\"visible\") capa.style.display=\"\";\
183                         else capa.style.display=\"none\";\
184                 }\
185                 else\
186                 {\
187                         if (capa.style.display == \"none\") {\
188                                 capa.style.display = \"\";\
189                                 button.innerHTML = \"&uarr;\";\
190                         } else {\
191                                 capa.style.display = \"none\";\
192                                 button.innerHTML = \"&darr;\";     \
193                         }\
194                 }\
195         }\
196 }"
197     print "</script>"
198
199
200     if (css_url != "")
201     {
202         print "<link rel=\"stylesheet\" href=\"" css_url "\" type =\"text/css\" media=\"screen\"/>"
203     }
204     if (css != "")
205     {
206         print "<style type =\"text/css\" media=\"screen\">"
207         print "<!--"
208         while ((getline cssline < css) > 0)
209         {
210             print cssline
211         }
212         print "-->"
213         print "</style />"
214         close(css)
215     }
216     print "</head>"
217     print "<body lang=\"en\" bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" \
218 vlink=\"#800080\" alink=\"#FF0000\">"
219 }
220
221 function html_footer ()
222 {
223     print "</body>"
224     print "</html>"
225 }
226
227 function html_fnc_header (fname_p,
228                           mcyclo_p,
229                           cyclo_p,
230                           num_statements_p,
231                           num_lines_p,
232                           first_line_p,
233                           file_p)
234 {
235     print "<tr class=\"function_table_header\">"
236     if (fname_p)
237     {
238         # Function name
239         print "<td class=\"function_table_header_entry\">"
240         print ""
241         print "</td>"
242
243         print "<td class=\"function_table_header_entry\">"
244         print "Function Name"
245         print "</td>"
246     }
247     if (mcyclo_p)
248     {
249         # Modified cyclo
250         print "<td class=\"function_table_header_entry\">"
251         print "Modified Cyclo"
252         print "</td>"
253     }
254     if (cyclo_p)
255     {
256         # Cyclo
257         print "<td class=\"function_table_header_entry\">"
258         print "Cyclomatic"
259         print "<br/>"
260         print "Complexity"
261         print "</td>"
262     }
263     if (num_statements_p)
264     {
265         print "<td class=\"function_table_header_entry\">"
266         print "Number of"
267         print "<br/>"
268         print "Statements"
269         print "</td>"
270     }
271     if (num_lines_p)
272     {
273         print "<td class=\"function_table_header_entry\">"
274         print "Number of"
275         print "<br/>"
276         print "Lines"
277         print "</td>"
278     }
279     if (first_line_p)
280     {
281         print "<td class=\"function_table_header_entry\">"
282         print "First Line"
283         print "</td>"
284     }
285     if (file_p)
286     {
287         print "<td class=\"function_table_header_entry\">"
288         print "Source File"
289         print "</td>"
290
291     }
292     print "</tr>"
293 }
294
295 function html_fnc (fname,
296                    fname_p,
297                    mcyclo_p,
298                    cyclo_p,
299                    num_statements_p,
300                    num_lines_p,
301                    first_line_p,
302                    file_p)
303 {
304     # Function name
305     trclass = "function_entry_simple"
306     if (mcyclo[fname] > cyclo_high_max)
307     {
308         trclass="function_entry_untestable"
309     }   
310     else if (mcyclo[fname] > cyclo_moderate_max)
311     {
312         trclass="function_entry_high"
313     }
314     else if (mcyclo[fname] > cyclo_simple_max)
315     {
316         trclass="function_entry_moderate"
317     }
318
319     print "<tr class=\"" trclass "\">"
320     if (fname_p)
321     {
322         print "<td class=\"function_entry_filename\">"
323         if (mcyclo[fname] > cyclo_simple_max)
324         {
325             print "<a href=\"javascript:void(0);\" title=\"show/hide function source\" onClick=\"javascript:show_hide('" fname "_src', '" fname "_button')\">\
326 <span id=\"" fname "_button\">&darr;</span></a>"
327         }
328         else
329         {
330             print "&nbsp;"
331         }
332         print "</td>"
333
334         print "<td class=\"function_entry_name\">"
335         print fname
336         print "</td>"
337     }
338     if (mcyclo_p)
339     {
340         # Modified cyclo
341         print "<td class=\"function_entry_cyclo\">"
342         print mcyclo[fname]
343         print "</td>"
344     }
345     if (cyclo_p)
346     {
347         # Cyclo
348         print "<td class=\"function_entry_cyclo\">"
349         print cyclo[fname]
350         print "</td>"
351     }
352     if (num_statements_p)
353     {
354         # Number of statements
355         print "<td class=\"function_entry_number\">"
356         print num_statements[fname]
357         print "</td>"
358     }
359     if (num_lines_p)
360     {
361         # Number of lines
362         print "<td class=\"function_entry_number\">"
363         print num_lines[fname]
364         print "</td>"
365     }
366     if (first_line_p)
367     {
368         # First line
369         print "<td class=\"function_entry_number\">"
370         print first_line[fname]
371         print "</td>"
372     }
373     if (file_p)
374     {
375         href = ""
376         if (source_file_link_tmpl != "")
377         {
378             # Get href target
379             href = source_file_link_tmpl
380             sub(/%FILENAME%/, file[fname], href)
381         }
382
383         # Source file
384         print "<td class=\"function_entry_filename\">"
385         if (href != "")
386         {
387             print "<a href=\"" href "\">" file[fname] "</a>"
388         }
389         else
390         {
391             print file[fname]
392         }
393  
394         print "</td>"
395
396
397         print "</tr>"
398
399         if (mcyclo[fname] > cyclo_simple_max)
400         {
401             print "<tr>"
402
403             num_columns = 1;
404             if (fname_p) { num_columns++ }
405             if (mcyclo_p) { num_columns++ }
406             if (cyclo_p) { num_columns++ }
407             if (num_statements_p) { num_columns++ }
408             if (num_lines_p) { num_columns++ }
409             if (first_line_p) { num_columns++ }
410             if (file_p) { num_columns++ }
411             
412             print "<td colspan=\"" num_columns "\" height=\"0\">"
413             print "<div id=\"" fname "_src\" class=\"function_src\" style=\"position: relative; display: none;\">"
414             print "<pre class=\"function_src\">"
415             while ((getline codeline < (fname "_fn.txt")) > 0)
416             {
417                 sub(/\\</, "&lt;", codeline)
418                 sub(/\\>/, "&gt;", codeline)
419                 sub(/&/, "&amp;", codeline)
420                 
421                 print codeline
422             }
423             close(fname "_fn.txt")
424             system("rm " fname "_fn.txt")
425             print "</pre>"
426             print "</div>"
427             print "</td>"
428             print "</tr>"
429         }
430
431     }
432 }
433
434 function html_global_stats ()
435 {
436     print "<div class=\"section_title\">Resume</div>"
437
438     print "<br/>"
439     print "<table class=\"resume_table\">"
440     # Total number of functions
441     print "<tr>"
442     print "<td class=\"resume_header_entry\">"
443     print "Total number of functions"
444     print "</td>"
445     print "<td class=\"resume_number_entry\">"
446     print num_of_functions
447     print "</td>"
448     print "</tr>"
449     # Number of simple functions
450     print "<tr>"
451     print "<td class=\"resume_header_entry\">"
452     print "Number of low risk functions"
453     print "</td>"
454     print "<td class=\"resume_number_entry\">"
455     print num_of_simple_functions
456     print "</td>"
457     print "</tr>"
458     # Number of moderate functions
459     print "<tr>"
460     print "<td class=\"resume_header_entry\">"
461     print "Number of moderate risk functions"
462     print "</td>"
463     print "<td class=\"resume_number_entry\">"
464     print num_of_moderate_functions
465     print "</td>"
466     print "</tr>"
467     # Number of high functions
468     print "<tr>"
469     print "<td class=\"resume_header_entry\">"
470     print "Number of high risk functions"
471     print "</td>"
472     print "<td class=\"resume_number_entry\">"
473     print num_of_high_functions
474     print "</td>"
475     print "</tr>"
476     # Number of untestable functions
477     print "<tr>"
478     print "<td class=\"resume_header_entry\">"
479     print "Number of untestable functions"
480     print "</td>"
481     print "<td class=\"resume_number_entry\">"
482     print num_of_untestable_functions
483     print "</td>"
484     print "</tr>"
485     print "</table>"
486     print "<br/>"
487 }
488
489 function html_function_cyclo ()
490 {
491     print "<div class=\"section_title\">Details for all functions</div>"
492     print "<p>Used ranges:</p>"
493
494     print "<table class=\"ranges_table\">"
495     print "<tr>"
496     print "<td class=\"ranges_header_entry\">"
497     print "&nbsp;"
498     print "</td>"
499     print "<td class=\"ranges_header_entry\">"
500     print "Cyclomatic Complexity"
501     print "</td>"
502     print "<td class=\"ranges_header_entry\">"
503     print "Risk Evaluation"
504     print "</td>"
505     print "</tr>"
506     # Simple
507     print "<tr>"
508     print "<td class=\"ranges_entry_simple\">"
509     print "&nbsp;"
510     print "</td>"
511     print "<td class=\"ranges_entry\">"
512     print "0 - " cyclo_simple_max
513     print "</td>"
514     print "<td class=\"ranges_entry\">"
515     print "Simple module, without much risk"
516     print "</td>"
517     print "</tr>"
518     # Moderate 
519     print "<tr>"
520     print "<td class=\"ranges_entry_moderate\">"
521     print "&nbsp;"
522     print "</td>"
523     print "<td class=\"ranges_entry\">"
524     print cyclo_simple_max + 1 " - " cyclo_moderate_max
525     print "</td>"
526     print "<td class=\"ranges_entry\">"
527     print "More complex module, moderate risk"
528     print "</td>"
529     print "</tr>"
530     # High
531     print "<tr>"
532     print "<td class=\"ranges_entry_high\">"
533     print "&nbsp;"
534     print "</td>"
535     print "<td class=\"ranges_entry\">"
536     print cyclo_moderate_max + 1 " - " cyclo_high_max
537     print "</td>"
538     print "<td class=\"ranges_entry\">"
539     print "Complex module, high risk"
540     print "</td>"
541     print "</tr>"
542     # Untestable
543     print "<tr>"
544     print "<td class=\"ranges_entry_untestable\">"
545     print "&nbsp;"
546     print "</td>"
547     print "<td class=\"ranges_entry\">"
548     print "greater than " cyclo_high_max
549     print "</td>"
550     print "<td class=\"ranges_entry\">"
551     print "Untestable module, very high risk"
552     print "</td>"
553     print "</tr>"
554     print "</table>"
555     print "<br/>"
556     html_fnc_table_complete("")
557 }
558
559 function wiki_global_stats ()
560 {
561     print "{| class=\"cyclo_resume_table\""
562     # Total number of functions
563     print "|-"
564     print "| class=\"cyclo_resume_header_entry\" | Total number of functions"
565     print "| class=\"cyclo_resume_number_entry\" |" num_of_functions
566     # Number of simple functions
567     print "|-"
568     print "| class=\"cyclo_resume_header_entry\" | Number of low risk functions"
569     print "| class=\"cyclo_resume_number_entry\" |" num_of_simple_functions
570     # Number of moderate functions
571     print "|-"
572     print "| class=\"cyclo_resume_header_entry\" | Number of moderate risk functions"
573     print "| class=\"cyclo_resume_number_entry\" |" num_of_moderate_functions
574     # Number of high functions
575     print "|-"
576     print "| class=\"cyclo_resume_header_entry\" | Number of high risk functions"
577     print "| class=\"cyclo_resume_number_entry\" |" num_of_high_functions
578     # Number of untestable functions
579     print "|-"
580     print "| class=\"cyclo_resume_header_entry\" | Number of untestable functions"
581     print "| class=\"cyclo_resume_number_entry\" |" num_of_untestable_functions
582     print "|}"
583 }
584
585 function wiki_function_cyclo ()
586 {
587     print "==Details for all functions=="
588
589     print "Used ranges:"
590     
591     print "{| class =\"cyclo_ranges_table\""
592     print "|-"
593     print "| class=\"cyclo_ranges_header_entry\" | "
594     print "| class=\"cyclo_ranges_header_entry\" | Cyclomatic Complexity"
595     print "| class=\"cyclo_ranges_header_entry\" | Risk Evaluation"
596     # Simple
597     print "|-"
598     print "| class=\"cyclo_ranges_entry_simple\" | "
599     print "| class=\"cyclo_ranges_entry\" | 0 - " cyclo_simple_max
600     print "| class=\"cyclo_ranges_entry\" | Simple module, without much risk"
601     # Moderate
602     print "|-"
603     print "| class=\"cyclo_ranges_entry_moderate\" | "
604     print "| class=\"cyclo_ranges_entry\" |" cyclo_simple_max + 1 " - " cyclo_moderate_max
605     print "| class=\"cyclo_ranges_entry\" | More complex module, moderate risk"
606     # High
607     print "|-"
608     print "| class=\"cyclo_ranges_entry_high\" | "
609     print "| class=\"cyclo_ranges_entry\" |" cyclo_moderate_max + 1 " - " cyclo_high_max
610     print "| class=\"cyclo_ranges_entry\" | Complex module, high risk"
611     # Untestable
612     print "|-"
613     print "| class=\"cyclo_ranges_entry_untestable\" | "
614     print "| class=\"cyclo_ranges_entry\" | greater than " cyclo_high_max
615     print "| class=\"cyclo_ranges_entry\" | Untestable module, very high risk"
616     print "|}"
617
618     print ""
619     print ""
620     wiki_fnc_table_complete("")
621 }
622
623 function wiki_fnc_table_complete (caption)
624 {
625     wiki_fnc_table(caption, 1, 0, 1, 1, 1, 0, 1)
626 }
627
628 function wiki_fnc_table_abbrev (caption)
629 {
630     wiki_fnc_table(caption, 1, 0, 0, 0, 0, 0, 0)
631 }
632
633 function wiki_fnc_table (caption,
634                          fname_p,
635                          mcyclo_p,
636                          cyclo_p,
637                          num_statements_p,
638                          num_lines_p,
639                          first_line_p,
640                          file_p)
641 {
642     print "{| width=\"90%\" class=\"cyclo_function_table\" cellpadding=\"0\" cellspacing=\"0\">"
643     if (caption != "")
644     {
645         print "|+" caption
646     }
647     wiki_fnc_header(fname_p, 
648                     mcyclo_p, 
649                     cyclo_p, 
650                     num_statements_p, 
651                     num_lines_p, 
652                     first_line_p, 
653                     file_p)
654     for (nfnc = 1; nfnc < nfuncs; nfnc++)
655     {
656         fnc = fnames[nfnc]
657         wiki_fnc(fnc, 
658                  fname_p, 
659                  mcyclo_p, 
660                  cyclo_p, 
661                  num_statements_p, 
662                  num_lines_p, 
663                  first_line_p, 
664                  file_p)
665     }
666     print "|}"
667 }
668
669 function wiki_fnc_header (fname_p,
670                           mcyclo_p,
671                           cyclo_p,
672                           num_statements_p,
673                           num_lines_p,
674                           first_line_p,
675                           file_p)
676 {
677     if (fname_p)
678     {
679         # Function name
680         print "! class=\"cyclo_function_table_header_entry\" | Function Name"
681     }
682     if (mcyclo_p)
683     {
684         # Modified cyclo
685         print "! class=\"cyclo_function_table_header_entry\" | Modified Cyclo"
686     }
687     if (cyclo_p)
688     {
689         # Cyclo
690         print "! class=\"cyclo_function_table_header_entry\" | Cyclomatic Complexity"
691     }
692     if (num_statements_p)
693     {
694         print "! class=\"cyclo_function_table_header_entry\" | Number of Statements"
695     }
696     if (num_lines_p)
697     {
698         print "! class=\"cyclo_function_table_header_entry\" | Number of Lines"
699     }
700     if (first_line_p)
701     {
702         print "! class=\"cyclo_function_table_header_entry\" | First Line"
703     }
704     if (file_p)
705     {
706         print "! class=\"cyclo_function_table_header_entry\" | Source File"
707     }
708 }
709
710 function wiki_fnc (fname,
711                    fname_p,
712                    mcyclo_p,
713                    cyclo_p,
714                    num_statements_p,
715                    num_lines_p,
716                    first_line_p,
717                    file_p)
718 {
719     # Function name
720     trclass = "cyclo_function_entry_simple"
721     if (mcyclo[fname] > cyclo_high_max)
722     {
723         trclass="cyclo_function_entry_untestable"
724     }   
725     else if (mcyclo[fname] > cyclo_moderate_max)
726     {
727         trclass="cyclo_function_entry_high"
728     }
729     else if (mcyclo[fname] > cyclo_simple_max)
730     {
731         trclass="cyclo_function_entry_moderate"
732     }
733
734     print "|- class=\"" trclass "\""
735     if (fname_p)
736     {
737         print "| class=\"cyclo_function_entry_name\" |" fname
738     }
739     if (mcyclo_p)
740     {
741         # Modified cyclo
742         print "| class=\"cyclo_function_entry_cyclo\" |" mcyclo[fname]
743     }
744     if (cyclo_p)
745     {
746         # Cyclo
747         print "| class=\"cyclo_function_entry_cyclo\" |" cyclo[fname]
748     }
749     if (num_statements_p)
750     {
751         # Number of statements
752         print "| class=\"cyclo_function_entry_number\" |" num_statements[fname]
753     }
754     if (num_lines_p)
755     {
756         # Number of lines
757         print "| class=\"cyclo_function_entry_number\" |" num_lines[fname]
758     }
759     if (first_line_p)
760     {
761         # First line
762         print "| class=\"cyclo_function_entry_number\" |" first_line[fname]
763     }
764     if (file_p)
765     {
766         href = ""
767         if (source_file_link_tmpl != "")
768         {
769             # Get href target
770             href = source_file_link_tmpl
771             sub(/%FILENAME%/, file[fname], href)
772         }
773         
774         # Source file
775         print "| class=\"cyclo_function_entry_filename\" |" \
776             ((href != "") ? "[" href " " file[fname] "]" : "[" file[fname] "]")
777     }
778 }
779
780 # Scan data from a line
781 {
782     function_name = $7
783
784     nfuncs++;
785     fnames[nfuncs] = function_name
786     mcyclo[function_name] = $1
787     cyclo[function_name] = $2
788     num_statements[function_name] = $3
789     first_line[function_name] = $4
790     num_lines[function_name] = $5
791
792     # Build the filename from the file_spec ($6)
793     begin_util_path = index($6, cut_dir)
794     tmpfilename = substr($6, begin_util_path + length(cut_dir))
795     sub(/\([0-9]+\):/, "", tmpfilename)
796     file[function_name] = tmpfilename
797
798     if (mcyclo[function_name] > cyclo_simple_max)
799     {
800         # Extract function contents to a fn_txt file
801         filepath = $6
802         sub(/\([0-9]+\):/, "", filepath)
803         num_line = 0
804         while ((getline codeline < filepath) > 0)
805         {
806             num_line++;
807             if ((num_line >= first_line[function_name]) &&
808                 (num_line < first_line[function_name] + num_lines[function_name]))
809             {
810                 print codeline > (function_name "_fn.txt")
811             }
812         }
813         close (function_name "_fn.txt")
814         close(filepath)
815     }
816
817     # Initial values for statistics variables
818     num_of_functions = 0
819     max_mcyclo = 0
820     max_function_length = 0
821     num_of_simple_functions = 0
822     num_of_moderate_functions = 0
823     num_of_high_functions = 0
824     num_of_untestable_functions = 0
825 }
826
827 # Epilogue
828 END {
829     # Print header (only for html)
830     if (output_lang == "html")
831     {
832         html_header()
833     }
834
835     # Print prolog
836     if ((output_lang == "html") && 
837         (html_prolog != ""))
838     {
839         print html_prolog
840     }
841     if ((output_lang == "wiki") &&
842         (wiki_prolog != ""))
843     {
844         print wiki_prolog
845     }
846
847     if (output_lang == "html")
848     {
849         print "<div class=\"page_title\">" package_name " Cyclomatic Complexity Report</div>"
850         print "<p>Report generated at: <span class=\"report_timestamp\">" strftime() "</div></p>"
851     }
852     if (output_lang == "wiki")
853     {
854         print "==" package_name " Cyclomatic Complexity Report=="
855         print "Report generated at: '''" strftime() "'''"
856     }
857
858     if (section_global_stats_p)
859     {
860         build_stats()
861
862         if (output_lang == "html")
863         {
864             html_global_stats()
865         }
866         if (output_lang == "wiki")
867         {
868             wiki_global_stats()
869         }
870     }
871     if (section_function_cyclo_p)
872     {
873         if (output_lang == "html")
874         {
875             html_function_cyclo()
876         }
877         if (output_lang == "wiki")
878         {
879             wiki_function_cyclo()
880         }
881     }
882     
883     # Print epilog
884     if ((output_lang == "html") && 
885         (html_epilog != ""))
886     {
887         print html_epilog
888     }
889     if ((output_lang == "wiki") &&
890         (wiki_epilog != ""))
891     {
892         print wiki_epilog
893     }
894
895     # Print footer (html only)
896     if (output_lang == "html")
897     {
898         html_footer()
899     }
900 }
901
902 # End of pmccabe2html