mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 18:11:20 +00:00
docs: kernel-doc: Move STATE_BODY processing to a separate function
Also group the pseudo-global $leading_space variable with its peers. Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
parent
3cac2bc41d
commit
d742f24d6c
1 changed files with 101 additions and 92 deletions
|
@ -336,6 +336,7 @@ use constant {
|
||||||
};
|
};
|
||||||
my $state;
|
my $state;
|
||||||
my $in_doc_sect;
|
my $in_doc_sect;
|
||||||
|
my $leading_space;
|
||||||
|
|
||||||
# Inline documentation state
|
# Inline documentation state
|
||||||
use constant {
|
use constant {
|
||||||
|
@ -1865,35 +1866,13 @@ sub process_name($$) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub process_file($) {
|
|
||||||
my $file;
|
|
||||||
my $func;
|
|
||||||
my $initial_section_counter = $section_counter;
|
|
||||||
my ($orig_file) = @_;
|
|
||||||
my $leading_space;
|
|
||||||
|
|
||||||
$file = map_filename($orig_file);
|
#
|
||||||
|
# STATE_BODY and STATE_BODY_MAYBE: the bulk of a kerneldoc comment.
|
||||||
|
#
|
||||||
|
sub process_body($$) {
|
||||||
|
my $file = shift;
|
||||||
|
|
||||||
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) {
|
|
||||||
if (/$doc_sect/i) { # case insensitive for supported section names
|
if (/$doc_sect/i) { # case insensitive for supported section names
|
||||||
$newsection = $1;
|
$newsection = $1;
|
||||||
$newcontents = $2;
|
$newcontents = $2;
|
||||||
|
@ -1946,7 +1925,6 @@ sub process_file($) {
|
||||||
$prototype = "";
|
$prototype = "";
|
||||||
$state = STATE_PROTO;
|
$state = STATE_PROTO;
|
||||||
$brcount = 0;
|
$brcount = 0;
|
||||||
# print STDERR "end of doc comment, looking for prototype\n";
|
|
||||||
} elsif (/$doc_content/) {
|
} elsif (/$doc_content/) {
|
||||||
# miguel-style comment kludge, look for blank lines after
|
# miguel-style comment kludge, look for blank lines after
|
||||||
# @parameter line to signify start of description
|
# @parameter line to signify start of description
|
||||||
|
@ -1975,7 +1953,6 @@ sub process_file($) {
|
||||||
$leading_space = "";
|
$leading_space = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cont =~ s/^$leading_space//;
|
$cont =~ s/^$leading_space//;
|
||||||
}
|
}
|
||||||
$contents .= $cont . "\n";
|
$contents .= $cont . "\n";
|
||||||
|
@ -1985,6 +1962,38 @@ sub process_file($) {
|
||||||
print STDERR "${file}:$.: warning: bad line: $_";
|
print STDERR "${file}:$.: warning: bad line: $_";
|
||||||
++$warnings;
|
++$warnings;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub process_file($) {
|
||||||
|
my $file;
|
||||||
|
my $func;
|
||||||
|
my $initial_section_counter = $section_counter;
|
||||||
|
my ($orig_file) = @_;
|
||||||
|
|
||||||
|
$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) {
|
||||||
|
process_body($file, $_);
|
||||||
} elsif ($state == STATE_INLINE) { # scanning for inline parameters
|
} elsif ($state == STATE_INLINE) { # scanning for inline parameters
|
||||||
# First line (state 1) needs to be a @parameter
|
# First line (state 1) needs to be a @parameter
|
||||||
if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) {
|
if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue