]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
scripts: get_abi.pl: fix parsing on ReST mode
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 30 Oct 2020 07:40:21 +0000 (08:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Oct 2020 12:02:25 +0000 (13:02 +0100)
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>
scripts/get_abi.pl

index 107672cdacb35c01714e3487609423092f247838..0c403af86fd5b9ccf275b07d0cbe7428e1146bdb 100755 (executable)
@@ -151,7 +151,8 @@ sub parse_abi {
                                                $content = $2;
                                        }
                                        while ($space =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
-                                       $data{$what}->{$tag} .= $content;
+
+                                       $data{$what}->{$tag} .= "$content\n" if ($content);
                                } else {
                                        $data{$what}->{$tag} = $content;
                                }
@@ -166,31 +167,28 @@ sub parse_abi {
                }
 
                if ($tag eq "description") {
+                       my $content = $_;
+                       while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
                        if (!$data{$what}->{description}) {
-                               s/^($space)//;
-                               if (m/^(\s*)(.*)/) {
-                                       my $sp = $1;
-                                       while ($sp =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
-                                       my $content = "$sp$2";
-
-                                       $content =~ s/^($space)//;
-
-                                       $data{$what}->{$tag} .= "$content";
+                               # Preserve initial spaces for the first line
+                               if ($content =~ m/^(\s*)(.*)$/) {
+                                       $space = $1;
+                                       $content = $2;
                                }
+
+                               $data{$what}->{$tag} .= "$content\n" if ($content);
                        } else {
-                               my $content = $_;
                                if (m/^\s*\n/) {
                                        $data{$what}->{$tag} .= $content;
                                        next;
                                }
 
-                               while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
                                $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>;
+#                              # Compress spaces with tabs
+#                              $content =~ s<^ {8}> <\t>;
+#                              $content =~ s<^ {1,7}\t> <\t>;
+#                              $content =~ s< {1,7}\t> <\t>;
                                $data{$what}->{$tag} .= $content;
                        }
                        next;