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.
Showing the changes to scripts/kernel-doc (1 of 1 file). Show all
Unified · Split
| @@ -553,10 +553,9 @@ sub output_highlight { · 552 unmodified lines | ||
| 553 | 553 | } |
| 554 | 554 | if ($line eq ""){ |
| 555 | 555 | if (! $output_preformatted) { |
| 556 | − print $lineprefix, local_unescape($blankline); | |
| 556 | + print $lineprefix, $blankline; | |
| 557 | 557 | } |
| 558 | 558 | } else { |
| 559 | − $line =~ s/\\\\\\/\&/g; | |
| 560 | 559 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { |
| 561 | 560 | print "\\&$line"; |
| 562 | 561 | } else { |
| @@ -751,9 +750,6 @@ sub output_highlight_rst { · 188 unmodified lines | ||
| 751 | 750 | my $contents = join "\n",@_; |
| 752 | 751 | my $line; |
| 753 | 752 | |
| 754 | − # undo the evil effects of xml_escape() earlier | |
| 755 | − $contents = xml_unescape($contents); | |
| 756 | − | |
| 757 | 753 | eval $dohighlight; |
| 758 | 754 | die $@ if $@; |
| 759 | 755 | |
| @@ -1422,8 +1418,6 @@ sub push_parameter($$$$) { · 662 unmodified lines | ||
| 1422 | 1418 | } |
| 1423 | 1419 | } |
| 1424 | 1420 | |
| 1425 | − $param = xml_escape($param); | |
| 1426 | − | |
| 1427 | 1421 | # strip spaces from $param so that it is one continuous string |
| 1428 | 1422 | # on @parameterlist; |
| 1429 | 1423 | # this fixes a problem where check_sections() cannot find |
| @@ -1748,47 +1742,6 @@ sub process_proto_type($$) { · 318 unmodified lines | ||
| 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()) | |
| 1758 | −sub 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 | |
| 1770 | −sub 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) | |
| 1783 | −sub 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 | |
| 1793 | 1746 | sub map_filename($) { |
| 1794 | 1747 | my $file; |
| @@ -1889,7 +1842,7 @@ sub process_file($) { · 94 unmodified lines | ||
| 1889 | 1842 | $descr =~ s/^\s*//; |
| 1890 | 1843 | $descr =~ s/\s*$//; |
| 1891 | 1844 | $descr =~ s/\s+/ /g; |
| 1892 | − $declaration_purpose = xml_escape($descr); | |
| 1845 | + $declaration_purpose = $descr; | |
| 1893 | 1846 | $in_purpose = 1; |
| 1894 | 1847 | } else { |
| 1895 | 1848 | $declaration_purpose = ""; |
| @@ -1944,7 +1897,7 @@ sub process_file($) { · 48 unmodified lines | ||
| 1944 | 1897 | print STDERR "${file}:$.: warning: contents before sections\n"; |
| 1945 | 1898 | ++$warnings; |
| 1946 | 1899 | } |
| 1947 | − dump_section($file, $section, xml_escape($contents)); | |
| 1900 | + dump_section($file, $section, $contents); | |
| 1948 | 1901 | $section = $section_default; |
| 1949 | 1902 | } |
| 1950 | 1903 | |
| @@ -1962,7 +1915,7 @@ sub process_file($) { · 11 unmodified lines | ||
| 1962 | 1915 | $leading_space = undef; |
| 1963 | 1916 | } elsif (/$doc_end/) { |
| 1964 | 1917 | if (($contents ne "") && ($contents ne "\n")) { |
| 1965 | − dump_section($file, $section, xml_escape($contents)); | |
| 1918 | + dump_section($file, $section, $contents); | |
| 1966 | 1919 | $section = $section_default; |
| 1967 | 1920 | $contents = ""; |
| 1968 | 1921 | } |
| @@ -1981,7 +1934,7 @@ sub process_file($) { · 12 unmodified lines | ||
| 1981 | 1934 | # @parameter line to signify start of description |
| 1982 | 1935 | if ($1 eq "") { |
| 1983 | 1936 | if ($section =~ m/^@/ || $section eq $section_context) { |
| 1984 | − dump_section($file, $section, xml_escape($contents)); | |
| 1937 | + dump_section($file, $section, $contents); | |
| 1985 | 1938 | $section = $section_default; |
| 1986 | 1939 | $contents = ""; |
| 1987 | 1940 | $new_start_line = $.; |
| @@ -1992,7 +1945,7 @@ sub process_file($) { · 4 unmodified lines | ||
| 1992 | 1945 | } elsif ($in_purpose == 1) { |
| 1993 | 1946 | # Continued declaration purpose |
| 1994 | 1947 | chomp($declaration_purpose); |
| 1995 | − $declaration_purpose .= " " . xml_escape($1); | |
| 1948 | + $declaration_purpose .= " " . $1; | |
| 1996 | 1949 | $declaration_purpose =~ s/\s+/ /g; |
| 1997 | 1950 | } else { |
| 1998 | 1951 | my $cont = $1; |
| @@ -2030,7 +1983,7 @@ sub process_file($) { · 31 unmodified lines | ||
| 2030 | 1983 | # Documentation block end */ |
| 2031 | 1984 | } elsif (/$doc_inline_end/) { |
| 2032 | 1985 | if (($contents ne "") && ($contents ne "\n")) { |
| 2033 | − dump_section($file, $section, xml_escape($contents)); | |
| 1986 | + dump_section($file, $section, $contents); | |
| 2034 | 1987 | $section = $section_default; |
| 2035 | 1988 | $contents = ""; |
| 2036 | 1989 | } |
| @@ -2057,7 +2010,7 @@ sub process_file($) { · 20 unmodified lines | ||
| 2057 | 2010 | $contents = $2; |
| 2058 | 2011 | if ($contents ne "") { |
| 2059 | 2012 | $contents .= "\n"; |
| 2060 | − dump_section($file, $section, xml_escape($contents)); | |
| 2013 | + dump_section($file, $section, $contents); | |
| 2061 | 2014 | $section = $section_default; |
| 2062 | 2015 | $contents = ""; |
| 2063 | 2016 | } |
| @@ -2072,7 +2025,7 @@ sub process_file($) { · 8 unmodified lines | ||
| 2072 | 2025 | } elsif ($state == STATE_DOCBLOCK) { |
| 2073 | 2026 | if (/$doc_end/) |
| 2074 | 2027 | { |
| 2075 | − dump_doc_section($file, $section, xml_escape($contents)); | |
| 2028 | + dump_doc_section($file, $section, $contents); | |
| 2076 | 2029 | $section = $section_default; |
| 2077 | 2030 | $contents = ""; |
| 2078 | 2031 | $function = ""; |