fbrosson | 533407a | 2018-04-04 21:44:29 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
Bence Szépkúti | 700ee44 | 2020-05-26 00:33:31 +0200 | [diff] [blame^] | 2 | # |
| 3 | # Copyright (C) 2015-2019, 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>; |
Christoph M. Wintersteiger | 8a0f5bb | 2018-12-14 15:46:34 +0000 | [diff] [blame] | 16 | push @ARGV, "3rdparty/everest/include/everest/everest.h"; |
| 17 | push @ARGV, "3rdparty/everest/include/everest/x25519.h"; |
| 18 | |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 19 | |
| 20 | my @consts; |
| 21 | my $state = 'out'; |
| 22 | while (<>) |
| 23 | { |
Manuel Pégourié-Gonnard | ae738c2 | 2015-07-01 19:32:00 +0200 | [diff] [blame] | 24 | if( $state eq 'out' and /^(typedef )?enum \{/ ) { |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 25 | $state = 'in'; |
| 26 | } elsif( $state eq 'out' and /^(typedef )?enum/ ) { |
| 27 | $state = 'start'; |
| 28 | } elsif( $state eq 'start' and /{/ ) { |
| 29 | $state = 'in'; |
| 30 | } elsif( $state eq 'in' and /}/ ) { |
| 31 | $state = 'out'; |
Christoph M. Wintersteiger | 7cc4c68 | 2018-12-14 13:18:52 +0000 | [diff] [blame] | 32 | } elsif( $state eq 'in' and not /^#/) { |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 33 | s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp; |
| 34 | push @consts, $_ if $_; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | open my $fh, '>', 'enum-consts' or die; |
| 39 | print $fh "$_\n" for sort @consts; |
| 40 | close $fh or die; |
| 41 | |
| 42 | printf "%8d enum-consts\n", scalar @consts; |