Skip to content

Commit e9bca89

Browse files
mchehabgregkh
authored andcommitted
scripts: get_abi.pl: fix parsing on ReST mode
When the source ABI file is using ReST notation, the script should handle whitespaces and lines with care, as otherwise the file won't be properly recognized. Address the bugs that are on such part of the script. Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/5c22c54fbd0cda797b691d52c568be6d0d1079d8.1604042072.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 11ce90a commit e9bca89

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

scripts/get_abi.pl

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ sub parse_abi {
151151
$content = $2;
152152
}
153153
while ($space =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
154-
$data{$what}->{$tag} .= $content;
154+
155+
$data{$what}->{$tag} .= "$content\n" if ($content);
155156
} else {
156157
$data{$what}->{$tag} = $content;
157158
}
@@ -166,31 +167,28 @@ sub parse_abi {
166167
}
167168

168169
if ($tag eq "description") {
170+
my $content = $_;
171+
while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
169172
if (!$data{$what}->{description}) {
170-
s/^($space)//;
171-
if (m/^(\s*)(.*)/) {
172-
my $sp = $1;
173-
while ($sp =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
174-
my $content = "$sp$2";
175-
176-
$content =~ s/^($space)//;
177-
178-
$data{$what}->{$tag} .= "$content";
173+
# Preserve initial spaces for the first line
174+
if ($content =~ m/^(\s*)(.*)$/) {
175+
$space = $1;
176+
$content = $2;
179177
}
178+
179+
$data{$what}->{$tag} .= "$content\n" if ($content);
180180
} else {
181-
my $content = $_;
182181
if (m/^\s*\n/) {
183182
$data{$what}->{$tag} .= $content;
184183
next;
185184
}
186185

187-
while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
188186
$space = "" if (!($content =~ s/^($space)//));
189187

190-
# Compress spaces with tabs
191-
$content =~ s<^ {8}> <\t>;
192-
$content =~ s<^ {1,7}\t> <\t>;
193-
$content =~ s< {1,7}\t> <\t>;
188+
# # Compress spaces with tabs
189+
# $content =~ s<^ {8}> <\t>;
190+
# $content =~ s<^ {1,7}\t> <\t>;
191+
# $content =~ s< {1,7}\t> <\t>;
194192
$data{$what}->{$tag} .= $content;
195193
}
196194
next;

0 commit comments

Comments
 (0)