mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-03-31 07:02:53 +07:00
scripts: get_abi.pl: improve its parser to better catch up indentation
The original parser for indentation were relying on having just one description for each "what". However, that's not the case: there are a number of ABI symbols that got defined multiple times. Improve the parser for it to better handle descriptions if entries are duplicated. Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/eb458bb30be0e5a89192d6057b2e8a7e910dbcb8.1604042072.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
61439c4ada
commit
f82a8a74ea
@ -147,17 +147,19 @@ sub parse_abi {
|
|||||||
parse_error($file, $ln, "'What:' should come first:", $_);
|
parse_error($file, $ln, "'What:' should come first:", $_);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if ($tag eq "description") {
|
if ($new_tag eq "description") {
|
||||||
# Preserve initial spaces for the first line
|
$sep =~ s,:, ,;
|
||||||
$content = ' ' x length($new_tag) . $sep . $content;
|
$content = ' ' x length($new_tag) . $sep . $content;
|
||||||
$content =~ s,^(\s*):,$1 ,;
|
while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
|
||||||
if ($content =~ m/^(\s*)(.*)$/) {
|
if ($content =~ m/^(\s*)(\S.*)$/) {
|
||||||
|
# Preserve initial spaces for the first line
|
||||||
$space = $1;
|
$space = $1;
|
||||||
$content = $2;
|
$content = "$2\n";
|
||||||
|
$data{$what}->{$tag} .= $content;
|
||||||
|
} else {
|
||||||
|
undef($space);
|
||||||
}
|
}
|
||||||
while ($space =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
|
|
||||||
|
|
||||||
$data{$what}->{$tag} .= "$content\n" if ($content);
|
|
||||||
} else {
|
} else {
|
||||||
$data{$what}->{$tag} = $content;
|
$data{$what}->{$tag} = $content;
|
||||||
}
|
}
|
||||||
@ -174,28 +176,22 @@ sub parse_abi {
|
|||||||
if ($tag eq "description") {
|
if ($tag eq "description") {
|
||||||
my $content = $_;
|
my $content = $_;
|
||||||
while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
|
while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
|
||||||
if (!$data{$what}->{description}) {
|
if (m/^\s*\n/) {
|
||||||
# Preserve initial spaces for the first line
|
$data{$what}->{$tag} .= "\n";
|
||||||
if ($content =~ m/^(\s*)(.*)$/) {
|
next;
|
||||||
$space = $1;
|
|
||||||
$content = $2;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data{$what}->{$tag} .= "$content\n" if ($content);
|
|
||||||
} else {
|
|
||||||
if (m/^\s*\n/) {
|
|
||||||
$data{$what}->{$tag} .= $content;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
$space = "" if (!($content =~ s/^($space)//));
|
|
||||||
|
|
||||||
# # Compress spaces with tabs
|
|
||||||
# $content =~ s<^ {8}> <\t>;
|
|
||||||
# $content =~ s<^ {1,7}\t> <\t>;
|
|
||||||
# $content =~ s< {1,7}\t> <\t>;
|
|
||||||
$data{$what}->{$tag} .= $content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!defined($space)) {
|
||||||
|
# Preserve initial spaces for the first line
|
||||||
|
if ($content =~ m/^(\s*)(\S.*)$/) {
|
||||||
|
$space = $1;
|
||||||
|
$content = "$2\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$space = "" if (!($content =~ s/^($space)//));
|
||||||
|
}
|
||||||
|
$data{$what}->{$tag} .= $content;
|
||||||
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (m/^\s*(.*)/) {
|
if (m/^\s*(.*)/) {
|
||||||
|
Loading…
Reference in New Issue
Block a user