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,
11 # fixhf.pl file1 [file2 file3 ...]
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.
36 # Read through the files
41 my $fileContents = '';
44 die "No such file: \"$filename\"" if (! -e
$filename);
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 .= $_; }
54 if ($fileContents =~ s
{
57 &\s
*[A
-Z0
-9_\
[\
]-]+ # &hf
60 ("[A-Z0-9 '\./\(\)_:-]+") # name
62 "[A-Z0-9_\.-]+" # abbrev
64 FT_
[A
-Z0
-9_
]+ # field type
66 [A
-Z0
-9x
|_
]+ # display
68 [A
-Z0
-9&_\
(\
)' -]+ # convert
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;