File Coverage

blib/lib/auto/share/dist/Alien-autoconf/bin/ifnames
Criterion Covered Total %
statement 46 62 74.1
branch 2 8 25.0
condition 9 29 31.0
subroutine 12 13 92.3
pod n/a
total 69 112 61.6


line stmt bran cond sub pod time code
1             #! /usr/local/bin/perl
2             BEGIN {
3 1     1   4793 use strict;
  1         2  
  1         31  
4 1     1   3 use warnings;
  1         1  
  1         40  
5 1     1   3 use File::Spec;
  1         1  
  1         199  
6 1     1   30 my($v,$d) = File::Spec->splitpath(File::Spec->rel2abs(__FILE__));
7 1         17 my @d = File::Spec->splitdir($d);
8 1         6 pop @d for 1..2;
9 1         18 my $dist_dir = File::Spec->catpath($v,File::Spec->catdir(@d), '');
10 1   33     29 $ENV{AUTOM4TE} ||= File::Spec->catfile($dist_dir, 'bin/autom4te');
11 1   33     10 $ENV{autom4te_perllibdir} ||= File::Spec->catdir($dist_dir, 'share/autoconf');
12 1   33     10 $ENV{AC_MACRODIR} ||= File::Spec->catdir($dist_dir, 'share/autoconf');
13 1   33     48 $ENV{AUTOCONF} ||= File::Spec->catfile($dist_dir, 'bin/autoconf');
14 1   33     9 $ENV{AUTOHEADER} ||= File::Spec->catfile($dist_dir, 'bin/autoheader');
15 1 50 33     20 $ENV{AUTOM4TE_CFG} ||= File::Spec->catfile($dist_dir, 'share/autoconf/autom4te.blib.cfg')
      33        
16             if $d[-5] eq 'lib' && $d[-6] eq 'blib';
17 1   33     42 $ENV{trailer_m4} ||= File::Spec->catdir($dist_dir, 'share/autoconf/autoconf/trailer.m4');
18             }
19             # -*- perl -*-
20             # Generated from bin/ifnames.in; do not edit by hand.
21              
22 1         176171 eval 'case $# in 0) exec /usr/local/bin/perl -S "$0";; *) exec /usr/local/bin/perl -S "$0" "$@";; esac'
23             if 0;
24              
25             # ifnames - print the identifiers used in C preprocessor conditionals
26              
27             # Copyright (C) 1994-1995, 1999-2003, 2005-2017, 2020-2023 Free Software
28             # Foundation, Inc.
29              
30             # This program is free software: you can redistribute it and/or modify
31             # it under the terms of the GNU General Public License as published by
32             # the Free Software Foundation, either version 3 of the License, or
33             # (at your option) any later version.
34              
35             # This program is distributed in the hope that it will be useful,
36             # but WITHOUT ANY WARRANTY; without even the implied warranty of
37             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38             # GNU General Public License for more details.
39              
40             # You should have received a copy of the GNU General Public License
41             # along with this program. If not, see .
42              
43             # Reads from stdin if no files are given.
44             # Writes to stdout.
45              
46             # Written by David MacKenzie
47             # and Paul Eggert .
48              
49 1     1   13 use 5.006;
  1         3  
50 1     1   6 use strict;
  1         4  
  1         60  
51 1     1   7 use warnings FATAL => 'all';
  1         11  
  1         108  
52              
53             BEGIN
54             {
55 1   50 1   4 my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '/usr/local/lib/perl5/site_perl/5.42.0/x86_64-linux/auto/share/dist/Alien-autoconf/share/autoconf';
56 1         3 unshift @INC, $pkgdatadir;
57              
58             # Override SHELL. On DJGPP SHELL may not be set to a shell
59             # that can handle redirection and quote arguments correctly,
60             # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
61             # has detected.
62 1 50       18 $ENV{'SHELL'} = '/bin/bash' if ($^O eq 'dos');
63             }
64              
65 1     1   524 use Autom4te::General;
  1         4  
  1         217  
66 1     1   694 use Autom4te::XFile;
  1         4  
  1         295  
67 1     1   9 use Autom4te::FileUtils;
  1         2  
  1         88041  
68              
69             # $HELP
70             # -----
71 1         9 $help = "Usage: $0 [OPTION]... [FILE]...
72              
73             Scan all of the C source FILES (or the standard input, if none are
74             given) and write to the standard output a sorted list of all the
75             identifiers that appear in those files in '#if', '#elif', '#ifdef', or
76             '#ifndef' directives. Print each identifier on a line, followed by a
77             space-separated list of the files in which that identifier occurs.
78              
79             -h, --help print this help, then exit
80             -V, --version print version number, then exit
81              
82             Report bugs to .
83              
84             The full documentation for Autoconf can be read via 'info autoconf',
85             or on the Web at .
86             ";
87              
88              
89             # $VERSION
90             # --------
91 1         4 $version = "ifnames (GNU Autoconf) 2.72
92             Copyright (C) 2023 Free Software Foundation, Inc.
93             License GPLv3+/Autoconf: GNU GPL version 3 or later
94             ,
95             This is free software: you are free to change and redistribute it.
96             There is NO WARRANTY, to the extent permitted by law.
97              
98             Written by David J. MacKenzie and Paul Eggert.
99             ";
100              
101              
102             # &parse_args ()
103             # --------------
104             # Process any command line arguments.
105             sub parse_args ()
106             {
107 1     1   9 getopt ();
108             }
109              
110              
111             # %OCCURRENCE
112             # -----------
113 1         3 my %occurrence;
114              
115              
116             # &scan_file ($FILE-NAME)
117             # -----------------------
118             sub scan_file ($)
119             {
120 0     0     my ($file_name) = @_;
121 0           my $file = new Autom4te::XFile ($file_name, "<");
122 0           while ($_ = $file->getline)
123             {
124             # Continuation lines.
125 0           $_ .= $file->getline
126             while (s/\\$//);
127              
128             # Preprocessor directives.
129 0 0         if (s/^\s*\#\s*(if|ifdef|ifndef|elif)\s+//)
130             {
131             # Remove comments. Not perfect, but close enough.
132 0           s(/\*.*?\*/)();
133 0           s(/\*.*)();
134 0           s(//.*)();
135 0           foreach my $word (split (/\W+/))
136             {
137             next
138 0 0 0       if $word eq 'defined' || $word !~ /^[a-zA-Z_]/;
139 0           $occurrence{$word}{$file_name} = 1;
140             }
141             }
142             }
143             }
144              
145              
146             ## ------ ##
147             ## Main. ##
148             ## ------ ##
149              
150 1         5 parse_args();
151 0         0 foreach (@ARGV)
152             {
153 0         0 scan_file ($_);
154             }
155 0         0 foreach (sort keys %occurrence)
156             {
157 0         0 print "$_ ", join (' ', sort keys %{$occurrence{$_}}), "\n";
  0         0  
158             }
159              
160             ### Setup "GNU" style for perl-mode and cperl-mode.
161             ## Local Variables:
162             ## perl-indent-level: 2
163             ## perl-continued-statement-offset: 2
164             ## perl-continued-brace-offset: 0
165             ## perl-brace-offset: 0
166             ## perl-brace-imaginary-offset: 0
167             ## perl-label-offset: -2
168             ## cperl-indent-level: 2
169             ## cperl-brace-offset: 0
170             ## cperl-continued-brace-offset: 0
171             ## cperl-label-offset: -2
172             ## cperl-extra-newline-before-brace: t
173             ## cperl-merge-trailing-else: nil
174             ## cperl-continued-statement-offset: 2
175             ## End: