Skip to content

Instantly share code, notes, and snippets.

@m-chaturvedi
Created December 12, 2017 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-chaturvedi/b1e978fd7b4200857f8e78e7756aeabb to your computer and use it in GitHub Desktop.
Save m-chaturvedi/b1e978fd7b4200857f8e78e7756aeabb to your computer and use it in GitHub Desktop.
use warnings;
use strict;
# http://search.cpan.org/~zmij/Array-Utils-0.5/Utils.pm
use Array::Utils qw(:all);
# $/ is the input record separator
# local is because it's a global variable
local $/ = undef;
open(DATA, "<", $ARGV[0]) or die;
my $file_data = <DATA>;
# g if trying to globally match the pattern repeatedly
my @all_defs = ($file_data =~ /PREPROC_ADD_MACRO\(info,(.*?)\)/g );
my @uniq_defs = unique(@all_defs);
# Find symmetric difference
my @repeat_defs = array_diff(@all_defs, @uniq_defs);
print join( "\n" , @repeat_defs)."\n";
# Output of the script
# __INT32_MAX__
# __INT64_MAX__
# __INT8_MAX__
# __INT_FAST16_MAX__
# __INT_FAST16_TYPE__
# __INT_FAST8_MAX__
# __UINT16_MAX__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment