autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Playing with autoscan 2.54 on the Coreutils


From: Akim Demaille
Subject: Re: Playing with autoscan 2.54 on the Coreutils
Date: 27 Sep 2002 09:35:23 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| > We extend autoscan with a means to say `deprecate function, do not use
| > it'.
| 
| Sounds like a good idea.  I would put the inherently unsafe functions
| like gets into this camp, too.

I'm installing the following patch.  All the lib/autoscan/* files
needs being updated...  ;-)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * bin/autoscan.in: Improve the comments.
        (&parse_args): Drop obsolete undocumented options.
        (&output_kind): Output warnings.
        * lib/autoscan/functions: (dcgettext): Now trigger AM_GNU_GETTEXT.
        (getwd): Trigger a warning.

Index: bin/autoscan.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autoscan.in,v
retrieving revision 1.81
diff -u -u -r1.81 autoscan.in
--- bin/autoscan.in 12 Sep 2002 15:04:18 -0000 1.81
+++ bin/autoscan.in 27 Sep 2002 07:34:12 -0000
@@ -43,16 +43,6 @@
       auto extern register typedef static goto return sizeof break
       continue if else for do while switch case default);
 
-# $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 = ();
-
 my @kinds = qw (functions headers identifiers programs
                 makevars libraries);
 
@@ -68,12 +58,28 @@
 
 my %kind_comment =
   (
-   'functions' => 'Checks for library functions.',
-   'headers' => 'Checks for header files.',
+   'functions'   => 'Checks for library functions.',
+   'headers'     => 'Checks for header files.',
    'identifiers' => 'Checks for typedefs, structures, and compiler 
characteristics.',
-   'programs' => 'Checks for programs.',
+   'programs'    => 'Checks for programs.',
   );
 
+# $USED{KIND}{ITEM} is the list of locations where the ITEM (of KIND) was used
+# in the user package.
+# For instance $USED{function}{alloca} is the list of `file:line' where
+# `alloca (...)' appears.
+my %used = ();
+
+# $MACRO{KIND}{ITEM} is the list of macros to use to test ITEM.
+# Initialized from lib/autoscan/*.  E.g., $MACRO{function}{alloca} contains
+# the singleton AC_FUNC_ALLOCA.  Some require several checks.
+my %macro = ();
+
+# $NEEDED_MACROS{MACRO} is an array of locations requiring MACRO.
+# E.g., $NEEDED_MACROS{AC_FUNC_ALLOC} the list of `file:line' containing
+# `alloca (...)'.
+my %needed_macros = ();
+
 my $configure_scan = 'configure.scan';
 my $log = new Autom4te::XFile ">$me.log";
 
@@ -123,7 +129,7 @@
 # Process any command line arguments.
 sub parse_args ()
 {
-  getopt ('I|include|A|autoconf-dir|m|macrodir=s' => address@hidden,
+  getopt ('I|include=s' => address@hidden,
          'B|prepend-include=s' => address@hidden);
 
   die "$me: too many arguments
@@ -162,25 +168,31 @@
          # Ignore blank lines and comments.
          next
            if /^\s*$/ || /^\s*\#/;
-         unless (/^(\S+)\s+(\S.*)$/ || /^(\S+)\s*$/)
-           {
-             error "cannot parse definition in $file:\n$_";
-           }
-         my $word = $1;
-         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
+
+         # '<word>        <macro invocation>' or...
+         # '<word>        warn: <message>'    or...
+         # '<word>'.
+         if (/^(\S+)\s+(\S.*)$/ || /^(\S+)\s*$/)
            {
-             push @{$macro{$kind}{$word}}, $macro;
+             my $word = $1;
+             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
+               {
+                 push @{$macro{$kind}{$word}}, $macro;
+               }
+             next;
            }
+
+         error "cannot parse definition in $file:\n$_";
        }
       $table->close;
     }
@@ -200,6 +212,7 @@
   push (@{$used{$kind}{$word}}, $where);
 }
 
+
 ## ----------------------- ##
 ## Scanning source files.  ##
 ## ----------------------- ##
@@ -436,7 +449,15 @@
       # already printed, and remember these macros are needed.
       foreach my $macro (@{$macro{$kind}{$word}})
        {
-         if (exists $generic_macro{$kind}
+         if ($macro =~ /^warn:\s+(.*)/)
+           {
+             my $message = $1;
+             foreach my $location (@{$used{$kind}{$word}})
+               {
+                 warn "$location: warning: $message\n";
+               }
+           }
+         elsif (exists $generic_macro{$kind}
              && $macro eq $generic_macro{$kind})
            {
              push (@have, $word);
Index: lib/autoscan/functions
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoscan/functions,v
retrieving revision 1.18
diff -u -u -r1.18 functions
--- lib/autoscan/functions 17 Jul 2002 08:09:43 -0000 1.18
+++ lib/autoscan/functions 27 Sep 2002 07:34:13 -0000
@@ -21,9 +21,10 @@
 alloca         AC_FUNC_ALLOCA
 bcmp           AC_HEADER_STDC
 bcopy          AC_HEADER_STDC
-bzero          AC_HEADER_STDC
 bzero          AC_CHECK_FUNCS
+bzero          AC_HEADER_STDC
 chown          AC_FUNC_CHOWN
+dcgettext       AM_GNU_GETTEXT
 error          AC_FUNC_ERROR_AT_LINE
 error_at_line  AC_FUNC_ERROR_AT_LINE
 fnmatch                AC_FUNC_FNMATCH
@@ -37,16 +38,16 @@
 ioctl          AC_PROG_GCC_TRADITIONAL
 lstat          AC_FUNC_LSTAT
 major          AC_HEADER_MAJOR
-malloc         AC_FUNC_MALLOC
 makedev                AC_HEADER_MAJOR
-memchr         AC_HEADER_STDC
+malloc         AC_FUNC_MALLOC
 memchr         AC_CHECK_FUNCS
+memchr         AC_HEADER_STDC
 memcmp         AC_FUNC_MEMCMP
 memcpy         AC_HEADER_STDC
-memmove                AC_HEADER_STDC
 memmove                AC_CHECK_FUNCS
-memset         AC_HEADER_STDC
+memmove                AC_HEADER_STDC
 memset         AC_CHECK_FUNCS
+memset         AC_HEADER_STDC
 minor          AC_HEADER_MAJOR
 mktime         AC_FUNC_MKTIME
 mmap           AC_FUNC_MMAP
@@ -62,14 +63,17 @@
 strftime       AC_FUNC_STRFTIME
 strnlen                AC_FUNC_STRNLEN
 strtod         AC_FUNC_STRTOD
-utime          AC_FUNC_UTIME_NULL
 utime          AC_CHECK_FUNCS
+utime          AC_FUNC_UTIME_NULL
 vfork          AC_FUNC_FORK
 vfprintf       AC_FUNC_VPRINTF
 vprintf                AC_FUNC_VPRINTF
 vsprintf       AC_FUNC_VPRINTF
 wait3          AC_FUNC_WAIT3
 
+# Functions we should no longer use.
+getwd          warn: getwd is depecrated, use getcwd instead
+
 # Others, checked with AC_CHECK_FUNCS.
 __argz_count
 __argz_next
@@ -80,7 +84,6 @@
 atexit
 btowc
 clock_gettime
-dcgettext
 doprnt
 dup2
 endgrent
@@ -106,7 +109,6 @@
 getspnam
 gettimeofday
 getusershell
-getwd
 hasmntopt
 inet_ntoa
 isascii




reply via email to

[Prev in Thread] Current Thread [Next in Thread]