Commit 3cac2bc4 authored by Jonathan Corbet's avatar Jonathan Corbet

docs: kernel-doc: Move STATE_NAME processing into its own function

Move this code out of process_file() in the name of readability and
maintainability.
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 07048d13
...@@ -1793,37 +1793,14 @@ sub process_normal() { ...@@ -1793,37 +1793,14 @@ sub process_normal() {
} }
} }
#
# STATE_NAME: Looking for the "name - description" line
sub process_file($) { #
my $file; sub process_name($$) {
my $file = shift;
my $identifier; my $identifier;
my $func;
my $descr; my $descr;
my $initial_section_counter = $section_counter;
my ($orig_file) = @_;
my $leading_space;
$file = map_filename($orig_file);
if (!open(IN,"<$file")) {
print STDERR "Error: Cannot open file $file\n";
++$errors;
return;
}
$. = 1;
$section_counter = 0;
while (<IN>) {
while (s/\\\s*$//) {
$_ .= <IN>;
}
# Replace tabs by spaces
while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
if ($state == STATE_NORMAL) {
process_normal();
} elsif ($state == STATE_NAME) {# this line is the function name (always)
if (/$doc_block/o) { if (/$doc_block/o) {
$state = STATE_DOCBLOCK; $state = STATE_DOCBLOCK;
$contents = ""; $contents = "";
...@@ -1886,6 +1863,36 @@ sub process_file($) { ...@@ -1886,6 +1863,36 @@ sub process_file($) {
++$warnings; ++$warnings;
$state = STATE_NORMAL; $state = STATE_NORMAL;
} }
}
sub process_file($) {
my $file;
my $func;
my $initial_section_counter = $section_counter;
my ($orig_file) = @_;
my $leading_space;
$file = map_filename($orig_file);
if (!open(IN,"<$file")) {
print STDERR "Error: Cannot open file $file\n";
++$errors;
return;
}
$. = 1;
$section_counter = 0;
while (<IN>) {
while (s/\\\s*$//) {
$_ .= <IN>;
}
# Replace tabs by spaces
while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
if ($state == STATE_NORMAL) {
process_normal();
} elsif ($state == STATE_NAME) {
process_name($file, $_);
} elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) {
if (/$doc_sect/i) { # case insensitive for supported section names if (/$doc_sect/i) { # case insensitive for supported section names
$newsection = $1; $newsection = $1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment