| Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 1 | #!/usr/bin/perl | 
|  | 2 |  | 
|  | 3 | use warnings; | 
|  | 4 | use strict; | 
|  | 5 |  | 
|  | 6 | use utf8; | 
|  | 7 | use open qw(:std utf8); | 
|  | 8 |  | 
| Manuel Pégourié-Gonnard | d1ddd29 | 2015-04-09 10:15:10 +0200 | [diff] [blame] | 9 | -d 'include/mbedtls' or die "$0: must be run from root\n"; | 
|  | 10 |  | 
| Manuel Pégourié-Gonnard | e137ea6 | 2015-04-09 10:47:44 +0200 | [diff] [blame] | 11 | @ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>; | 
| Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 12 |  | 
|  | 13 | my @consts; | 
|  | 14 | my $state = 'out'; | 
|  | 15 | while (<>) | 
|  | 16 | { | 
| Manuel Pégourié-Gonnard | ae738c2 | 2015-07-01 19:32:00 +0200 | [diff] [blame] | 17 | if( $state eq 'out' and /^(typedef )?enum \{/ ) { | 
| Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 18 | $state = 'in'; | 
|  | 19 | } elsif( $state eq 'out' and /^(typedef )?enum/ ) { | 
|  | 20 | $state = 'start'; | 
|  | 21 | } elsif( $state eq 'start' and /{/ ) { | 
|  | 22 | $state = 'in'; | 
|  | 23 | } elsif( $state eq 'in' and /}/ ) { | 
|  | 24 | $state = 'out'; | 
|  | 25 | } elsif( $state eq 'in' ) { | 
|  | 26 | s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp; | 
|  | 27 | push @consts, $_ if $_; | 
|  | 28 | } | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | open my $fh, '>', 'enum-consts' or die; | 
|  | 32 | print $fh "$_\n" for sort @consts; | 
|  | 33 | close $fh or die; | 
|  | 34 |  | 
|  | 35 | printf "%8d enum-consts\n", scalar @consts; |