Skip to content

Commit f82a8a7

Browse files
mchehabgregkh
authored andcommitted
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>
1 parent 61439c4 commit f82a8a7

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

scripts/get_abi.pl

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,19 @@ sub parse_abi {
147147
parse_error($file, $ln, "'What:' should come first:", $_);
148148
next;
149149
}
150-
if ($tag eq "description") {
151-
# Preserve initial spaces for the first line
150+
if ($new_tag eq "description") {
151+
$sep =~ s,:, ,;
152152
$content = ' ' x length($new_tag) . $sep . $content;
153-
$content =~ s,^(\s*):,$1 ,;
154-
if ($content =~ m/^(\s*)(.*)$/) {
153+
while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
154+
if ($content =~ m/^(\s*)(\S.*)$/) {
155+
# Preserve initial spaces for the first line
155156
$space = $1;
156-
$content = $2;
157+
$content = "$2\n";
158+
$data{$what}->{$tag} .= $content;
159+
} else {
160+
undef($space);
157161
}
158-
while ($space =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
159162

160-
$data{$what}->{$tag} .= "$content\n" if ($content);
161163
} else {
162164
$data{$what}->{$tag} = $content;
163165
}
@@ -174,28 +176,22 @@ sub parse_abi {
174176
if ($tag eq "description") {
175177
my $content = $_;
176178
while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
177-
if (!$data{$what}->{description}) {
179+
if (m/^\s*\n/) {
180+
$data{$what}->{$tag} .= "\n";
181+
next;
182+
}
183+
184+
if (!defined($space)) {
178185
# Preserve initial spaces for the first line
179-
if ($content =~ m/^(\s*)(.*)$/) {
186+
if ($content =~ m/^(\s*)(\S.*)$/) {
180187
$space = $1;
181-
$content = $2;
188+
$content = "$2\n";
182189
}
183-
184-
$data{$what}->{$tag} .= "$content\n" if ($content);
185190
} else {
186-
if (m/^\s*\n/) {
187-
$data{$what}->{$tag} .= $content;
188-
next;
189-
}
190-
191191
$space = "" if (!($content =~ s/^($space)//));
192-
193-
# # Compress spaces with tabs
194-
# $content =~ s<^ {8}> <\t>;
195-
# $content =~ s<^ {1,7}\t> <\t>;
196-
# $content =~ s< {1,7}\t> <\t>;
197-
$data{$what}->{$tag} .= $content;
198192
}
193+
$data{$what}->{$tag} .= $content;
194+
199195
next;
200196
}
201197
if (m/^\s*(.*)/) {

0 commit comments

Comments
 (0)