kernel-doc (bc030d6cb9532877c1c5a3f5e7123344fa24a285) | kernel-doc (8484baaa5065b460e5eb18ee721d8417251f7897) |
---|---|
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-2010 Randy Dunlap ## --- 141 unchanged lines hidden (view full) --- 150# patterns, which are highlighted appropriately. 151# 152# 'funcname()' - function 153# '$ENVVAR' - environmental variable 154# '&struct_name' - name of a structure (up to two words including 'struct') 155# '@parameter' - name of a parameter 156# '%CONST' - name of a constant. 157 | 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-2010 Randy Dunlap ## --- 141 unchanged lines hidden (view full) --- 150# patterns, which are highlighted appropriately. 151# 152# 'funcname()' - function 153# '$ENVVAR' - environmental variable 154# '&struct_name' - name of a structure (up to two words including 'struct') 155# '@parameter' - name of a parameter 156# '%CONST' - name of a constant. 157 |
158## init lots of data 159 |
|
158my $errors = 0; 159my $warnings = 0; 160my $anon_struct_union = 0; 161 162# match expressions used to find embedded type information 163my $type_constant = '\%([-_\w]+)'; 164my $type_func = '(\w+)\(\)'; 165my $type_param = '\@(\w+)'; --- 47 unchanged lines hidden (view full) --- 213 214# list mode 215my %highlights_list = ( $type_constant, "\$1", 216 $type_func, "\$1", 217 $type_struct, "\$1", 218 $type_param, "\$1" ); 219my $blankline_list = ""; 220 | 160my $errors = 0; 161my $warnings = 0; 162my $anon_struct_union = 0; 163 164# match expressions used to find embedded type information 165my $type_constant = '\%([-_\w]+)'; 166my $type_func = '(\w+)\(\)'; 167my $type_param = '\@(\w+)'; --- 47 unchanged lines hidden (view full) --- 215 216# list mode 217my %highlights_list = ( $type_constant, "\$1", 218 $type_func, "\$1", 219 $type_struct, "\$1", 220 $type_param, "\$1" ); 221my $blankline_list = ""; 222 |
221sub 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 232if ($#ARGV == -1) { 233 usage(); 234} 235 | 223# read arguments 224if ($#ARGV == -1) { 225 usage(); 226} 227 |
228my $kernelversion; 229my $dohighlight = ""; 230 |
|
236my $verbose = 0; 237my $output_mode = "man"; 238my $no_doc_sections = 0; 239my %highlights = %highlights_man; 240my $blankline = $blankline_man; 241my $modulename = "Kernel API"; 242my $function_only = 0; 243my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', 244 'July', 'August', 'September', 'October', 245 'November', 'December')[(localtime)[4]] . 246 " " . ((localtime)[5]+1900); 247 | 231my $verbose = 0; 232my $output_mode = "man"; 233my $no_doc_sections = 0; 234my %highlights = %highlights_man; 235my $blankline = $blankline_man; 236my $modulename = "Kernel API"; 237my $function_only = 0; 238my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', 239 'July', 'August', 'September', 'October', 240 'November', 'December')[(localtime)[4]] . 241 " " . ((localtime)[5]+1900); 242 |
248# Essentially these are globals | 243# Essentially these are globals. |
249# 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 251# could cause "use of undefined value" or other bugs. 252my ($function, %function_table, %parametertypes, $declaration_purpose); 253my ($type, $declaration_name, $return_type); 254my ($newsection, $newcontents, $prototype, $brcount, %source_map); 255 256if (defined($ENV{'KBUILD_VERBOSE'})) { --- 91 unchanged lines hidden (view full) --- 348 $verbose = 1; 349 } elsif (($cmd eq "-h") || ($cmd eq "--help")) { 350 usage(); 351 } elsif ($cmd eq '-no-doc-sections') { 352 $no_doc_sections = 1; 353 } 354} 355 | 244# They probably want to be tidied up, made more localised or something. 245# CAVEAT EMPTOR! Some of the others I localised may not want to be, which 246# could cause "use of undefined value" or other bugs. 247my ($function, %function_table, %parametertypes, $declaration_purpose); 248my ($type, $declaration_name, $return_type); 249my ($newsection, $newcontents, $prototype, $brcount, %source_map); 250 251if (defined($ENV{'KBUILD_VERBOSE'})) { --- 91 unchanged lines hidden (view full) --- 343 $verbose = 1; 344 } elsif (($cmd eq "-h") || ($cmd eq "--help")) { 345 usage(); 346 } elsif ($cmd eq '-no-doc-sections') { 347 $no_doc_sections = 1; 348 } 349} 350 |
351# continue execution near EOF; 352 353sub 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 357sub get_kernel_version() { 358 my $version = 'unknown kernel version'; 359 360 if (defined($ENV{'KERNELVERSION'})) { 361 $version = $ENV{'KERNELVERSION'}; 362 } 363 return $version; 364} | 363# get kernel version from env 364sub get_kernel_version() { 365 my $version = 'unknown kernel version'; 366 367 if (defined($ENV{'KERNELVERSION'})) { 368 $version = $ENV{'KERNELVERSION'}; 369 } 370 return $version; 371} |
365my $kernelversion = get_kernel_version(); | |
366 | 372 |
367# generate a sequence of code that will splice in highlighting information 368# using the s// operator. 369my $dohighlight = ""; 370foreach 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 | |
375## 376# dumps section contents to arrays/hashes intended for that purpose. 377# 378sub dump_section { 379 my $file = shift; 380 my $name = shift; 381 my $contents = join "\n", @_; 382 --- 1463 unchanged lines hidden (view full) --- 1846 'parameterdescs' => \%parameterdescs, 1847 'parametertypes' => \%parametertypes, 1848 'sectionlist' => \@sectionlist, 1849 'sections' => \%sections, 1850 'purpose' => $declaration_purpose 1851 }); 1852} 1853 | 373## 374# dumps section contents to arrays/hashes intended for that purpose. 375# 376sub dump_section { 377 my $file = shift; 378 my $name = shift; 379 my $contents = join "\n", @_; 380 --- 1463 unchanged lines hidden (view full) --- 1844 'parameterdescs' => \%parameterdescs, 1845 'parametertypes' => \%parametertypes, 1846 'sectionlist' => \@sectionlist, 1847 'sections' => \%sections, 1848 'purpose' => $declaration_purpose 1849 }); 1850} 1851 |
1854sub process_file($); 1855 1856# Read the file that maps relative names to absolute names for 1857# separate source and object directories and for shadow trees. 1858if (open(SOURCE_MAP, "<.tmp_filelist.txt")) { 1859 my ($relname, $absname); 1860 while(<SOURCE_MAP>) { 1861 chop(); 1862 ($relname, $absname) = (split())[0..1]; 1863 $relname =~ s:^/+::; 1864 $source_map{$relname} = $absname; 1865 } 1866 close(SOURCE_MAP); 1867} 1868 1869foreach (@ARGV) { 1870 chomp; 1871 process_file($_); 1872} 1873if ($verbose && $errors) { 1874 print STDERR "$errors errors\n"; 1875} 1876if ($verbose && $warnings) { 1877 print STDERR "$warnings warnings\n"; 1878} 1879 1880exit($errors); 1881 | |
1882sub reset_state { 1883 $function = ""; 1884 %constants = (); 1885 %parameterdescs = (); 1886 %parametertypes = (); 1887 @parameterlist = (); 1888 %sections = (); 1889 @sectionlist = (); --- 390 unchanged lines hidden (view full) --- 2280 print " generation to continue.\n"; 2281 print " </para>\n"; 2282 print " </warning>\n"; 2283 print " </refsect1>\n"; 2284 print "</refentry>\n"; 2285 } 2286 } 2287} | 1852sub reset_state { 1853 $function = ""; 1854 %constants = (); 1855 %parameterdescs = (); 1856 %parametertypes = (); 1857 @parameterlist = (); 1858 %sections = (); 1859 @sectionlist = (); --- 390 unchanged lines hidden (view full) --- 2250 print " generation to continue.\n"; 2251 print " </para>\n"; 2252 print " </warning>\n"; 2253 print " </refsect1>\n"; 2254 print "</refentry>\n"; 2255 } 2256 } 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. 2264foreach 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. 2271if (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 2282foreach (@ARGV) { 2283 chomp; 2284 process_file($_); 2285} 2286if ($verbose && $errors) { 2287 print STDERR "$errors errors\n"; 2288} 2289if ($verbose && $warnings) { 2290 print STDERR "$warnings warnings\n"; 2291} 2292 2293exit($errors); |
|