Witness: set col_info for interfaceInfo_state
[wireshark-wip.git] / tools / fixhf.pl
blobb8bd1cbda5eca49820c0b8171e1abb8243d1348a
1 #!/usr/bin/env perl
3 # Copyright 2010, Jeff Morriss <jeff.morriss[AT]ulticom.com>
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.
10 # Usage:
11 # fixhf.pl file1 [file2 file3 ...]
13 # $Id$
15 # Wireshark - Network traffic analyzer
16 # By Gerald Combs <gerald@wireshark.org>
17 # Copyright 1998 Gerald Combs
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 use strict;
36 # Read through the files
37 while ($_ = $ARGV[0])
39 shift;
40 my $filename = $_;
41 my $fileContents = '';
42 my @foundAPIs = ();
44 die "No such file: \"$filename\"" if (! -e $filename);
46 # delete leading './'
47 $filename =~ s{ ^ \. / } {}xo;
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);
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)
76 print STDERR "Warning: field with name==blurb found in " .$filename. " FIXING IT!\n";
78 # Trim trailing white space while we're here
79 $fileContents =~ s{[ \t]+$} []gom;
81 open(FC, ">".$filename) || die("Couldn't open $filename");
82 print FC $fileContents;
83 close(FC);