aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2018-02-05 14:40:15 -0500
committerJonathan Corbet <corbet@lwn.net>2018-02-15 15:11:02 -0500
commit0bba924ce99aadf8dcd316b8bf8b98902925ea8a (patch)
treef142aea316232a55e4642417d2733b8acde59c7f /scripts/kernel-doc
parent35277995e17919ab838beae765f440674e8576eb (diff)
docs: kernel-doc: Get rid of xml_escape() and friends
XML escaping is a worry that came with DocBook, which we no longer have any dealings with. So get rid of the useless xml_escape()/xml_unescape() functions. No change to the generated output. Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-xscripts/kernel-doc65
1 files changed, 9 insertions, 56 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index fee8952037b1..5aa4ce211fc6 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -553,10 +553,9 @@ sub output_highlight {
553 } 553 }
554 if ($line eq ""){ 554 if ($line eq ""){
555 if (! $output_preformatted) { 555 if (! $output_preformatted) {
556 print $lineprefix, local_unescape($blankline); 556 print $lineprefix, $blankline;
557 } 557 }
558 } else { 558 } else {
559 $line =~ s/\\\\\\/\&/g;
560 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { 559 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
561 print "\\&$line"; 560 print "\\&$line";
562 } else { 561 } else {
@@ -751,9 +750,6 @@ sub output_highlight_rst {
751 my $contents = join "\n",@_; 750 my $contents = join "\n",@_;
752 my $line; 751 my $line;
753 752
754 # undo the evil effects of xml_escape() earlier
755 $contents = xml_unescape($contents);
756
757 eval $dohighlight; 753 eval $dohighlight;
758 die $@ if $@; 754 die $@ if $@;
759 755
@@ -1422,8 +1418,6 @@ sub push_parameter($$$$) {
1422 } 1418 }
1423 } 1419 }
1424 1420
1425 $param = xml_escape($param);
1426
1427 # strip spaces from $param so that it is one continuous string 1421 # strip spaces from $param so that it is one continuous string
1428 # on @parameterlist; 1422 # on @parameterlist;
1429 # this fixes a problem where check_sections() cannot find 1423 # this fixes a problem where check_sections() cannot find
@@ -1748,47 +1742,6 @@ sub process_proto_type($$) {
1748 } 1742 }
1749} 1743}
1750 1744
1751# xml_escape: replace <, >, and & in the text stream;
1752#
1753# however, formatting controls that are generated internally/locally in the
1754# kernel-doc script are not escaped here; instead, they begin life like
1755# $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings
1756# are converted to their mnemonic-expected output, without the 4 * '\' & ':',
1757# just before actual output; (this is done by local_unescape())
1758sub xml_escape($) {
1759 my $text = shift;
1760 if ($output_mode eq "man") {
1761 return $text;
1762 }
1763 $text =~ s/\&/\\\\\\amp;/g;
1764 $text =~ s/\</\\\\\\lt;/g;
1765 $text =~ s/\>/\\\\\\gt;/g;
1766 return $text;
1767}
1768
1769# xml_unescape: reverse the effects of xml_escape
1770sub xml_unescape($) {
1771 my $text = shift;
1772 if ($output_mode eq "man") {
1773 return $text;
1774 }
1775 $text =~ s/\\\\\\amp;/\&/g;
1776 $text =~ s/\\\\\\lt;/</g;
1777 $text =~ s/\\\\\\gt;/>/g;
1778 return $text;
1779}
1780
1781# convert local escape strings to html
1782# local escape strings look like: '\\\\menmonic:' (that's 4 backslashes)
1783sub local_unescape($) {
1784 my $text = shift;
1785 if ($output_mode eq "man") {
1786 return $text;
1787 }
1788 $text =~ s/\\\\\\\\lt:/</g;
1789 $text =~ s/\\\\\\\\gt:/>/g;
1790 return $text;
1791}
1792 1745
1793sub map_filename($) { 1746sub map_filename($) {
1794 my $file; 1747 my $file;
@@ -1889,7 +1842,7 @@ sub process_file($) {
1889 $descr =~ s/^\s*//; 1842 $descr =~ s/^\s*//;
1890 $descr =~ s/\s*$//; 1843 $descr =~ s/\s*$//;
1891 $descr =~ s/\s+/ /g; 1844 $descr =~ s/\s+/ /g;
1892 $declaration_purpose = xml_escape($descr); 1845 $declaration_purpose = $descr;
1893 $in_purpose = 1; 1846 $in_purpose = 1;
1894 } else { 1847 } else {
1895 $declaration_purpose = ""; 1848 $declaration_purpose = "";
@@ -1944,7 +1897,7 @@ sub process_file($) {
1944 print STDERR "${file}:$.: warning: contents before sections\n"; 1897 print STDERR "${file}:$.: warning: contents before sections\n";
1945 ++$warnings; 1898 ++$warnings;
1946 } 1899 }
1947 dump_section($file, $section, xml_escape($contents)); 1900 dump_section($file, $section, $contents);
1948 $section = $section_default; 1901 $section = $section_default;
1949 } 1902 }
1950 1903
@@ -1962,7 +1915,7 @@ sub process_file($) {
1962 $leading_space = undef; 1915 $leading_space = undef;
1963 } elsif (/$doc_end/) { 1916 } elsif (/$doc_end/) {
1964 if (($contents ne "") && ($contents ne "\n")) { 1917 if (($contents ne "") && ($contents ne "\n")) {
1965 dump_section($file, $section, xml_escape($contents)); 1918 dump_section($file, $section, $contents);
1966 $section = $section_default; 1919 $section = $section_default;
1967 $contents = ""; 1920 $contents = "";
1968 } 1921 }
@@ -1981,7 +1934,7 @@ sub process_file($) {
1981 # @parameter line to signify start of description 1934 # @parameter line to signify start of description
1982 if ($1 eq "") { 1935 if ($1 eq "") {
1983 if ($section =~ m/^@/ || $section eq $section_context) { 1936 if ($section =~ m/^@/ || $section eq $section_context) {
1984 dump_section($file, $section, xml_escape($contents)); 1937 dump_section($file, $section, $contents);
1985 $section = $section_default; 1938 $section = $section_default;
1986 $contents = ""; 1939 $contents = "";
1987 $new_start_line = $.; 1940 $new_start_line = $.;
@@ -1992,7 +1945,7 @@ sub process_file($) {
1992 } elsif ($in_purpose == 1) { 1945 } elsif ($in_purpose == 1) {
1993 # Continued declaration purpose 1946 # Continued declaration purpose
1994 chomp($declaration_purpose); 1947 chomp($declaration_purpose);
1995 $declaration_purpose .= " " . xml_escape($1); 1948 $declaration_purpose .= " " . $1;
1996 $declaration_purpose =~ s/\s+/ /g; 1949 $declaration_purpose =~ s/\s+/ /g;
1997 } else { 1950 } else {
1998 my $cont = $1; 1951 my $cont = $1;
@@ -2030,7 +1983,7 @@ sub process_file($) {
2030 # Documentation block end */ 1983 # Documentation block end */
2031 } elsif (/$doc_inline_end/) { 1984 } elsif (/$doc_inline_end/) {
2032 if (($contents ne "") && ($contents ne "\n")) { 1985 if (($contents ne "") && ($contents ne "\n")) {
2033 dump_section($file, $section, xml_escape($contents)); 1986 dump_section($file, $section, $contents);
2034 $section = $section_default; 1987 $section = $section_default;
2035 $contents = ""; 1988 $contents = "";
2036 } 1989 }
@@ -2057,7 +2010,7 @@ sub process_file($) {
2057 $contents = $2; 2010 $contents = $2;
2058 if ($contents ne "") { 2011 if ($contents ne "") {
2059 $contents .= "\n"; 2012 $contents .= "\n";
2060 dump_section($file, $section, xml_escape($contents)); 2013 dump_section($file, $section, $contents);
2061 $section = $section_default; 2014 $section = $section_default;
2062 $contents = ""; 2015 $contents = "";
2063 } 2016 }
@@ -2072,7 +2025,7 @@ sub process_file($) {
2072 } elsif ($state == STATE_DOCBLOCK) { 2025 } elsif ($state == STATE_DOCBLOCK) {
2073 if (/$doc_end/) 2026 if (/$doc_end/)
2074 { 2027 {
2075 dump_doc_section($file, $section, xml_escape($contents)); 2028 dump_doc_section($file, $section, $contents);
2076 $section = $section_default; 2029 $section = $section_default;
2077 $contents = ""; 2030 $contents = "";
2078 $function = ""; 2031 $function = "";