~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to devtools/testsuite/c_casts.t

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
use FindBin qw/$Bin/;
 
7
use lib $Bin.'/../lib';
 
8
use Test::More tests => 1;
 
9
use Gnash::Distribution;
 
10
use Gnash::Utils qw/clean/;
 
11
 
 
12
my $DIST = Gnash::Distribution->new;
 
13
 
 
14
## Jerry Gay explained that this construction was needed because Windows
 
15
## does not get @ARGV the same way as most systems.
 
16
my @files = @ARGV 
 
17
    ? ( $^O eq 'MSwin32' ? <@ARGV> : @ARGV )
 
18
    : $DIST->get_cpp_language_files();
 
19
 
 
20
my @var_types = qw/int bool char long double/; 
 
21
my @failures;  
 
22
 
 
23
foreach my $path (@files) {
 
24
    open my $fh, '<', $path
 
25
        or die "Cannot open '$path' for reading: $!\n";
 
26
 
 
27
    my $prefix = qq<  $path line(s):>;
 
28
    my $message = '';
 
29
 
 
30
    ## Read in the entire file, as some of the cleaning spans lines
 
31
    local $/ = undef;
 
32
    my $entire_file = clean(<$fh>);
 
33
    my @lines = split /\n/, $entire_file;    
 
34
 
 
35
    ## We need the array index to report the correct line number.
 
36
    LINE: foreach my $i (0..$#lines) {
 
37
        my $string = $lines[$i];
 
38
 
 
39
        ## Look for C-style pointer for each builtin data type.  This
 
40
        ## will not check for user-defined types, but it prevents false
 
41
        ## positives such as functions.
 
42
        my $errmark = 0;
 
43
        TYPE: foreach my $type (@var_types) {
 
44
            ## Skip unless a cast of type 'int num = (int*) x;' is found.
 
45
            $errmark = 1, last TYPE if ( $string =~ /=\s*\($type\*?\)\s*\w+/ );
 
46
 
 
47
            ## Skip unless a cast of type 'num = int*(x);' is found
 
48
            $errmark = 1, last TYPE if ( $string =~ /=\s*$type\*?\(\w+\)/ );
 
49
        }
 
50
 
 
51
        next LINE unless ($errmark); 
 
52
        $message .= " ".($i+1);
 
53
    }
 
54
    push @failures => "$prefix$message\n" if ($message);
 
55
    close $fh;
 
56
}
 
57
 
 
58
ok( !scalar(@failures), "C-style casting" )
 
59
    or diag("C-style casting found in ".scalar @failures." files:\n@failures");
 
60
 
 
61
=head1 NAME
 
62
 
 
63
devtools/testsuite/c_casts.t - checks for C-style casts C++ source and headers
 
64
 
 
65
=head1 SYNOPSIS
 
66
 
 
67
    # test all files
 
68
    % prove devtools/testsuite/c_casts.t
 
69
 
 
70
    # test specific files
 
71
    % perl devtools/testsuite/c_casts.t recently/modified/file
 
72
 
 
73
=head1 DESCRIPTION
 
74
 
 
75
This test looks for C++ source files which contain C-style casts.  These
 
76
are examples of casting using C-style:
 
77
 
 
78
    double x;
 
79
    int num = (int) x
 
80
 
 
81
    double x;
 
82
    num = int*(x)
 
83
 
 
84
C++ casting style (shown below) provides better diagnoses of usage errors
 
85
and are easier to identify and maintain.
 
86
 
 
87
    double x;
 
88
    int num = static_cast<int>(x);
 
89
 
 
90
=head1 AUTHORS
 
91
 
 
92
Ann Barcomb <kudra@domaintje.com>, based upon ideas from the Parrot
 
93
L<http://http://dev.perl.org/perl6/> test suite.
 
94
 
 
95
=head1 COPYRIGHT
 
96
 
 
97
Copyright (C) 2007 Free Software Foundation, Inc.
 
98
 
 
99
This program is free software; you can redistribute it and/or modify
 
100
it under the terms of the GNU General Public License as published by
 
101
the Free Software Foundation; either version 3 of the License, or
 
102
(at your option) any later version.
 
103
 
 
104
This program is distributed in the hope that it will be useful,
 
105
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
106
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
107
GNU General Public License for more details.
 
108
You should have received a copy of the GNU General Public License
 
109
along with this program; if not, write to the Free Software
 
110
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
111
 
 
112
=cut