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