/[autoconf]/autoconf/bin/autoscan.in
ViewVC logotype

Diff of /autoconf/bin/autoscan.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.81 by akim, Thu Sep 12 15:04:18 2002 UTC revision 1.82 by akim, Fri Sep 27 07:35:39 2002 UTC
# Line 43  my %c_keywords = map { $_ => 1} Line 43  my %c_keywords = map { $_ => 1}
43        auto extern register typedef static goto return sizeof break        auto extern register typedef static goto return sizeof break
44        continue if else for do while switch case default);        continue if else for do while switch case default);
45    
 # $USED{KIND}{ITEM} is set if ITEM is used in the program.  
 # It is set to its list of locations.  
 my %used = ();  
   
 # $MACRO{KIND}{ITEM} is the list of macros to use to test ITEM.  
 my %macro = ();  
   
 # $NEEDED_MACROS{MACRO} is an array of locations requiring MACRO.  
 my %needed_macros = ();  
   
46  my @kinds = qw (functions headers identifiers programs  my @kinds = qw (functions headers identifiers programs
47                  makevars libraries);                  makevars libraries);
48    
# Line 68  my %generic_macro = Line 58  my %generic_macro =
58    
59  my %kind_comment =  my %kind_comment =
60    (    (
61     'functions' => 'Checks for library functions.',     'functions'   => 'Checks for library functions.',
62     'headers' => 'Checks for header files.',     'headers'     => 'Checks for header files.',
63     'identifiers' => 'Checks for typedefs, structures, and compiler characteristics.',     'identifiers' => 'Checks for typedefs, structures, and compiler characteristics.',
64     'programs' => 'Checks for programs.',     'programs'    => 'Checks for programs.',
65    );    );
66    
67    # $USED{KIND}{ITEM} is the list of locations where the ITEM (of KIND) was used
68    # in the user package.
69    # For instance $USED{function}{alloca} is the list of `file:line' where
70    # `alloca (...)' appears.
71    my %used = ();
72    
73    # $MACRO{KIND}{ITEM} is the list of macros to use to test ITEM.
74    # Initialized from lib/autoscan/*.  E.g., $MACRO{function}{alloca} contains
75    # the singleton AC_FUNC_ALLOCA.  Some require several checks.
76    my %macro = ();
77    
78    # $NEEDED_MACROS{MACRO} is an array of locations requiring MACRO.
79    # E.g., $NEEDED_MACROS{AC_FUNC_ALLOC} the list of `file:line' containing
80    # `alloca (...)'.
81    my %needed_macros = ();
82    
83  my $configure_scan = 'configure.scan';  my $configure_scan = 'configure.scan';
84  my $log = new Autom4te::XFile ">$me.log";  my $log = new Autom4te::XFile ">$me.log";
85    
# Line 123  warranty; not even for MERCHANTABILITY o Line 129  warranty; not even for MERCHANTABILITY o
129  # Process any command line arguments.  # Process any command line arguments.
130  sub parse_args ()  sub parse_args ()
131  {  {
132    getopt ('I|include|A|autoconf-dir|m|macrodir=s' => \@include,    getopt ('I|include=s' => \@include,
133            'B|prepend-include=s' => \@prepend_include);            'B|prepend-include=s' => \@prepend_include);
134    
135    die "$me: too many arguments    die "$me: too many arguments
# Line 162  sub init_tables () Line 168  sub init_tables ()
168            # Ignore blank lines and comments.            # Ignore blank lines and comments.
169            next            next
170              if /^\s*$/ || /^\s*\#/;              if /^\s*$/ || /^\s*\#/;
171            unless (/^(\S+)\s+(\S.*)$/ || /^(\S+)\s*$/)  
172              {            # '<word>        <macro invocation>' or...
173                error "cannot parse definition in $file:\n$_";            # '<word>        warn: <message>'    or...
174              }            # '<word>'.
175            my $word = $1;            if (/^(\S+)\s+(\S.*)$/ || /^(\S+)\s*$/)
           my $macro = $2 || $generic_macro{$kind};  
           # The default macro must be explicitly listed for words  
           # which have a specific macros.  This allows to enforce  
           # consistency checks.  
           if (!defined $2 && exists $macro{$kind}{$word})  
             {  
               warn ("$file:$.: "  
                     . "ignoring implicit call to the generic macro for $word\n");  
               $tables_are_consistent = 0;  
             }  
           else  
176              {              {
177                push @{$macro{$kind}{$word}}, $macro;                my $word = $1;
178                  my $macro = $2 || $generic_macro{$kind};
179                  # The default macro must be explicitly listed for words
180                  # which have a specific macros.  This allows to enforce
181                  # consistency checks.
182                  if (!defined $2 && exists $macro{$kind}{$word})
183                    {
184                      warn ("$file:$.: "
185                            . "ignoring implicit call to the generic macro for $word\n");
186                      $tables_are_consistent = 0;
187                    }
188                  else
189                    {
190                      push @{$macro{$kind}{$word}}, $macro;
191                    }
192                  next;
193              }              }
194    
195              error "cannot parse definition in $file:\n$_";
196          }          }
197        $table->close;        $table->close;
198      }      }
# Line 200  sub used ($$;$) Line 212  sub used ($$;$)
212    push (@{$used{$kind}{$word}}, $where);    push (@{$used{$kind}{$word}}, $where);
213  }  }
214    
215    
216  ## ----------------------- ##  ## ----------------------- ##
217  ## Scanning source files.  ##  ## Scanning source files.  ##
218  ## ----------------------- ##  ## ----------------------- ##
# Line 436  sub output_kind ($$) Line 449  sub output_kind ($$)
449        # already printed, and remember these macros are needed.        # already printed, and remember these macros are needed.
450        foreach my $macro (@{$macro{$kind}{$word}})        foreach my $macro (@{$macro{$kind}{$word}})
451          {          {
452            if (exists $generic_macro{$kind}            if ($macro =~ /^warn:\s+(.*)/)
453                {
454                  my $message = $1;
455                  foreach my $location (@{$used{$kind}{$word}})
456                    {
457                      warn "$location: warning: $message\n";
458                    }
459                }
460              elsif (exists $generic_macro{$kind}
461                && $macro eq $generic_macro{$kind})                && $macro eq $generic_macro{$kind})
462              {              {
463                push (@have, $word);                push (@have, $word);

Legend:
Removed from v.1.81  
changed lines
  Added in v.1.82

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26