History

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.

Mauro Carvalho Chehab committed 6 years ago

Commit f82a8a71 parent 61439c41 file · +19 −23Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/get_abi.pl+19−23
@@ -147,17 +147,19 @@ sub parse_abi { · 146 unmodified lines
147 parse_error($file, $ln, "'What:' should come first:", $_);147 parse_error($file, $ln, "'What:' should come first:", $_);
148 next;148 next;
149 }149 }
150 if ($tag eq "description") {150 if ($new_tag eq "description") {
151 # Preserve initial spaces for the first line151 $sep =~ s,:, ,;
152 $content = ' ' x length($new_tag) . $sep . $content;152 $content = ' ' x length($new_tag) . $sep . $content;
153 $content =~ s,^(\s*):,$1 ,;153 while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
154 if ($content =~ m/^(\s*)(.*)$/) {154 if ($content =~ m/^(\s*)(\S.*)$/) {
155 # Preserve initial spaces for the first line
155 $space = $1;156 $space = $1;
156 $content = $2;157 $content = "$2\n";
158 $data{$what}->{$tag} .= $content;
159 } else {
160 undef($space);
157 }161 }
158 while ($space =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
159 162
160 $data{$what}->{$tag} .= "$content\n" if ($content);
161 } else {163 } else {
162 $data{$what}->{$tag} = $content;164 $data{$what}->{$tag} = $content;
163 }165 }
@@ -174,28 +176,22 @@ sub parse_abi { · 10 unmodified lines
174 if ($tag eq "description") {176 if ($tag eq "description") {
175 my $content = $_;177 my $content = $_;
176 while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}178 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)) {
178 # Preserve initial spaces for the first line185 # Preserve initial spaces for the first line
179 if ($content =~ m/^(\s*)(.*)$/) {186 if ($content =~ m/^(\s*)(\S.*)$/) {
180 $space = $1;187 $space = $1;
181 $content = $2;188 $content = "$2\n";
182 }189 }
183
184 $data{$what}->{$tag} .= "$content\n" if ($content);
185 } else {190 } else {
186 if (m/^\s*\n/) {
187 $data{$what}->{$tag} .= $content;
188 next;
189 }
190
191 $space = "" if (!($content =~ s/^($space)//));191 $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;
198 }192 }
193 $data{$what}->{$tag} .= $content;
194
199 next;195 next;
200 }196 }
201 if (m/^\s*(.*)/) {197 if (m/^\s*(.*)/) {