From 4bdf5145129a2b9dbae3d927a761d9be5cecacd5 Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Thu, 18 Sep 2014 18:41:57 -0400 Subject: 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 --- tools/fix-encoding-args.pl | 46 +++++++++++++++++++++++++++++----------------- 1 file 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 @@ -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; -- cgit v1.2.1