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