Updated Czech translation
[gnumeric.git] / tools / check-trailing-commas
blobd6fdd2935aa62625d4d0fee26ba50e7fced4bce6
1 #!/usr/bin/perl -w
3 # Gnumeric
5 # Copyright (C) 2001 Morten Welinder.
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this library; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 # Author: Morten Welinder <terra@gnome.org>
23 use strict;
25 my $exitcode = 0;
26 my $verbose = 0;
28 warn "$0: should be run from top-level directory.\n"
29 unless -r "configure.ac" && -r 'ChangeLog';
31 my %base_exceptions =
32 ();
34 my %exceptions =
35 ();
38 local (*FIND);
39 open (*FIND, "find . '(' -type f -name '*.[ch]' -print ')' -o '(' -type d '(' -name intl -o -name macros -o -name .git -o -name win32 ')' -prune ')' |")
40 or die "$0: cannot execute find: $!\n";
41 FILE:
42 foreach my $filename (<FIND>) {
43 chomp $filename;
44 $filename =~ s|^\./||;
46 next if $exceptions{$filename};
47 next if $filename =~ /\.glade\.h$/;
48 next if $filename =~ /\.xml\.h$/;
49 my $basename = $filename;
50 $basename =~ s|^.*/||;
51 next if $base_exceptions{$basename};
53 local (*FIL);
54 if (open (*FIL, "< $filename")) {
55 my $lineno = 0;
56 my $state = 0;
57 LINE:
58 while (<FIL>) {
59 $lineno++;
61 if ($state == 1 && /^\s*\}/) {
62 my $linenom1 = $lineno - 1;
63 print STDERR "$filename:$linenom1: Suspicious comma.\n";
66 if (/,\s*\}/) {
67 print STDERR "$filename:$lineno: Suspicious comma.\n";
68 $exitcode = 1;
71 if (/,\s*$/) {
72 $state = 1;
73 } else {
74 $state = 0;
77 close (*FIL);
78 } else {
79 print STDERR "$0: Cannot read `$filename': $!\b";
80 $exitcode = 1;
83 close (*FIND);
86 exit $exitcode;