diff options
author | Bill Meier <wmeier@newsguy.com> | 2014-09-18 18:41:57 -0400 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2014-09-19 01:37:38 +0000 |
commit | 4bdf5145129a2b9dbae3d927a761d9be5cecacd5 (patch) | |
tree | 65e537542328a676d65459fef716f62a3b3e4c40 /tools/fix-encoding-args.pl | |
parent | 7b20afc73f20bf7537cce18bda43285d69a2a150 (diff) | |
download | wireshark-4bdf5145129a2b9dbae3d927a761d9be5cecacd5.tar.gz |
fix-encoding-args.pl: Add a few additional fixups;
Specifically: A number of cases of the use of the encoding arg
"ENC_ASCII | ENC_NA" for FT_BYTES FIELDTYPEs seem to
have crept into Wireshark source.
Also: Add a ToDo comment as to code rework needed to be able to
better *validate* encoding args.
Change-Id: I9d4b10b869fe2aef3f20bcd2d7ad6531375aba87
Reviewed-on: https://code.wireshark.org/review/4183
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'tools/fix-encoding-args.pl')
-rwxr-xr-x | tools/fix-encoding-args.pl | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/tools/fix-encoding-args.pl b/tools/fix-encoding-args.pl index 6eca20d4b1..59e3e78538 100755 --- a/tools/fix-encoding-args.pl +++ b/tools/fix-encoding-args.pl @@ -18,6 +18,7 @@ # - ptvcursor_add_no_advance # - ptvcursor_add_with_subtree !! ToDo: encoding arg not last arg # +# ToDo: Rework program so that it can better be used to *validate* encoding-args # # Wireshark - Network traffic analyzer # By Gerald Combs <gerald@wireshark.org> @@ -56,15 +57,16 @@ my $searchReplaceFalseTrueHRef = my $searchReplaceEncNAHRef = { - "FALSE" => "ENC_NA", - "0" => "ENC_NA", - "TRUE" => "ENC_NA", - "1" => "ENC_NA", - "ENC_LITTLE_ENDIAN" => "ENC_NA", - "ENC_BIG_ENDIAN" => "ENC_NA" + "FALSE" => "ENC_NA", + "0" => "ENC_NA", + "TRUE" => "ENC_NA", + "1" => "ENC_NA", + "ENC_LITTLE_ENDIAN" => "ENC_NA", + "ENC_BIG_ENDIAN" => "ENC_NA", + "ENC_ASCII|ENC_NA" => "ENC_NA", + "ENC_ASCII | ENC_NA" => "ENC_NA" }; - # --------------------------------------------------------------------- # Conversion "request" structure # ( @@ -286,6 +288,7 @@ while (my $fileName = $ARGV[0]) { # delete leading './' $fileName =~ s{ ^ \. / } {}xo; + ##print "$fileName\n"; # Read in the file (ouch, but it's easier that way) open(FCI, "<", $fileName) || die("Couldn't open $fileName"); @@ -463,17 +466,21 @@ sub find_hf_array_entries { # build the complete pattern my $patRegEx = qr / - ( # part 1: $1 + # part 1: $1 + ( (?:^|=) # don't try to handle fcn_name call when arg of another fcn call \s* $fcn_name \s* \( [^;]+? # a bit dangerous ,\s* ) - ( # part 2: $2 - $encArgPat - ) - ( # part 3: $3 + + # part 2: $2 + # exact match of pattern (including spaces) + ((?-x)$encArgPat) + + # part 3: $3 + ( \s* \) \s* ; ) @@ -591,7 +598,8 @@ sub find_hf_array_entries { # build the complete pattern my $patRegEx = qr / - ( # part 1: $1 + # part 1: $1 + ( $fcn_name \s* \( [^;]+? ,\s* @@ -600,16 +608,20 @@ sub find_hf_array_entries { [^;]+ ,\s* ) - ( # part 2: $2 - $encArgPat - ) - ( # part 3: $3 + + # part 2: $2 + # exact match of pattern (including spaces) + ((?-x)$encArgPat) + + # part 3: $3 + ( \s* \) \s* ; ) /xs; ##print "\n$hf_index_name $hf_field_type\n"; + ##print "\n$patRegEx\n"; ## Match and substitute as specified $$fileContentsRef =~ s/ $patRegEx /patsub($1,$2,$3)/xges; |