diff options
Diffstat (limited to 'scripts/kernel-doc')
| -rwxr-xr-x | scripts/kernel-doc | 116 |
1 files changed, 64 insertions, 52 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index cdb6dc1f6458..d793001929cf 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -5,7 +5,7 @@ use strict; | |||
| 5 | ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## | 5 | ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## |
| 6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## | 6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## |
| 7 | ## Copyright (C) 2001 Simon Huggins ## | 7 | ## Copyright (C) 2001 Simon Huggins ## |
| 8 | ## Copyright (C) 2005-2009 Randy Dunlap ## | 8 | ## Copyright (C) 2005-2010 Randy Dunlap ## |
| 9 | ## ## | 9 | ## ## |
| 10 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## | 10 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## |
| 11 | ## Copyright (c) 2000 MontaVista Software, Inc. ## | 11 | ## Copyright (c) 2000 MontaVista Software, Inc. ## |
| @@ -155,6 +155,8 @@ use strict; | |||
| 155 | # '@parameter' - name of a parameter | 155 | # '@parameter' - name of a parameter |
| 156 | # '%CONST' - name of a constant. | 156 | # '%CONST' - name of a constant. |
| 157 | 157 | ||
| 158 | ## init lots of data | ||
| 159 | |||
| 158 | my $errors = 0; | 160 | my $errors = 0; |
| 159 | my $warnings = 0; | 161 | my $warnings = 0; |
| 160 | my $anon_struct_union = 0; | 162 | my $anon_struct_union = 0; |
| @@ -218,21 +220,14 @@ my %highlights_list = ( $type_constant, "\$1", | |||
| 218 | $type_param, "\$1" ); | 220 | $type_param, "\$1" ); |
| 219 | my $blankline_list = ""; | 221 | my $blankline_list = ""; |
| 220 | 222 | ||
| 221 | sub usage { | ||
| 222 | print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -list ]\n"; | ||
| 223 | print " [ -no-doc-sections ]\n"; | ||
| 224 | print " [ -function funcname [ -function funcname ...] ]\n"; | ||
| 225 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; | ||
| 226 | print " c source file(s) > outputfile\n"; | ||
| 227 | print " -v : verbose output, more warnings & other info listed\n"; | ||
| 228 | exit 1; | ||
| 229 | } | ||
| 230 | |||
| 231 | # read arguments | 223 | # read arguments |
| 232 | if ($#ARGV == -1) { | 224 | if ($#ARGV == -1) { |
| 233 | usage(); | 225 | usage(); |
| 234 | } | 226 | } |
| 235 | 227 | ||
| 228 | my $kernelversion; | ||
| 229 | my $dohighlight = ""; | ||
| 230 | |||
| 236 | my $verbose = 0; | 231 | my $verbose = 0; |
| 237 | my $output_mode = "man"; | 232 | my $output_mode = "man"; |
| 238 | my $no_doc_sections = 0; | 233 | my $no_doc_sections = 0; |
| @@ -245,7 +240,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', | |||
| 245 | 'November', 'December')[(localtime)[4]] . | 240 | 'November', 'December')[(localtime)[4]] . |
| 246 | " " . ((localtime)[5]+1900); | 241 | " " . ((localtime)[5]+1900); |
| 247 | 242 | ||
| 248 | # Essentially these are globals | 243 | # Essentially these are globals. |
| 249 | # They probably want to be tidied up, made more localised or something. | 244 | # They probably want to be tidied up, made more localised or something. |
| 250 | # CAVEAT EMPTOR! Some of the others I localised may not want to be, which | 245 | # CAVEAT EMPTOR! Some of the others I localised may not want to be, which |
| 251 | # could cause "use of undefined value" or other bugs. | 246 | # could cause "use of undefined value" or other bugs. |
| @@ -353,6 +348,18 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
| 353 | } | 348 | } |
| 354 | } | 349 | } |
| 355 | 350 | ||
| 351 | # continue execution near EOF; | ||
| 352 | |||
| 353 | sub usage { | ||
| 354 | print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -list ]\n"; | ||
| 355 | print " [ -no-doc-sections ]\n"; | ||
| 356 | print " [ -function funcname [ -function funcname ...] ]\n"; | ||
| 357 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; | ||
| 358 | print " c source file(s) > outputfile\n"; | ||
| 359 | print " -v : verbose output, more warnings & other info listed\n"; | ||
| 360 | exit 1; | ||
| 361 | } | ||
| 362 | |||
| 356 | # get kernel version from env | 363 | # get kernel version from env |
| 357 | sub get_kernel_version() { | 364 | sub get_kernel_version() { |
| 358 | my $version = 'unknown kernel version'; | 365 | my $version = 'unknown kernel version'; |
| @@ -362,15 +369,6 @@ sub get_kernel_version() { | |||
| 362 | } | 369 | } |
| 363 | return $version; | 370 | return $version; |
| 364 | } | 371 | } |
| 365 | my $kernelversion = get_kernel_version(); | ||
| 366 | |||
| 367 | # generate a sequence of code that will splice in highlighting information | ||
| 368 | # using the s// operator. | ||
| 369 | my $dohighlight = ""; | ||
| 370 | foreach my $pattern (keys %highlights) { | ||
| 371 | # print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n"; | ||
| 372 | $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n"; | ||
| 373 | } | ||
| 374 | 372 | ||
| 375 | ## | 373 | ## |
| 376 | # dumps section contents to arrays/hashes intended for that purpose. | 374 | # dumps section contents to arrays/hashes intended for that purpose. |
| @@ -453,7 +451,7 @@ sub output_highlight { | |||
| 453 | if ($output_mode eq "html" || $output_mode eq "xml") { | 451 | if ($output_mode eq "html" || $output_mode eq "xml") { |
| 454 | $contents = local_unescape($contents); | 452 | $contents = local_unescape($contents); |
| 455 | # convert data read & converted thru xml_escape() into &xyz; format: | 453 | # convert data read & converted thru xml_escape() into &xyz; format: |
| 456 | $contents =~ s/\\\\\\/&/g; | 454 | $contents =~ s/\\\\\\/\&/g; |
| 457 | } | 455 | } |
| 458 | # print STDERR "contents b4:$contents\n"; | 456 | # print STDERR "contents b4:$contents\n"; |
| 459 | eval $dohighlight; | 457 | eval $dohighlight; |
| @@ -770,7 +768,11 @@ sub output_struct_xml(%) { | |||
| 770 | print $args{'type'} . " " . $args{'struct'} . " {\n"; | 768 | print $args{'type'} . " " . $args{'struct'} . " {\n"; |
| 771 | foreach $parameter (@{$args{'parameterlist'}}) { | 769 | foreach $parameter (@{$args{'parameterlist'}}) { |
| 772 | if ($parameter =~ /^#/) { | 770 | if ($parameter =~ /^#/) { |
| 773 | print "$parameter\n"; | 771 | my $prm = $parameter; |
| 772 | # convert data read & converted thru xml_escape() into &xyz; format: | ||
| 773 | # This allows us to have #define macros interspersed in a struct. | ||
| 774 | $prm =~ s/\\\\\\/\&/g; | ||
| 775 | print "$prm\n"; | ||
| 774 | next; | 776 | next; |
| 775 | } | 777 | } |
| 776 | 778 | ||
| @@ -1701,7 +1703,9 @@ sub push_parameter($$$) { | |||
| 1701 | } | 1703 | } |
| 1702 | } | 1704 | } |
| 1703 | 1705 | ||
| 1704 | # strip spaces from $param so that it is one continous string | 1706 | $param = xml_escape($param); |
| 1707 | |||
| 1708 | # strip spaces from $param so that it is one continuous string | ||
| 1705 | # on @parameterlist; | 1709 | # on @parameterlist; |
| 1706 | # this fixes a problem where check_sections() cannot find | 1710 | # this fixes a problem where check_sections() cannot find |
| 1707 | # a parameter like "addr[6 + 2]" because it actually appears | 1711 | # a parameter like "addr[6 + 2]" because it actually appears |
| @@ -1845,34 +1849,6 @@ sub dump_function($$) { | |||
| 1845 | }); | 1849 | }); |
| 1846 | } | 1850 | } |
| 1847 | 1851 | ||
| 1848 | sub process_file($); | ||
| 1849 | |||
| 1850 | # Read the file that maps relative names to absolute names for | ||
| 1851 | # separate source and object directories and for shadow trees. | ||
| 1852 | if (open(SOURCE_MAP, "<.tmp_filelist.txt")) { | ||
| 1853 | my ($relname, $absname); | ||
| 1854 | while(<SOURCE_MAP>) { | ||
| 1855 | chop(); | ||
| 1856 | ($relname, $absname) = (split())[0..1]; | ||
| 1857 | $relname =~ s:^/+::; | ||
| 1858 | $source_map{$relname} = $absname; | ||
| 1859 | } | ||
| 1860 | close(SOURCE_MAP); | ||
| 1861 | } | ||
| 1862 | |||
| 1863 | foreach (@ARGV) { | ||
| 1864 | chomp; | ||
| 1865 | process_file($_); | ||
| 1866 | } | ||
| 1867 | if ($verbose && $errors) { | ||
| 1868 | print STDERR "$errors errors\n"; | ||
| 1869 | } | ||
| 1870 | if ($verbose && $warnings) { | ||
| 1871 | print STDERR "$warnings warnings\n"; | ||
| 1872 | } | ||
| 1873 | |||
| 1874 | exit($errors); | ||
| 1875 | |||
| 1876 | sub reset_state { | 1852 | sub reset_state { |
| 1877 | $function = ""; | 1853 | $function = ""; |
| 1878 | %constants = (); | 1854 | %constants = (); |
| @@ -2279,3 +2255,39 @@ sub process_file($) { | |||
| 2279 | } | 2255 | } |
| 2280 | } | 2256 | } |
| 2281 | } | 2257 | } |
| 2258 | |||
| 2259 | |||
| 2260 | $kernelversion = get_kernel_version(); | ||
| 2261 | |||
| 2262 | # generate a sequence of code that will splice in highlighting information | ||
| 2263 | # using the s// operator. | ||
| 2264 | foreach my $pattern (keys %highlights) { | ||
| 2265 | # print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n"; | ||
| 2266 | $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n"; | ||
| 2267 | } | ||
| 2268 | |||
| 2269 | # Read the file that maps relative names to absolute names for | ||
| 2270 | # separate source and object directories and for shadow trees. | ||
| 2271 | if (open(SOURCE_MAP, "<.tmp_filelist.txt")) { | ||
| 2272 | my ($relname, $absname); | ||
| 2273 | while(<SOURCE_MAP>) { | ||
| 2274 | chop(); | ||
| 2275 | ($relname, $absname) = (split())[0..1]; | ||
| 2276 | $relname =~ s:^/+::; | ||
| 2277 | $source_map{$relname} = $absname; | ||
| 2278 | } | ||
| 2279 | close(SOURCE_MAP); | ||
| 2280 | } | ||
| 2281 | |||
| 2282 | foreach (@ARGV) { | ||
| 2283 | chomp; | ||
| 2284 | process_file($_); | ||
| 2285 | } | ||
| 2286 | if ($verbose && $errors) { | ||
| 2287 | print STDERR "$errors errors\n"; | ||
| 2288 | } | ||
| 2289 | if ($verbose && $warnings) { | ||
| 2290 | print STDERR "$warnings warnings\n"; | ||
| 2291 | } | ||
| 2292 | |||
| 2293 | exit($errors); | ||
