kernel-doc (b981d8b3f5e008ff10d993be633ad00564fc22cd) | kernel-doc (6b5b55f6c404fa730a09a8254eb19f5a038afcc2) |
---|---|
1#!/usr/bin/perl -w 2 3use strict; 4 5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 7## Copyright (C) 2001 Simon Huggins ## | 1#!/usr/bin/perl -w 2 3use strict; 4 5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 7## Copyright (C) 2001 Simon Huggins ## |
8## Copyright (C) 2005-2007 Randy Dunlap ## |
|
8## ## 9## #define enhancements by Armin Kuster <akuster@mvista.com> ## 10## Copyright (c) 2000 MontaVista Software, Inc. ## 11## ## 12## This software falls under the GNU General Public License. ## 13## Please read the COPYING file for more information ## 14 15# w.o. 03-11-2000: added the '-filelist' option. --- 140 unchanged lines hidden (view full) --- 156my $warnings = 0; 157my $anon_struct_union = 0; 158 159# match expressions used to find embedded type information 160my $type_constant = '\%([-_\w]+)'; 161my $type_func = '(\w+)\(\)'; 162my $type_param = '\@(\w+)'; 163my $type_struct = '\&((struct\s*)*[_\w]+)'; | 9## ## 10## #define enhancements by Armin Kuster <akuster@mvista.com> ## 11## Copyright (c) 2000 MontaVista Software, Inc. ## 12## ## 13## This software falls under the GNU General Public License. ## 14## Please read the COPYING file for more information ## 15 16# w.o. 03-11-2000: added the '-filelist' option. --- 140 unchanged lines hidden (view full) --- 157my $warnings = 0; 158my $anon_struct_union = 0; 159 160# match expressions used to find embedded type information 161my $type_constant = '\%([-_\w]+)'; 162my $type_func = '(\w+)\(\)'; 163my $type_param = '\@(\w+)'; 164my $type_struct = '\&((struct\s*)*[_\w]+)'; |
164my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)'; | 165my $type_struct_xml = '\\&((struct\s*)*[_\w]+)'; |
165my $type_env = '(\$\w+)'; 166 167# Output conversion substitutions. 168# One for each output format 169 170# these work fairly well 171my %highlights_html = ( $type_constant, "<i>\$1</i>", 172 $type_func, "<b>\$1</b>", 173 $type_struct_xml, "<i>\$1</i>", 174 $type_env, "<b><i>\$1</i></b>", 175 $type_param, "<tt><b>\$1</b></tt>" ); | 166my $type_env = '(\$\w+)'; 167 168# Output conversion substitutions. 169# One for each output format 170 171# these work fairly well 172my %highlights_html = ( $type_constant, "<i>\$1</i>", 173 $type_func, "<b>\$1</b>", 174 $type_struct_xml, "<i>\$1</i>", 175 $type_env, "<b><i>\$1</i></b>", 176 $type_param, "<tt><b>\$1</b></tt>" ); |
176my $blankline_html = "<p>"; | 177my $local_lt = "\\\\\\\\lt:"; 178my $local_gt = "\\\\\\\\gt:"; 179my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" |
177 178# XML, docbook format 179my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", 180 $type_constant, "<constant>\$1</constant>", 181 $type_func, "<function>\$1</function>", 182 $type_struct, "<structname>\$1</structname>", 183 $type_env, "<envar>\$1</envar>", 184 $type_param, "<parameter>\$1</parameter>" ); --- 201 unchanged lines hidden (view full) --- 386 my $line; 387 388# DEBUG 389# if (!defined $contents) { 390# use Carp; 391# confess "output_highlight got called with no args?\n"; 392# } 393 | 180 181# XML, docbook format 182my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", 183 $type_constant, "<constant>\$1</constant>", 184 $type_func, "<function>\$1</function>", 185 $type_struct, "<structname>\$1</structname>", 186 $type_env, "<envar>\$1</envar>", 187 $type_param, "<parameter>\$1</parameter>" ); --- 201 unchanged lines hidden (view full) --- 389 my $line; 390 391# DEBUG 392# if (!defined $contents) { 393# use Carp; 394# confess "output_highlight got called with no args?\n"; 395# } 396 |
397 if ($output_mode eq "html") { 398 $contents = local_unescape($contents); 399 # convert data read & converted thru xml_escape() into &xyz; format: 400 $contents =~ s/\\\\\\/&/g; 401 } |
|
394# print STDERR "contents b4:$contents\n"; 395 eval $dohighlight; 396 die $@ if $@; | 402# print STDERR "contents b4:$contents\n"; 403 eval $dohighlight; 404 die $@ if $@; |
397 if ($output_mode eq "html") { 398 $contents =~ s/\\\\//; 399 } | |
400# print STDERR "contents af:$contents\n"; 401 402 foreach $line (split "\n", $contents) { 403 if ($line eq ""){ | 405# print STDERR "contents af:$contents\n"; 406 407 foreach $line (split "\n", $contents) { 408 if ($line eq ""){ |
404 print $lineprefix, $blankline; | 409 print $lineprefix, local_unescape($blankline); |
405 } else { 406 $line =~ s/\\\\\\/\&/g; 407 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { 408 print "\\&$line"; 409 } else { 410 print $lineprefix, $line; 411 } 412 } --- 1334 unchanged lines hidden (view full) --- 1747 $x = $3; 1748 } else { 1749 $prototype .= $x; 1750 last; 1751 } 1752 } 1753} 1754 | 410 } else { 411 $line =~ s/\\\\\\/\&/g; 412 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { 413 print "\\&$line"; 414 } else { 415 print $lineprefix, $line; 416 } 417 } --- 1334 unchanged lines hidden (view full) --- 1752 $x = $3; 1753 } else { 1754 $prototype .= $x; 1755 last; 1756 } 1757 } 1758} 1759 |
1755# replace <, >, and & | 1760# xml_escape: replace <, >, and & in the text stream; 1761# 1762# however, formatting controls that are generated internally/locally in the 1763# kernel-doc script are not escaped here; instead, they begin life like 1764# $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings 1765# are converted to their mnemonic-expected output, without the 4 * '\' & ':', 1766# just before actual output; (this is done by local_unescape()) |
1756sub xml_escape($) { 1757 my $text = shift; 1758 if (($output_mode eq "text") || ($output_mode eq "man")) { 1759 return $text; 1760 } 1761 $text =~ s/\&/\\\\\\amp;/g; 1762 $text =~ s/\</\\\\\\lt;/g; 1763 $text =~ s/\>/\\\\\\gt;/g; 1764 return $text; 1765} 1766 | 1767sub xml_escape($) { 1768 my $text = shift; 1769 if (($output_mode eq "text") || ($output_mode eq "man")) { 1770 return $text; 1771 } 1772 $text =~ s/\&/\\\\\\amp;/g; 1773 $text =~ s/\</\\\\\\lt;/g; 1774 $text =~ s/\>/\\\\\\gt;/g; 1775 return $text; 1776} 1777 |
1778# convert local escape strings to html 1779# local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) 1780sub local_unescape($) { 1781 my $text = shift; 1782 if (($output_mode eq "text") || ($output_mode eq "man")) { 1783 return $text; 1784 } 1785 $text =~ s/\\\\\\\\lt:/</g; 1786 $text =~ s/\\\\\\\\gt:/>/g; 1787 return $text; 1788} 1789 |
|
1767sub process_file($) { 1768 my $file; 1769 my $identifier; 1770 my $func; 1771 my $descr; 1772 my $initial_section_counter = $section_counter; 1773 1774 if (defined($ENV{'SRCTREE'})) { --- 123 unchanged lines hidden (view full) --- 1898 if ($decl_type eq 'function') { 1899 process_state3_function($_, $file); 1900 } else { 1901 process_state3_type($_, $file); 1902 } 1903 } elsif ($state == 4) { 1904 # Documentation block 1905 if (/$doc_block/) { | 1790sub process_file($) { 1791 my $file; 1792 my $identifier; 1793 my $func; 1794 my $descr; 1795 my $initial_section_counter = $section_counter; 1796 1797 if (defined($ENV{'SRCTREE'})) { --- 123 unchanged lines hidden (view full) --- 1921 if ($decl_type eq 'function') { 1922 process_state3_function($_, $file); 1923 } else { 1924 process_state3_type($_, $file); 1925 } 1926 } elsif ($state == 4) { 1927 # Documentation block 1928 if (/$doc_block/) { |
1906 dump_section($section, $contents); | 1929 dump_section($section, xml_escape($contents)); |
1907 output_intro({'sectionlist' => \@sectionlist, 1908 'sections' => \%sections }); 1909 $contents = ""; 1910 $function = ""; 1911 %constants = (); 1912 %parameterdescs = (); 1913 %parametertypes = (); 1914 @parameterlist = (); 1915 %sections = (); 1916 @sectionlist = (); 1917 $prototype = ""; 1918 if ( $1 eq "" ) { 1919 $section = $section_intro; 1920 } else { 1921 $section = $1; 1922 } 1923 } 1924 elsif (/$doc_end/) 1925 { | 1930 output_intro({'sectionlist' => \@sectionlist, 1931 'sections' => \%sections }); 1932 $contents = ""; 1933 $function = ""; 1934 %constants = (); 1935 %parameterdescs = (); 1936 %parametertypes = (); 1937 @parameterlist = (); 1938 %sections = (); 1939 @sectionlist = (); 1940 $prototype = ""; 1941 if ( $1 eq "" ) { 1942 $section = $section_intro; 1943 } else { 1944 $section = $1; 1945 } 1946 } 1947 elsif (/$doc_end/) 1948 { |
1926 dump_section($section, $contents); | 1949 dump_section($section, xml_escape($contents)); |
1927 output_intro({'sectionlist' => \@sectionlist, 1928 'sections' => \%sections }); 1929 $contents = ""; 1930 $function = ""; 1931 %constants = (); 1932 %parameterdescs = (); 1933 %parametertypes = (); 1934 @parameterlist = (); --- 50 unchanged lines hidden --- | 1950 output_intro({'sectionlist' => \@sectionlist, 1951 'sections' => \%sections }); 1952 $contents = ""; 1953 $function = ""; 1954 %constants = (); 1955 %parameterdescs = (); 1956 %parametertypes = (); 1957 @parameterlist = (); --- 50 unchanged lines hidden --- |