turn pattern() into an extractor class method, getting rid of the previous hack
[deps.git] / lib / graphincludes / extractor / C.pm
blob47673c8065868a11ee7a00c3e2904c751fd4b390
1 # This file is part of the graph-includes package
3 # (c) 2005 Yann Dirson <ydirson@altern.org>
4 # Distributed under version 2 of the GNU GPL.
6 package graphincludes::extractor::C;
7 use strict;
8 use warnings;
10 use base qw(graphincludes::extractor);
12 use graphincludes::params;
13 use File::Basename qw(dirname);
15 sub pattern { '\.[ch]$' }
17 sub getdeps {
18 my $self = shift;
19 my %deps;
21 @ARGV = @{$self->{FILES}};
22 while (<>) {
23 my $dstfile;
24 if (m/^\s*#\s*include\s*"(.*)"/) {
25 $dstfile = $self->locatefile ($1, dirname($ARGV), @graphincludes::params::inclpath);
26 } elsif (m/^\s*#\s*include\s*<(.*)>/) {
27 $dstfile = $self->locatefile ($1, @graphincludes::params::inclpath);
28 } else {
29 next;
32 if (defined $dstfile) {
33 $self->record_dep (\%deps, $ARGV, $dstfile);
34 } else {
35 $self->record_missed_dep ($ARGV, $1);
38 return \%deps;