Update my email address in a couple more spots.
[metze/wireshark/wip.git] / tools / fixhf.pl
1 #!/usr/bin/env perl
2
3 # Copyright 2010, Jeff Morriss <jeff.morriss.ws[AT]gmail.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 # Wireshark - Network traffic analyzer
14 # By Gerald Combs <gerald@wireshark.org>
15 # Copyright 1998 Gerald Combs
16 #
17 # This program is free software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License
19 # as published by the Free Software Foundation; either version 2
20 # of the License, or (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #
31
32 use strict;
33
34 # Read through the files
35 while ($_ = $ARGV[0])
36 {
37         shift;
38         my $filename = $_;
39         my $fileContents = '';
40         my @foundAPIs = ();
41
42         die "No such file: \"$filename\"" if (! -e $filename);
43
44         # delete leading './'
45         $filename =~ s{ ^ \. / } {}xo;
46
47         # Read in the file (ouch, but it's easier that way)
48         open(FC, $filename) || die("Couldn't open $filename");
49         while (<FC>) { $fileContents .= $_; }
50         close(FC);
51
52         if ($fileContents =~ s{   
53                                   (\{
54                                   \s*
55                                   &\s*[A-Z0-9_\[\]-]+           # &hf
56                                   \s*,\s*
57                                   \{\s*
58                                   ("[A-Z0-9 '\./\(\)_:-]+")     # name
59                                   \s*,\s*
60                                   "[A-Z0-9_\.-]+"               # abbrev
61                                   \s*,\s*
62                                   FT_[A-Z0-9_]+                 # field type
63                                   \s*,\s*
64                                   [A-Z0-9x|_]+                  # display
65                                   \s*,\s*
66                                   [A-Z0-9&_\(\)' -]+            # convert
67                                   \s*,\s*
68                                   [A-Z0-9x_]+                   # bitmask
69                                   \s*,\s*)
70                                   \2                            # blurb
71                                 } [$1NULL]xgios)
72                                  # \s*HFILL)
73         {
74                 print STDERR "Warning: field with name==blurb found in " .$filename. " FIXING IT!\n";
75
76                 # Trim trailing white space while we're here
77                 $fileContents =~ s{[ \t]+$} []gom;
78
79                 open(FC, ">".$filename) || die("Couldn't open $filename");
80                 print FC $fileContents;
81                 close(FC);
82         }
83
84 }