Fix build by #if 0 out unused de_sgsap_tmsi() function.
[obnox/wireshark/wip.git] / tools / fixhf.pl
1 #!/usr/bin/env perl
2
3 # Copyright 2010, Jeff Morriss <jeff.morriss[AT]ulticom.com>
4 #
5 # A simple tool to remove bogus blurbs from hf entries.
6 # This has already been run so it may not be necessary any more, but
7 # may as well check it in in case it can serve as a base for other, future,
8 # global hf changes.
9 #
10 # Usage:
11 # fixhf.pl file1 [file2 file3 ...]
12 #
13 # $Id$
14 #
15 # Wireshark - Network traffic analyzer
16 # By Gerald Combs <gerald@wireshark.org>
17 # Copyright 1998 Gerald Combs
18 #
19 # This program is free software; you can redistribute it and/or
20 # modify it under the terms of the GNU General Public License
21 # as published by the Free Software Foundation; either version 2
22 # of the License, or (at your option) any later version.
23 #
24 # This program is distributed in the hope that it will be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 # GNU General Public License for more details.
28 #
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write to the Free Software
31 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #
33
34 use strict;
35
36 # Read through the files
37 while ($_ = $ARGV[0])
38 {
39         shift;
40         my $filename = $_;
41         my $fileContents = '';
42         my @foundAPIs = ();
43
44         die "No such file: \"$filename\"" if (! -e $filename);
45
46         # delete leading './'
47         $filename =~ s{ ^ \. / } {}xo;
48
49         # Read in the file (ouch, but it's easier that way)
50         open(FC, $filename) || die("Couldn't open $filename");
51         while (<FC>) { $fileContents .= $_; }
52         close(FC);
53
54         if ($fileContents =~ s{   
55                                   (\{
56                                   \s*
57                                   &\s*[A-Z0-9_\[\]-]+           # &hf
58                                   \s*,\s*
59                                   \{\s*
60                                   ("[A-Z0-9 '\./\(\)_:-]+")     # name
61                                   \s*,\s*
62                                   "[A-Z0-9_\.-]+"               # abbrev
63                                   \s*,\s*
64                                   FT_[A-Z0-9_]+                 # field type
65                                   \s*,\s*
66                                   [A-Z0-9x|_]+                  # display
67                                   \s*,\s*
68                                   [A-Z0-9&_\(\)' -]+            # convert
69                                   \s*,\s*
70                                   [A-Z0-9x_]+                   # bitmask
71                                   \s*,\s*)
72                                   \2                            # blurb
73                                 } [$1NULL]xgios)
74                                  # \s*HFILL)
75         {
76                 print STDERR "Warning: field with name==blurb found in " .$filename. " FIXING IT!\n";
77
78                 # Trim trailing white space while we're here
79                 $fileContents =~ s{[ \t]+$} []gom;
80
81                 open(FC, ">".$filename) || die("Couldn't open $filename");
82                 print FC $fileContents;
83                 close(FC);
84         }
85
86 }