This file is indexed.

/usr/share/makepp/Mpp/CommandParser/Swig.pm is in makepp 2.0.98.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# $Id: Swig.pm,v 1.16 2012/05/15 21:26:30 pfeiffer Exp $

=head1 NAME

Mpp::CommandParser::Swig - makepp command parser for swig

=head1 DESCRIPTION

Parses a SWIG (Simplified Wrapper and Interface Generator, http://www.swig.org)
command line for dependencies.

=cut

use strict;
package Mpp::CommandParser::Swig;

use Mpp::CommandParser;
our @ISA = qw/Mpp::CommandParser/;

use Mpp::File;

*factory = \&Mpp::Subs::p_swig;

#
# Swig has a convenient option to get where its library directories are, so
#

sub new {
  my $self = &Mpp::CommandParser::new;
  require Mpp::Scanner::Swig;
  $self->{SCANNER} = new Mpp::Scanner::Swig($self->rule, $self->dir);
  $self;
}

my( $cplusplus, $idash, $importall, $includeall );

my %opt =
  ('c++' => \$cplusplus,
   'I-' => \$idash,
   importall => \$importall,
   includeall => \$includeall);

# languages
$opt{$_} = 1 for qw(allegrocl chicken csharp guile java modula3 mzscheme ocaml
		    perl perl5 php php4 pike python ruby sexp tcl xml);
# unhandled options with argument
$opt{$_} = 2 for qw(MD MF MMD co dllimport dlname feature features generateconst
		    generaterename generatetypemap globals identifier-converter
		    interface module namespace outdir package prefix typemaplang
		    w withc withcxx withincs withlibs xmllang);



#
# This is the main command parser, implementing
# Mpp::CommandParser::xparse_command().  See Mpp/CommandParser.pm for its
# inputs and outputs.
#
my %info_string = (user => 'SWIG_INCLUDES',
		   sys => 'SWIG_SYSTEM_INCLUDES');
my $swig_library_path;
sub xparse_command {
  my( $self, $command, $setenv ) = @_;

  my @input_files;              # The files mentioned on the command line.
  my $output_file;
  my @swig_libs;                # Libraries mentioned with -l.
  my $swig_language = 'tcl';	# The language we're translating into.
  my @includes;
  my @defines;
  my @files;
  $cplusplus = $idash = $importall = $includeall = 0;

  my( $swig_binary, @words ) = @$command; # Make a copy of the command words.

  local $_;
  while( defined( $_ = shift @words )) {
    if( !s/^-// ) {		# Is this a filename?  Swig also takes any
				# unknown -option as a filename, but handling
				# that would require having an up to date list
				# of all options understood by swig, and
				# handling them depending on the language.
				# Hopefully nobody will use this misfeature.
      push @files, $_;
    #
    # It's an option.  Parse it:
    #
    } elsif( $opt{$_} ) {
      if( ref $opt{$_} ) {
	${$opt{$_}} = 1;
      } elsif( $opt{$_} == 1 ) {
	$swig_language = $_;
      } else {
	shift @words;
      }
    #} elsif (/^E$/) {
      # Not sure what to do here.
    } elsif( s/^l// ) {
      push @swig_libs, $_;
    } elsif( /^(?:oh?|xml(?:out)?)$/ ) {
      $self->add_target( shift @words );
    } elsif( s/^D// ) {
      push @defines, $_;
    } elsif( s/^I// ) {
      push @includes, $_;
    }
  }

#
# Set up some things in the scanner:
#
  my $scanner = $self->{SCANNER};
  $scanner->{LANGUAGE} = $swig_language;
  $scanner->should_find("user");
  $scanner->info_string( \%info_string );
  foreach my $def (@defines) {
    if ($def =~ /^(\w+)=(.*)/) {
      $scanner->set_var($1, $2);
    } else {
      $scanner->set_var($def, 1);
    }
  }
  $importall and $scanner->{IMPORTALL} = 1;
  $includeall and $scanner->{INCLUDEALL} = 1;

  my $rule = $self->rule;
  $rule->set_signature_class( 'C', 1 );

  $scanner->set_var(SWIG => 1);
  $scanner->set_var("SWIG" . uc($swig_language), 1);
  $scanner->set_var( __STDC__ => 1 );
  $scanner->set_var( __cplusplus => 1) if $cplusplus;

#
# Get the whole include path.  Swig can tell us the system library path
# by running it with the -swiglib option.
#
  $swig_library_path = Mpp::Subs::f_shell "$swig_binary -swiglib", $rule->makefile, $rule->source
    if !defined $swig_library_path;
                                # This is more or less equivalent to caching
                                # `$swig_binary -swiglib`.  See f_shell for
                                # why we don't just use backquotes.
  $scanner->add_include_dir("user", undef) unless $idash;
  foreach my $include (@includes, ".", "$swig_library_path") {
    $scanner->add_include_dir("user", $include);
    $scanner->add_include_dir("sys", $include);
    my $inc_swig_language = "$include/$swig_language";
    if( is_or_will_be_dir file_info $inc_swig_language ) {
                                # If the subdirectory given by the language
                                # exists, it is a valid place to look for
                                # include files too.
      $scanner->add_include_dir("user", $inc_swig_language);
      $scanner->add_include_dir("sys", $inc_swig_language);
    }
  }

#
# Scan any files imported with -l.
#
  my $context = $scanner->get_context;
  foreach my $swig_lib (@swig_libs) {
    $scanner->scan_file($self, "c", "$swig_lib.i") or return undef;
  }

#
# Scan files listed on the command line.
#
  $scanner->reset( $context );
  foreach my $file (@files) {
    $scanner->reset( $context );
    $scanner->scan_file($self, "c", $file) or return undef;
  }

  return 1;
}

1;