diff --git a/.gitattributes b/.gitattributes index e83c6400580..0f1a116cad4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3078,6 +3078,7 @@ STL_Extension/test/STL_Extension/test_type_traits.cpp -text Scripts/developer_scripts/autotest_cgal_with_cmake -text Scripts/developer_scripts/cgal_build -text Scripts/developer_scripts/cgal_test_with_cmake eol=lf +Scripts/developer_scripts/check_macro_names -text Scripts/developer_scripts/check_no_CGAL_USE_without_includes_before -text Scripts/developer_scripts/check_svn_keywords -text Scripts/developer_scripts/common_impl.rb -text diff --git a/Scripts/developer_scripts/check_macro_names b/Scripts/developer_scripts/check_macro_names new file mode 100755 index 00000000000..f76bbb3934a --- /dev/null +++ b/Scripts/developer_scripts/check_macro_names @@ -0,0 +1,73 @@ +#!/usr/bin/env perl + +=head1 SYNOPSIS + +check_macro_names [options] [file...] + + Options: + --help help message + --debug debug mode + +=head1 OPTIONS + +=over 8 + +=item B<-d, --debug> + +Print to standard error output all macros names that are defined in the +file. + +=item B<-l, --list> + +Print to standard output the names of all macros defined in the file that +do not follow the naming rules, preceded by the file name. + +=Head1 DESCRIPTION + +This script reads a file whose name is specify in command line options, and +return 1 if a macro defined in the file does not follow the naming +rules. The script can process several files simultaneously. + + +=cut + +use strict; +use warnings; + +use Getopt::Long qw(:config permute); +use Pod::Usage; + +my $help; +my $debug; +my $global_errcode = 0; +my $listmacros; + +GetOptions('help' => \$help, + 'list|l' => \$listmacros, + 'debug|d' => \$debug, + '<>' => \&process) or pod2usage(2); + +pod2usage(1) if $help; + +sub process() { + my $filename = shift; + my $errcode=1; + my $FILE; + + open(FILE, $filename) or die "Cannot read file $filename"; + + while () { + my $macro; + if( ($macro) = ($_ =~ /# *define +([^[:space:]]+)/) ) { + print STDERR "$filename: $macro\n" if $debug; + if( $macro !~ /^CGAL/ ) { + $global_errcode = 1; + if( $listmacros && ! $debug ) { + print STDOUT "$filename: $macro\n"; + } + } + } + } +} + +exit $global_errcode;