#!/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;