X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=build-aux%2Fpmccabe2html;h=81dd932ca3c1e7dbdcfbb812c3af11ce8f30e036;hb=46f5f314f34a08c9305758482d7d2fdb0e999d09;hp=dd397cff19ad1951386bdd93411627bc6a2b9540;hpb=b7be78fd0c455acefbdf32618c2f6488915c1a33;p=gnulib.git diff --git a/build-aux/pmccabe2html b/build-aux/pmccabe2html index dd397cff1..81dd932ca 100644 --- a/build-aux/pmccabe2html +++ b/build-aux/pmccabe2html @@ -1,6 +1,6 @@ -# pmccabe2html - AWK script to convert pmccabe output to html +# pmccabe2html - AWK script to convert pmccabe output to html -*- awk -*- -# Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 2007-2014 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,16 +21,19 @@ # Typical Invocation is from a Makefile.am: # -# cyclo-$(PACKAGE).html: -# $(PMCCABE) ${top_srcdir}/lib/*.[ch] \ -# | sort -nr \ -# | $(AWK) -f ${top_srcdir}/build-aux/pmccabe2html \ -# -v lang=html -v name="$(PACKAGE_NAME)" \ -# -v vcurl="http://git.savannah.gnu.org/gitweb/?p=$(PACKAGE).git;a=blob;f=%FILENAME%;hb=HEAD" \ -# -v url="http://www.gnu.org/software/$(PACKAGE)/" \ -# -v css=${top_srcdir}/build-aux/pmccabe.css \ -# > $@-tmp -# mv $@-tmp $@ +# CYCLO_SOURCES = ${top_srcdir}/src/*.[ch] +# +# cyclo-$(PACKAGE).html: $(CYCLO_SOURCES) +# $(PMCCABE) $(CYCLO_SOURCES) \ +# | sort -nr \ +# | $(AWK) -f ${top_srcdir}/build-aux/pmccabe2html \ +# -v lang=html -v name="$(PACKAGE_NAME)" \ +# -v vcurl="http://git.savannah.gnu.org/gitweb/?p=$(PACKAGE).git;a=blob;f=%FILENAME%;hb=HEAD" \ +# -v url="http://www.gnu.org/software/$(PACKAGE)/" \ +# -v css=${top_srcdir}/build-aux/pmccabe.css \ +# -v cut_dir=${top_srcdir}/ \ +# > $@-tmp +# mv $@-tmp $@ # # The variables available are: # lang output language, either 'html' or 'wiki' @@ -44,6 +47,10 @@ # Prologue & configuration BEGIN { + # Portable lookup of present time. + "date +%s" | getline epoch_time + "date" | getline chronos_time + section_global_stats_p = 1 section_function_cyclo_p = 1 @@ -55,7 +62,6 @@ BEGIN { cyclo_simple_max = 10 cyclo_moderate_max = 20 cyclo_high_max = 50 - cut_dir = "/../" source_file_link_tmpl = vcurl # HTML options @@ -64,10 +70,10 @@ BEGIN { html_prolog = "Back to " package_name " Homepage

" } html_epilog = "
\ -Copyright (c) 2007, 2008 Free Software Foundation Inc." +Copyright (c) 2007, 2008 Free Software Foundation, Inc." html_doctype = "" - html_comment = "" + html_comment = "" html_title = "Cyclomatic Complexity report for " package_name # Wiki options @@ -112,12 +118,12 @@ function build_stats() function html_fnc_table_complete (caption) { - html_fnc_table(caption, 1, 0, 1, 1, 1, 0, 1) + html_fnc_table(caption, 1, 1, 0, 1, 1, 0, 1) } function html_fnc_table_abbrev (caption) { - html_fnc_table(caption, 1, 0, 1, 0, 1, 0, 0) + html_fnc_table(caption, 1, 1, 0, 0, 1, 0, 0) } @@ -135,22 +141,22 @@ function html_fnc_table (caption, { print "" caption "" } - html_fnc_header(fname_p, - mcyclo_p, - cyclo_p, - num_statements_p, - num_lines_p, - first_line_p, + html_fnc_header(fname_p, + mcyclo_p, + cyclo_p, + num_statements_p, + num_lines_p, + first_line_p, file_p) - for (nfnc = 1; nfnc < nfuncs; nfnc++) + for (nfnc = 1; nfnc <= nfuncs; nfnc++) { html_fnc(nfnc, - fname_p, - mcyclo_p, - cyclo_p, - num_statements_p, - num_lines_p, - first_line_p, + fname_p, + mcyclo_p, + cyclo_p, + num_statements_p, + num_lines_p, + first_line_p, file_p) } print "" @@ -209,7 +215,7 @@ function html_header () print cssline } print "-->" - print "" + print "" close(css) } print "" @@ -307,7 +313,7 @@ function html_fnc (nfun, if (mcyclo[nfun] > cyclo_high_max) { trclass="function_entry_untestable" - } + } else if (mcyclo[nfun] > cyclo_moderate_max) { trclass="function_entry_high" @@ -391,7 +397,7 @@ function html_fnc (nfun, { print file[nfun] } - + print "" @@ -409,21 +415,21 @@ function html_fnc (nfun, if (num_lines_p) { num_columns++ } if (first_line_p) { num_columns++ } if (file_p) { num_columns++ } - + print "" print "
" print "
"
 
             while ((getline codeline < (fname nfun "_fn.txt")) > 0)
             {
-                sub(/\\/, ">", codeline)
-                sub(/&/, "&", codeline)
-                
+                gsub(/&/, "\&", codeline)	# Must come first.
+                gsub(//, "\>", codeline)
+
                 print codeline
             }
             close(fname nfun "_fn.txt")
-            system("rm " fname nfun "_fn.txt")
+            system("rm " "'" fname "'" nfun "_fn.txt")
             print "
" print "
" print "" @@ -435,52 +441,51 @@ function html_fnc (nfun, function html_global_stats () { - print "
Resume
" + print "
Summary
" - print "
" - print "" + print "
" # Total number of functions print "" - print "" - print "" print "" # Number of simple functions print "" - print "" - print "" print "" # Number of moderate functions print "" - print "" - print "" print "" # Number of high functions print "" - print "" - print "" print "" # Number of untestable functions print "" - print "" - print "" print "" @@ -491,7 +496,6 @@ function html_global_stats () function html_function_cyclo () { print "
Details for all functions
" - print "

Used ranges:

" print "
" + print "" print "Total number of functions" print "" + print "" print num_of_functions print "
" + print "" print "Number of low risk functions" print "" + print "" print num_of_simple_functions print "
" + print "" print "Number of moderate risk functions" print "" + print "" print num_of_moderate_functions print "
" + print "" print "Number of high risk functions" print "" + print "" print num_of_high_functions print "
" + print "" print "Number of untestable functions" print "" + print "" print num_of_untestable_functions print "
" print "" @@ -517,7 +521,7 @@ function html_function_cyclo () print "Simple module, without much risk" print "" print "" - # Moderate + # Moderate print "" print "
" print " " @@ -560,27 +564,27 @@ function html_function_cyclo () function wiki_global_stats () { - print "{| class=\"cyclo_resume_table\"" + print "{| class=\"cyclo_summary_table\"" # Total number of functions print "|-" - print "| class=\"cyclo_resume_header_entry\" | Total number of functions" - print "| class=\"cyclo_resume_number_entry\" |" num_of_functions + print "| class=\"cyclo_summary_header_entry\" | Total number of functions" + print "| class=\"cyclo_summary_number_entry\" |" num_of_functions # Number of simple functions print "|-" - print "| class=\"cyclo_resume_header_entry\" | Number of low risk functions" - print "| class=\"cyclo_resume_number_entry\" |" num_of_simple_functions + print "| class=\"cyclo_summary_header_entry\" | Number of low risk functions" + print "| class=\"cyclo_summary_number_entry\" |" num_of_simple_functions # Number of moderate functions print "|-" - print "| class=\"cyclo_resume_header_entry\" | Number of moderate risk functions" - print "| class=\"cyclo_resume_number_entry\" |" num_of_moderate_functions + print "| class=\"cyclo_summary_header_entry\" | Number of moderate risk functions" + print "| class=\"cyclo_summary_number_entry\" |" num_of_moderate_functions # Number of high functions print "|-" - print "| class=\"cyclo_resume_header_entry\" | Number of high risk functions" - print "| class=\"cyclo_resume_number_entry\" |" num_of_high_functions + print "| class=\"cyclo_summary_header_entry\" | Number of high risk functions" + print "| class=\"cyclo_summary_number_entry\" |" num_of_high_functions # Number of untestable functions print "|-" - print "| class=\"cyclo_resume_header_entry\" | Number of untestable functions" - print "| class=\"cyclo_resume_number_entry\" |" num_of_untestable_functions + print "| class=\"cyclo_summary_header_entry\" | Number of untestable functions" + print "| class=\"cyclo_summary_number_entry\" |" num_of_untestable_functions print "|}" } @@ -589,7 +593,7 @@ function wiki_function_cyclo () print "==Details for all functions==" print "Used ranges:" - + print "{| class =\"cyclo_ranges_table\"" print "|-" print "| class=\"cyclo_ranges_header_entry\" | " @@ -624,7 +628,7 @@ function wiki_function_cyclo () function wiki_fnc_table_complete (caption) { - wiki_fnc_table(caption, 1, 0, 1, 1, 1, 0, 1) + wiki_fnc_table(caption, 1, 1, 0, 1, 1, 0, 1) } function wiki_fnc_table_abbrev (caption) @@ -646,22 +650,22 @@ function wiki_fnc_table (caption, { print "|+" caption } - wiki_fnc_header(fname_p, - mcyclo_p, - cyclo_p, - num_statements_p, - num_lines_p, - first_line_p, + wiki_fnc_header(fname_p, + mcyclo_p, + cyclo_p, + num_statements_p, + num_lines_p, + first_line_p, file_p) - for (nfnc = 1; nfnc < nfuncs; nfnc++) + for (nfnc = 1; nfnc <= nfuncs; nfnc++) { wiki_fnc(nfnc, - fname_p, - mcyclo_p, - cyclo_p, - num_statements_p, - num_lines_p, - first_line_p, + fname_p, + mcyclo_p, + cyclo_p, + num_statements_p, + num_lines_p, + first_line_p, file_p) } print "|}" @@ -724,7 +728,7 @@ function wiki_fnc (nfnc, if (mcyclo[nfnc] > cyclo_high_max) { trclass="cyclo_function_entry_untestable" - } + } else if (mcyclo[nfnc] > cyclo_moderate_max) { trclass="cyclo_function_entry_high" @@ -773,7 +777,7 @@ function wiki_fnc (nfnc, href = source_file_link_tmpl sub(/%FILENAME%/, file[nfnc], href) } - + # Source file print "| class=\"cyclo_function_entry_filename\" |" \ ((href != "") ? "[" href " " file[nfnc] "]" : "[" file[nfnc] "]") @@ -838,7 +842,7 @@ END { } # Print prolog - if ((output_lang == "html") && + if ((output_lang == "html") && (html_prolog != "")) { print html_prolog @@ -852,12 +856,12 @@ END { if (output_lang == "html") { print "
" package_name " Cyclomatic Complexity Report
" - print "

Report generated at: " strftime() "

" + print "

Report generated at: " chronos_time "

" } if (output_lang == "wiki") { print "==" package_name " Cyclomatic Complexity Report==" - print "Report generated at: '''" strftime() "'''" + print "Report generated at: '''" chronos_time "'''" } if (section_global_stats_p) @@ -884,9 +888,9 @@ END { wiki_function_cyclo() } } - + # Print epilog - if ((output_lang == "html") && + if ((output_lang == "html") && (html_epilog != "")) { print html_epilog