From: Akim Demaille Date: Mon, 2 Jun 2003 06:55:03 +0000 (+0000) Subject: * bin/autom4te.in, bin/autoscan.in, bin/autoheader.in: White space X-Git-Tag: AUTOCONF-2.57a~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff9230c1463ebaadcf08f01f620f7c9a1985b82a;p=thirdparty%2Fautoconf.git * bin/autom4te.in, bin/autoscan.in, bin/autoheader.in: White space changes. * lib/Autom4te/General.pm (&backname): Remove, no longer used by Autoconf nor Automake. (&contents): New, from Automake. PODify. * lib/autoconf/c.m4 (_AC_PROG_CXX_EXIT_DECLARATION): Remove `#include ' from the list; we should never --- diff --git a/ChangeLog b/ChangeLog index ccf3260f4..8eb1cf4d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-06-02 Akim Demaille + + * bin/autom4te.in, bin/autoscan.in, bin/autoheader.in: White space + changes. + * lib/Autom4te/General.pm (&backname): Remove, no longer used by + Autoconf nor Automake. + (&contents): New, from Automake. + PODify. + +- and Paul Eggert ++ and Paul Eggert + + * lib/autoconf/c.m4 (_AC_PROG_CXX_EXIT_DECLARATION): + Remove `#include ' from the list; we should never + 2003-05-28 Paul Eggert * NEWS, doc/autoconf.texi (Particular Functions), diff --git a/bin/autoheader.in b/bin/autoheader.in index 59ea90b29..407d3d3e7 100644 --- a/bin/autoheader.in +++ b/bin/autoheader.in @@ -150,7 +150,7 @@ if ($config_h_top || $config_h_bot || $acconfig_h) \`acconfig.h\': AC_DEFINE([NEED_MAIN], 1, - [Define if a function \`main\' is needed.]) + [Define if a function \`main\' is needed.]) More sophisticated templates can also be produced, see the documentation. diff --git a/bin/autom4te.in b/bin/autom4te.in index cb9fa748a..97e18d7c8 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -134,10 +134,10 @@ sub request ($%) foreach (@{$request{'macro'}}) { if (! exists ${$req->macro}{$_}) - { - ${$req->macro}{$_} = 1; - $req->valid (0); - } + { + ${$req->macro}{$_} = 1; + $req->valid (0); + } } # It would be great to have $REQ check that it up to date wrt its @@ -864,7 +864,7 @@ sub trace_format_to_m4 ($) } # $x, no separator given. elsif (s/^\$([fldn\$])//) - { + { $res .= $escape{$1}; } # $.x or ${sep}x. @@ -888,14 +888,14 @@ sub trace_format_to_m4 ($) } } elsif (/^(\$.)/) - { + { error "invalid escape: $1"; - } + } else - { + { s/^([^\$]+)//; $res .= $1; - } + } } $_ = $underscore; @@ -935,26 +935,26 @@ sub handle_traces ($$%) # and no new line remains. define([_at_at], [at_ifelse([$#], [1], [], - [$#], [2], [[[$2]]], - [[[$2]][$1]$0([$1], at_shift(at_shift($@)))])]) + [$#], [2], [[[$2]]], + [[[$2]][$1]$0([$1], at_shift(at_shift($@)))])]) define([_at_percent], [at_ifelse([$#], [1], [], - [$#], [2], [at_flatten([$2])], - [at_flatten([$2])[$1]$0([$1], at_shift(at_shift($@)))])]) + [$#], [2], [at_flatten([$2])], + [at_flatten([$2])[$1]$0([$1], at_shift(at_shift($@)))])]) define([_at_star], [at_ifelse([$#], [1], [], - [$#], [2], [[$2]], - [[$2][$1]$0([$1], at_shift(at_shift($@)))])]) + [$#], [2], [[$2]], + [[$2][$1]$0([$1], at_shift(at_shift($@)))])]) # FLATTEN quotes its result. # Note that the second pattern is `newline, tab or space'. Don't lose # the tab! define([at_flatten], [at_patsubst(at_patsubst(at_patsubst(at_patsubst([[[[$1]]]], [\\\n]), - [[\n\t ]+], [ ]), - [ *\(.\)$], [\1]), + [[\n\t ]+], [ ]), + [ *\(.\)$], [\1]), [^ *\(.*\)], [[\1]])]) define([at_args], [at_shift(at_shift(at_shift(at_shift(at_shift($@)))))]) diff --git a/bin/autoscan.in b/bin/autoscan.in index 2851bc4fb..d1bcf818b 100644 --- a/bin/autoscan.in +++ b/bin/autoscan.in @@ -46,7 +46,7 @@ use vars qw(@cfiles @makefiles @shfiles %printed); # The kind of the words we are looking for. my @kinds = qw (function header identifier program - makevar librarie); + makevar librarie); # For each kind, the default macro. my %generic_macro = @@ -603,9 +603,9 @@ sub check_configure_ac ($) . "\n"); print $log "$me: warning: missing $macro wanted by: \n"; foreach my $need (@{$needed_macros{$macro}}) - { - print $log "\t$need\n"; - } + { + print $log "\t$need\n"; + } } } diff --git a/lib/Autom4te/General.pm b/lib/Autom4te/General.pm index 083fdc806..ed0a88486 100644 --- a/lib/Autom4te/General.pm +++ b/lib/Autom4te/General.pm @@ -18,6 +18,21 @@ package Autom4te::General; +=head1 NAME + +Autom4te::General - general support functions for Autoconf and Automake + +=head1 SYNOPSIS + + use Autom4te::General + +=head1 DESCRIPTION + +This perl module provides various general purpose support functions +used in several executables of the Autoconf and Automake packages. + +=cut + use 5.005_03; use Exporter; use File::Basename; @@ -37,7 +52,7 @@ my @export_vars = # Functions we define and export. my @export_subs = - qw (&backname &catfile &canonpath &debug &error + qw (&catfile &canonpath &contents &debug &error &file_name_is_absolute &find_configure_ac &find_file &getopt &mktmpdir &mtime &uniq &update_file &up_to_date_p &verbose &xsystem &xqx); @@ -48,32 +63,88 @@ my @export_forward_subs = @EXPORT = (@export_vars, @export_subs, @export_forward_subs); + # Variable we share with the main package. Be sure to have a single # copy of them: using `my' together with multiple inclusion of this # package would introduce several copies. + +=head2 Global Variables + +=over 4 + +=item C<$debug> + +Set this variable to 1 if debug messages should be enabled. Debug +messages are meant for developpers only, or when tracking down an +incorrect execution. + +=cut + use vars qw ($debug); $debug = 0; -# Recreate all the files, or consider all the output files are obsolete. +=item C<$force> + +Set this variable to 1 to recreate all the files, or to consider all +the output files are obsolete. + +=cut + use vars qw ($force); $force = undef; +=item C<$help> + +Set to the help message associated to the option C<--help>. + +=cut + use vars qw ($help); $help = undef; +=item C<$me> + +The name of this application, as should be used in diagostic messages. + +=cut + use vars qw ($me); $me = basename ($0); +=item C<$tmp> + +The name of the temporary directory created by C. Left +C otherwise. + +=cut + # Our tmp dir. use vars qw ($tmp); $tmp = undef; +=item C<$verbose> + +Enable verbosity messages. These messages are meant for ordinary +users, and typically make explicit the steps being performed. + +=cut + use vars qw ($verbose); $verbose = 0; +=item C<$version> + +Set to the version message associated to the option C<--version>. + +=cut + use vars qw ($version); $version = undef; +=back + +=cut + ## ------------ ## ## Prototypes. ## @@ -86,11 +157,19 @@ sub verbose (@); ## END. ## ## ----- ## +=head2 Functions + +=over 4 + +=item C + +Filter Perl's exit codes, delete any temporary directory (unless +C<$debug>), and exit nonzero whenever closing C fails. + +=cut # END # --- -# Filter Perl's exit codes, delete any temporary directory, and exit -# nonzero whenever closing STDOUT fails. sub END { # $? contains the exit status we will return. @@ -149,36 +228,13 @@ sub END ## Functions. ## ## ----------- ## +=item C -# $BACKPATH -# &backname ($REL-DIR) -# -------------------- -# If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'. -# For instance `src/foo' => `../..'. -# Works with non strictly increasing paths, i.e., `src/../lib' => `..'. -sub backname ($) -{ - my ($file) = @_; - my $underscore = $_; - my @res; - - foreach (split (/\//, $file)) - { - next if $_ eq '.' || $_ eq ''; - if ($_ eq '..') - { - pop @res; - } - else - { - push (@res, '..'); - } - } - - $_ = $underscore; - return canonpath (catfile (@res)) -} +Wrapper around Ccatfile>. Concatenate one or more +directory names and a filename to form a complete path ending with a +filename. +=cut # $FILE # &catfile (@COMPONENT) @@ -190,6 +246,16 @@ sub catfile (@) } +=item C + +Wrapper around Ccanonpath>. No physical check on the +filesystem, but a logical cleanup of a path. On UNIX eliminates +successive slashes and successive "/.". + + $cpath = canonpath ($path) ; + +=cut + # $FILE # &canonpath ($FILE) # ------------------ @@ -200,6 +266,34 @@ sub canonpath ($) } +=item C + +Return the contents of c<$filename>. Exit with diagnostic on failure. + +=cut + +# &contents ($FILENAME) +# --------------------- +# Swallow the contents of file $FILENAME. +sub contents ($) +{ + my ($file) = @_; + verbose "reading $file"; + local $/; # Turn on slurp-mode. + my $f = new Autom4te::XFile "< $file"; + my $contents = $f->getline; + $f->close; + return $contents; +} + + +=item C + +If the debug mode is enabled (C<$debug> and C<$verbose>), report the +C<@message> on C, signed with the name of the program. + +=cut + # &debug(@MESSAGE) # ---------------- # Messages displayed only if $DEBUG and $VERBOSE. @@ -210,6 +304,14 @@ sub debug (@) } +=item C + +Report the C<@message> on C, signed with the name of the +program, and exit with failure. If the debug mode is enabled +(C<$debug>), then in addition dump the call stack. + +=cut + # &error (@MESSAGE) # ----------------- # Same as die or confess, depending on $debug. @@ -226,6 +328,13 @@ sub error (@) } +=item C + +Wrapper around Cfile_name_is_absolute>. Return true iff +C<$filename> is absolute. + +=cut + # $BOOLEAN # &file_name_is_absolute ($FILE) # ------------------------------ @@ -236,6 +345,14 @@ sub file_name_is_absolute ($) } +=item C])> + +Look for C or C in the C<$directory> and +return the one which should be used. Report ambiguities to the user, +but prefer C. + +=cut + # $CONFIGURE_AC # &find_configure_ac ([$DIRECTORY = `.']) # --------------------------------------- @@ -263,15 +380,22 @@ sub find_configure_ac (;$) } +=item C + +Return the first path for a C<$filename> in the Cs. + +We match exactly the behavior of GNU M4: first look in the current +directory (which includes the case of absolute file names), and, if +the file is not absolute, just fail. Otherwise, look in C<@include>. + +If the file is flagged as optional (ends with C), then return undef +if absent, otherwise exit with error. + +=cut + # $FILENAME # find_file ($FILENAME, @INCLUDE) # ------------------------------- -# We match exactly the behavior of GNU M4: first look in the current -# directory (which includes the case of absolute file names), and, if -# the file is not absolute, just fail. Otherwise, look in @INCLUDE. -# -# If the file is flagged as optional (ends with `?'), then return undef -# if absent. sub find_file ($@) { my ($filename, @include) = @_; @@ -303,6 +427,17 @@ sub find_file ($@) } +=item C + +Wrapper around C. In addition to the user C