kernel-doc (cc794812eba917f271c6a09ac4cb1750497e404c) | kernel-doc (c17add56ca4ee618b07ed9a21e2a29f0a90dc0ba) |
---|---|
1#!/usr/bin/env perl 2 3use warnings; 4use strict; 5 6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 8## Copyright (C) 2001 Simon Huggins ## --- 1976 unchanged lines hidden (view full) --- 1985 $inline_doc_state = STATE_INLINE_NAME; 1986 } elsif ($decl_type eq 'function') { 1987 process_proto_function($_, $file); 1988 } else { 1989 process_proto_type($_, $file); 1990 } 1991} 1992 | 1#!/usr/bin/env perl 2 3use warnings; 4use strict; 5 6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 8## Copyright (C) 2001 Simon Huggins ## --- 1976 unchanged lines hidden (view full) --- 1985 $inline_doc_state = STATE_INLINE_NAME; 1986 } elsif ($decl_type eq 'function') { 1987 process_proto_function($_, $file); 1988 } else { 1989 process_proto_type($_, $file); 1990 } 1991} 1992 |
1993# 1994# STATE_DOCBLOCK: within a DOC: block. 1995# 1996sub process_docblock($$) { 1997 my $file = shift; |
|
1993 | 1998 |
1999 if (/$doc_end/) { 2000 dump_doc_section($file, $section, $contents); 2001 $section = $section_default; 2002 $contents = ""; 2003 $function = ""; 2004 %parameterdescs = (); 2005 %parametertypes = (); 2006 @parameterlist = (); 2007 %sections = (); 2008 @sectionlist = (); 2009 $prototype = ""; 2010 $state = STATE_NORMAL; 2011 } elsif (/$doc_content/) { 2012 if ( $1 eq "" ) { 2013 $contents .= $blankline; 2014 } else { 2015 $contents .= $1 . "\n"; 2016 } 2017 } 2018} 2019 2020# 2021# STATE_INLINE: docbook comments within a prototype. 2022# 2023sub process_inline($$) { 2024 my $file = shift; 2025 2026 # First line (state 1) needs to be a @parameter 2027 if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) { 2028 $section = $1; 2029 $contents = $2; 2030 $new_start_line = $.; 2031 if ($contents ne "") { 2032 while (substr($contents, 0, 1) eq " ") { 2033 $contents = substr($contents, 1); 2034 } 2035 $contents .= "\n"; 2036 } 2037 $inline_doc_state = STATE_INLINE_TEXT; 2038 # Documentation block end */ 2039 } elsif (/$doc_inline_end/) { 2040 if (($contents ne "") && ($contents ne "\n")) { 2041 dump_section($file, $section, $contents); 2042 $section = $section_default; 2043 $contents = ""; 2044 } 2045 $state = STATE_PROTO; 2046 $inline_doc_state = STATE_INLINE_NA; 2047 # Regular text 2048 } elsif (/$doc_content/) { 2049 if ($inline_doc_state == STATE_INLINE_TEXT) { 2050 $contents .= $1 . "\n"; 2051 # nuke leading blank lines 2052 if ($contents =~ /^\s*$/) { 2053 $contents = ""; 2054 } 2055 } elsif ($inline_doc_state == STATE_INLINE_NAME) { 2056 $inline_doc_state = STATE_INLINE_ERROR; 2057 print STDERR "${file}:$.: warning: "; 2058 print STDERR "Incorrect use of kernel-doc format: $_"; 2059 ++$warnings; 2060 } 2061 } 2062} 2063 2064 |
|
1994sub process_file($) { 1995 my $file; | 2065sub process_file($) { 2066 my $file; |
1996 my $func; | |
1997 my $initial_section_counter = $section_counter; 1998 my ($orig_file) = @_; 1999 2000 $file = map_filename($orig_file); 2001 2002 if (!open(IN,"<$file")) { 2003 print STDERR "Error: Cannot open file $file\n"; 2004 ++$errors; --- 4 unchanged lines hidden (view full) --- 2009 2010 $section_counter = 0; 2011 while (<IN>) { 2012 while (s/\\\s*$//) { 2013 $_ .= <IN>; 2014 } 2015 # Replace tabs by spaces 2016 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; | 2067 my $initial_section_counter = $section_counter; 2068 my ($orig_file) = @_; 2069 2070 $file = map_filename($orig_file); 2071 2072 if (!open(IN,"<$file")) { 2073 print STDERR "Error: Cannot open file $file\n"; 2074 ++$errors; --- 4 unchanged lines hidden (view full) --- 2079 2080 $section_counter = 0; 2081 while (<IN>) { 2082 while (s/\\\s*$//) { 2083 $_ .= <IN>; 2084 } 2085 # Replace tabs by spaces 2086 while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; |
2087 2088 # Hand this line to the appropriate state handler |
|
2017 if ($state == STATE_NORMAL) { 2018 process_normal(); 2019 } elsif ($state == STATE_NAME) { 2020 process_name($file, $_); 2021 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { 2022 process_body($file, $_); 2023 } elsif ($state == STATE_INLINE) { # scanning for inline parameters | 2089 if ($state == STATE_NORMAL) { 2090 process_normal(); 2091 } elsif ($state == STATE_NAME) { 2092 process_name($file, $_); 2093 } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { 2094 process_body($file, $_); 2095 } elsif ($state == STATE_INLINE) { # scanning for inline parameters |
2024 # First line (state 1) needs to be a @parameter 2025 if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) { 2026 $section = $1; 2027 $contents = $2; 2028 $new_start_line = $.; 2029 if ($contents ne "") { 2030 while (substr($contents, 0, 1) eq " ") { 2031 $contents = substr($contents, 1); 2032 } 2033 $contents .= "\n"; 2034 } 2035 $inline_doc_state = STATE_INLINE_TEXT; 2036 # Documentation block end */ 2037 } elsif (/$doc_inline_end/) { 2038 if (($contents ne "") && ($contents ne "\n")) { 2039 dump_section($file, $section, $contents); 2040 $section = $section_default; 2041 $contents = ""; 2042 } 2043 $state = STATE_PROTO; 2044 $inline_doc_state = STATE_INLINE_NA; 2045 # Regular text 2046 } elsif (/$doc_content/) { 2047 if ($inline_doc_state == STATE_INLINE_TEXT) { 2048 $contents .= $1 . "\n"; 2049 # nuke leading blank lines 2050 if ($contents =~ /^\s*$/) { 2051 $contents = ""; 2052 } 2053 } elsif ($inline_doc_state == STATE_INLINE_NAME) { 2054 $inline_doc_state = STATE_INLINE_ERROR; 2055 print STDERR "${file}:$.: warning: "; 2056 print STDERR "Incorrect use of kernel-doc format: $_"; 2057 ++$warnings; 2058 } 2059 } | 2096 process_inline($file, $_); |
2060 } elsif ($state == STATE_PROTO) { 2061 process_proto($file, $_); 2062 } elsif ($state == STATE_DOCBLOCK) { | 2097 } elsif ($state == STATE_PROTO) { 2098 process_proto($file, $_); 2099 } elsif ($state == STATE_DOCBLOCK) { |
2063 if (/$doc_end/) 2064 { 2065 dump_doc_section($file, $section, $contents); 2066 $section = $section_default; 2067 $contents = ""; 2068 $function = ""; 2069 %parameterdescs = (); 2070 %parametertypes = (); 2071 @parameterlist = (); 2072 %sections = (); 2073 @sectionlist = (); 2074 $prototype = ""; 2075 $state = STATE_NORMAL; 2076 } 2077 elsif (/$doc_content/) 2078 { 2079 if ( $1 eq "" ) 2080 { 2081 $contents .= $blankline; 2082 } 2083 else 2084 { 2085 $contents .= $1 . "\n"; 2086 } 2087 } | 2100 process_docblock($file, $_); |
2088 } 2089 } | 2101 } 2102 } |
2103 2104 # Make sure we got something interesting. |
|
2090 if ($initial_section_counter == $section_counter) { 2091 if ($output_mode ne "none") { 2092 print STDERR "${file}:1: warning: no structured comments found\n"; 2093 } 2094 if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) { 2095 print STDERR " Was looking for '$_'.\n" for keys %function_table; 2096 } 2097 } --- 50 unchanged lines hidden --- | 2105 if ($initial_section_counter == $section_counter) { 2106 if ($output_mode ne "none") { 2107 print STDERR "${file}:1: warning: no structured comments found\n"; 2108 } 2109 if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) { 2110 print STDERR " Was looking for '$_'.\n" for keys %function_table; 2111 } 2112 } --- 50 unchanged lines hidden --- |