gen-error-list.pl 691 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env perl
  2. use strict;
  3. my $doc_start;
  4. my $error_data;
  5. my $line;
  6. my @errors;
  7. while ($line = <>) {
  8. chomp $line;
  9. $line =~ /^\/\*\*/ and do {
  10. $doc_start = 1;
  11. next;
  12. };
  13. $line =~ /^\s*\*\// and undef $error_data;
  14. $doc_start and $line =~ /^\s*\*\s*QmiProtocolError:/ and do {
  15. $error_data = 1;
  16. undef $doc_start;
  17. next;
  18. };
  19. undef $doc_start;
  20. $line =~ /^.*@([A-Z0-9_]+): ([A-z0-9 ]+)[.].*$/ and push @errors, [ $1, $2 ];
  21. }
  22. @errors > 0 or die "No data found\n";
  23. print <<EOF;
  24. static const struct {
  25. QmiProtocolError code;
  26. const char *text;
  27. } qmi_errors[] = {
  28. EOF
  29. foreach my $error (@errors) {
  30. print "\t{ ".$error->[0].", \"".$error->[1]."\" },\n";
  31. }
  32. print <<EOF;
  33. };
  34. EOF