Commit e2e30006 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

New tool.

2002-01-07  Morten Welinder  <terra@diku.dk>

	* check-trailing-commas: New tool.
parent c41d362d
2002-01-07 Morten Welinder <terra@diku.dk>
* check-trailing-commas: New tool.
* check-config-h.pl: Fix after s/config/gnumeric-config/ change.
Also skip intl directory.
......
#!/usr/bin/perl -w
#
# Gnumeric
#
# Copyright (C) 2001 Morten Welinder.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this library; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author: Morten Welinder <terra@diku.dk>
use strict;
my $exitcode = 0;
my $verbose = 0;
warn "$0: should be run from top-level directory.\n"
unless -r "configure.in" && -r 'ChangeLog';
my %base_exceptions =
();
my %exceptions =
();
{
local (*FIND);
open (*FIND, "find . '(' -type f -name '*.[ch]' -print ')' -o '(' -type d '(' -name CVS -o -name intl -o -name macros ')' -prune ')' |")
or die "$0: cannot execute find: $!\n";
FILE:
foreach my $filename (<FIND>) {
chomp $filename;
$filename =~ s|^\./||;
next if $exceptions{$filename};
next if $filename =~ /\.glade\.h$/;
next if $filename =~ /\.xml\.h$/;
my $basename = $filename;
$basename =~ s|^.*/||;
next if $base_exceptions{$basename};
local (*FIL);
if (open (*FIL, "< $filename")) {
my $guard = undef;
my $lineno = 0;
my $state = 0;
LINE:
while (<FIL>) {
$lineno++;
if (/,\s*\}/) {
print STDERR "$filename:$lineno: Suspicious comma.\n";
$exitcode = 1;
next LINE;
} elsif ($state == 1 && /^\s*\}/) {
my $linenom1 = $lineno - 1;
print STDERR "$filename:$linenom1: Suspicious comma.\n";
}
if (/,\s*$/) {
$state = 1;
} else {
$state = 0;
}
}
close (*FIL);
} else {
print STDERR "$0: Cannot read `$filename': $!\b";
$exitcode = 1;
}
}
close (*FIND);
}
exit $exitcode;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment