History

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.

Jonathan Corbet committed 8 years ago

Commit 0bba9241 parent 35277991 file · +9 −56Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kernel-doc+9−56
@@ -553,10 +553,9 @@ sub output_highlight { · 552 unmodified lines
553553 }
554554 if ($line eq ""){
555555 if (! $output_preformatted) {
556− print $lineprefix, local_unescape($blankline);
556+ print $lineprefix, $blankline;
557557 }
558558 } else {
559− $line =~ s/\\\\\\/\&/g;
560559 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
561560 print "\\&$line";
562561 } else {
@@ -751,9 +750,6 @@ sub output_highlight_rst { · 188 unmodified lines
751750 my $contents = join "\n",@_;
752751 my $line;
753752
754− # undo the evil effects of xml_escape() earlier
755− $contents = xml_unescape($contents);
756−
757753 eval $dohighlight;
758754 die $@ if $@;
759755
@@ -1422,8 +1418,6 @@ sub push_parameter($$$$) { · 662 unmodified lines
14221418 }
14231419 }
14241420
1425− $param = xml_escape($param);
1426−
14271421 # strip spaces from $param so that it is one continuous string
14281422 # on @parameterlist;
14291423 # this fixes a problem where check_sections() cannot find
@@ -1748,47 +1742,6 @@ sub process_proto_type($$) { · 318 unmodified lines
17481742 }
17491743 }
17501744
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−}
17921745
17931746 sub map_filename($) {
17941747 my $file;
@@ -1889,7 +1842,7 @@ sub process_file($) { · 94 unmodified lines
18891842 $descr =~ s/^\s*//;
18901843 $descr =~ s/\s*$//;
18911844 $descr =~ s/\s+/ /g;
1892− $declaration_purpose = xml_escape($descr);
1845+ $declaration_purpose = $descr;
18931846 $in_purpose = 1;
18941847 } else {
18951848 $declaration_purpose = "";
@@ -1944,7 +1897,7 @@ sub process_file($) { · 48 unmodified lines
19441897 print STDERR "${file}:$.: warning: contents before sections\n";
19451898 ++$warnings;
19461899 }
1947− dump_section($file, $section, xml_escape($contents));
1900+ dump_section($file, $section, $contents);
19481901 $section = $section_default;
19491902 }
19501903
@@ -1962,7 +1915,7 @@ sub process_file($) { · 11 unmodified lines
19621915 $leading_space = undef;
19631916 } elsif (/$doc_end/) {
19641917 if (($contents ne "") && ($contents ne "\n")) {
1965− dump_section($file, $section, xml_escape($contents));
1918+ dump_section($file, $section, $contents);
19661919 $section = $section_default;
19671920 $contents = "";
19681921 }
@@ -1981,7 +1934,7 @@ sub process_file($) { · 12 unmodified lines
19811934 # @parameter line to signify start of description
19821935 if ($1 eq "") {
19831936 if ($section =~ m/^@/ || $section eq $section_context) {
1984− dump_section($file, $section, xml_escape($contents));
1937+ dump_section($file, $section, $contents);
19851938 $section = $section_default;
19861939 $contents = "";
19871940 $new_start_line = $.;
@@ -1992,7 +1945,7 @@ sub process_file($) { · 4 unmodified lines
19921945 } elsif ($in_purpose == 1) {
19931946 # Continued declaration purpose
19941947 chomp($declaration_purpose);
1995− $declaration_purpose .= " " . xml_escape($1);
1948+ $declaration_purpose .= " " . $1;
19961949 $declaration_purpose =~ s/\s+/ /g;
19971950 } else {
19981951 my $cont = $1;
@@ -2030,7 +1983,7 @@ sub process_file($) { · 31 unmodified lines
20301983 # Documentation block end */
20311984 } elsif (/$doc_inline_end/) {
20321985 if (($contents ne "") && ($contents ne "\n")) {
2033− dump_section($file, $section, xml_escape($contents));
1986+ dump_section($file, $section, $contents);
20341987 $section = $section_default;
20351988 $contents = "";
20361989 }
@@ -2057,7 +2010,7 @@ sub process_file($) { · 20 unmodified lines
20572010 $contents = $2;
20582011 if ($contents ne "") {
20592012 $contents .= "\n";
2060− dump_section($file, $section, xml_escape($contents));
2013+ dump_section($file, $section, $contents);
20612014 $section = $section_default;
20622015 $contents = "";
20632016 }
@@ -2072,7 +2025,7 @@ sub process_file($) { · 8 unmodified lines
20722025 } elsif ($state == STATE_DOCBLOCK) {
20732026 if (/$doc_end/)
20742027 {
2075− dump_doc_section($file, $section, xml_escape($contents));
2028+ dump_doc_section($file, $section, $contents);
20762029 $section = $section_default;
20772030 $contents = "";
20782031 $function = "";