fbrosson | 533407a | 2018-04-04 21:44:29 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame^] | 2 | # |
| 3 | # Copyright (C) 2015, Arm Limited, All Rights Reserved |
| 4 | # |
| 5 | # This file is part of Mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 6 | |
| 7 | use warnings; |
| 8 | use strict; |
| 9 | |
| 10 | use utf8; |
| 11 | use open qw(:std utf8); |
| 12 | |
Manuel Pégourié-Gonnard | d1ddd29 | 2015-04-09 10:15:10 +0200 | [diff] [blame] | 13 | -d 'include/mbedtls' or die "$0: must be run from root\n"; |
| 14 | |
Manuel Pégourié-Gonnard | e137ea6 | 2015-04-09 10:47:44 +0200 | [diff] [blame] | 15 | @ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>; |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 16 | |
| 17 | my @consts; |
| 18 | my $state = 'out'; |
| 19 | while (<>) |
| 20 | { |
Manuel Pégourié-Gonnard | ae738c2 | 2015-07-01 19:32:00 +0200 | [diff] [blame] | 21 | if( $state eq 'out' and /^(typedef )?enum \{/ ) { |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 22 | $state = 'in'; |
| 23 | } elsif( $state eq 'out' and /^(typedef )?enum/ ) { |
| 24 | $state = 'start'; |
| 25 | } elsif( $state eq 'start' and /{/ ) { |
| 26 | $state = 'in'; |
| 27 | } elsif( $state eq 'in' and /}/ ) { |
| 28 | $state = 'out'; |
| 29 | } elsif( $state eq 'in' ) { |
| 30 | s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp; |
| 31 | push @consts, $_ if $_; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | open my $fh, '>', 'enum-consts' or die; |
| 36 | print $fh "$_\n" for sort @consts; |
| 37 | close $fh or die; |
| 38 | |
| 39 | printf "%8d enum-consts\n", scalar @consts; |