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

Unified · Split

scripts/get_abi.pl+19−23
@@ -147,17 +147,19 @@ sub parse_abi { · 146 unmodified lines
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 { · 10 unmodified lines
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*(.*)/) {