[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
66-fyi-general-getopt.patch
From: |
Akim Demaille |
Subject: |
66-fyi-general-getopt.patch |
Date: |
Fri, 31 Aug 2001 15:30:45 +0200 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* lib/Autom4te/General.pm ($version, $help, &getopt): New.
* bin/autoupdate.in, bin/autoheader.in, bin/autom4te.in: Use them.
* bin/autom4te.in ($autoconf): Pass --force.
`print $out' doesn't print `$_' but `$out'.
* tests/tools.at (Syntax of the Perl scripts): Pass the lib dir.
(autoheader): Pass --force since the test suite goes too fast for
the time stamps.
Adjust to the new autoheader messages.
Index: bin/autoheader.in
--- bin/autoheader.in Fri, 31 Aug 2001 10:25:28 +0200 akim
+++ bin/autoheader.in Fri, 31 Aug 2001 11:16:09 +0200 akim
@@ -53,17 +53,9 @@
my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
-## ---------- ##
-## Routines. ##
-## ---------- ##
-
-
-# print_usage ()
-# --------------
-# Display usage (--help).
-sub print_usage ()
-{
- print <<"END";
+# $HELP
+# -----
+$help = <<"END";
Usage: $0 [OPTION] ... [TEMPLATE-FILE]
Create a template file of C \`#define\' statements for \`configure\' to
@@ -90,16 +82,11 @@ Usage: $0 [OPTION] ... [TEMPLATE-FILE]
Report bugs to <address@hidden>.
END
- exit 0;
-}
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<END;
+# $VERSION
+# --------
+$version = <<"END";
autoheader (@PACKAGE_NAME@) @VERSION@
Written by Roland McGrath.
@@ -108,8 +95,11 @@ sub print_version
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
END
- exit 0;
-}
+
+
+## ---------- ##
+## Routines. ##
+## ---------- ##
# parse_args ()
@@ -122,16 +112,10 @@ sub parse_args ()
# If fixed some day, use this: '' => sub { push @ARGV, "-" }
my $stdin = grep /^-$/, @ARGV;
@ARGV = grep !/^-$/, @ARGV;
- Getopt::Long::config ("bundling");
- Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
- 'l|localdir=s' => \$localdir,
- 'd|debug' => \$debug,
- 'h|help' => \&print_usage,
- 'V|version' => \&print_version,
- 'v|verbose' => \$verbose,
- 'f|force' => \$force,
- 'W|warning' => address@hidden)
- or exit 1;
+ getopt ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
+ 'l|localdir=s' => \$localdir,
+ 'f|force' => \$force,
+ 'W|warning' => address@hidden);
push @ARGV, '-'
if $stdin;
@@ -180,8 +164,9 @@ sub parse_args ()
# Set up autoconf.
$autoconf .= " --include=$autoconf_dir --include=$localdir";
-$autoconf .= ' --verbose' if $verbose;
$autoconf .= ' --debug' if $debug;
+$autoconf .= ' --force' if $force;
+$autoconf .= ' --verbose' if $verbose;
# ----------------------- #
# Real work starts here. #
@@ -219,7 +204,7 @@ sub parse_args ()
my $in = new IO::File ($config_h_top);
while ($_ = $in->getline)
{
- print $out;
+ print $out $_;
}
}
@@ -231,7 +216,7 @@ sub parse_args ()
{
last if /address@hidden@/;
next if /address@hidden@/;
- print $out;
+ print $out $_;
}
}
@@ -248,7 +233,7 @@ sub parse_args ()
my $dump = 0;
while ($_ = $in->getline)
{
- print $out if $dump;
+ print $out $_ if $dump;
$dump = 1 if /address@hidden@/;
}
}
@@ -259,7 +244,7 @@ sub parse_args ()
my $in = new IO::File ($config_h_bot);
while ($_ = $in->getline)
{
- print $out;
+ print $out $_;
}
}
Index: bin/autom4te.in
--- bin/autom4te.in Fri, 31 Aug 2001 09:41:25 +0200 akim
+++ bin/autom4te.in Fri, 31 Aug 2001 10:42:49 +0200 akim
@@ -230,7 +230,6 @@ sub load
package Autom4te;
use Autom4te::General;
-use Getopt::Long;
use File::Basename;
use IO::File;
use strict;
@@ -352,21 +351,9 @@ sub load
@m4_builtin_alternate_name{"m4wrap", "m4_wrap"} = ("m4_wrap", "m4wrap");
-
-
-
-## ---------- ##
-## Routines. ##
-## ---------- ##
-
-
-# print_usage ()
-# --------------
-# Display usage (--help).
-sub print_usage ()
-{
- # Quotes are backslahed to help Emacs' font-lock-mode.
- print <<EOF;
+# $HELP
+# -----
+$help = << "EOF";
Usage: $0 [OPTION] ... [FILES]
Run GNU M4 on the FILES, avoiding useless runs. If tracing, the output
@@ -415,16 +402,10 @@ Tracing:
Report bugs to <address@hidden>.
EOF
- exit 0;
-}
-
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<EOF;
+# $VERSION
+# --------
+$version = <<"EOF";
autom4te (@PACKAGE_NAME@) @VERSION@
Written by Akim Demaille.
@@ -433,8 +414,10 @@ sub print_version
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
- exit 0;
-}
+
+## ---------- ##
+## Routines. ##
+## ---------- ##
# load_configuration ()
@@ -486,16 +469,8 @@ sub parse_args ()
# We want to look for the early options, which should not be found
# in the configuration file. Prepend to the user arguments.
- Getopt::Long::Configure ("bundling", "pass_through");
- GetOptions (
- "h|help" => \&print_usage,
- "V|version" => \&print_version,
-
- "s|language=s" => \$language,
- "v|verbose" => \$verbose,
- "d|debug" => \$debug,
- )
- or exit 1;
+ Getopt::Long::Configure ("pass_through");
+ getopt ("s|language=s" => \$language);
Getopt::Long::Configure ("defaults");
unshift @ARGV, @{$language{$language}}
if $language;
@@ -504,8 +479,7 @@ sub parse_args ()
if $debug;
# Process the arguments for real this time.
- Getopt::Long::Configure ("bundling");
- GetOptions
+ getopt
(
# Operation modes:
"o|output=s" => \$output,
@@ -525,8 +499,7 @@ sub parse_args ()
# by hand.
"t|trace=s" => address@hidden,
"p|preselect=s" => address@hidden,
- )
- or exit 1;
+ );
die "$me: too few arguments
Try `$me --help' for more information.\n"
Index: bin/autoupdate.in
--- bin/autoupdate.in Fri, 31 Aug 2001 09:41:25 +0200 akim
+++ bin/autoupdate.in Fri, 31 Aug 2001 10:47:10 +0200 akim
@@ -27,7 +27,6 @@
unshift @INC, "$perllibdir";
}
-use Getopt::Long;
use File::Basename;
use Autom4te::General;
use strict;
@@ -40,17 +39,9 @@
my $m4 = $ENV{"M4"} || "@M4@";
-## ---------- ##
-## Routines. ##
-## ---------- ##
-
-
-# print_usage ()
-# --------------
-# Display usage (--help).
-sub print_usage ()
-{
- print <<"END";
+# $HELP
+# -----
+$help = <<"END";
Usage: $0 [OPTION] ... [TEMPLATE-FILE...]
Update the TEMPLATE-FILE... if given, or \`configure.ac\' if present,
@@ -73,16 +64,10 @@ Usage: $0 [OPTION] ... [TEMPLATE-FILE..
Report bugs to <address@hidden>.
END
- exit 0;
-}
-
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<END;
+# $VERSION
+# --------
+$version = <<"END";
autoupdate (@PACKAGE_NAME@) @VERSION@
Written by David J. MacKenzie and Akim Demaille.
@@ -90,8 +75,11 @@ sub print_version
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
END
- exit 0;
-}
+
+
+## ---------- ##
+## Routines. ##
+## ---------- ##
# parse_args ()
@@ -104,14 +92,8 @@ sub parse_args ()
# If fixed some day, use this: '' => sub { push @ARGV, "-" }
my $update_stdin = grep /^-$/, @ARGV;
@ARGV = grep !/^-$/, @ARGV;
- Getopt::Long::config ("bundling");
- Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
- 'l|localdir=s' => \$localdir,
- 'd|debug' => \$debug,
- 'h|help' => \&print_usage,
- 'V|version' => \&print_version,
- 'v|verbose' => \$verbose)
- or exit 1;
+ getopt ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
+ 'l|localdir=s' => \$localdir);
push @ARGV, '-'
if $update_stdin;
Index: lib/Autom4te/General.pm
--- lib/Autom4te/General.pm Fri, 31 Aug 2001 10:25:28 +0200 akim
+++ lib/Autom4te/General.pm Fri, 31 Aug 2001 10:36:23 +0200 akim
@@ -20,7 +20,6 @@
use 5.005;
use Exporter;
-use Getopt::Long;
use File::Basename;
use File::stat;
use IO::File;
@@ -30,26 +29,32 @@
use vars qw (@ISA @EXPORT);
@ISA = qw (Exporter);
address@hidden = qw (&find_configure_ac &find_file &mktmpdir &mtime
address@hidden = qw (&find_configure_ac &find_file &getopt &mktmpdir &mtime
&uniq &update_file &verbose &xsystem
- $me $verbose $debug $tmp);
+ $debug $help $me $tmp $verbose $version);
# 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.
-use vars qw ($me);
-$me = basename ($0);
-
-use vars qw ($verbose);
-$verbose = 0;
-
use vars qw ($debug);
$debug = 0;
+use vars qw ($help);
+$help = undef;
+
+use vars qw ($me);
+$me = basename ($0);
+
# Our tmp dir.
use vars qw ($tmp);
$tmp = undef;
+use vars qw ($verbose);
+$verbose = 0;
+
+use vars qw ($version);
+$version = undef;
+
# END
# ---
@@ -145,6 +150,26 @@ sub find_file ($@)
unless $optional;
return undef;
+}
+
+
+# getopt (%OPTIONS)
+# -----------------
+sub getopt (%)
+{
+ my (%option) = @_;
+ use Getopt::Long;
+
+ %option = (%option,
+ "h|help" => sub { print $help; exit 0 },
+ "V|version" => sub { print $version; exit 0 },
+
+ "v|verbose" => \$verbose,
+ "d|debug" => \$debug,
+ );
+ Getopt::Long::Configure ("bundling");
+ GetOptions (%option)
+ or exit 1;
}
Index: tests/tools.at
--- tests/tools.at Fri, 31 Aug 2001 10:25:28 +0200 akim
+++ tests/tools.at Fri, 31 Aug 2001 11:17:33 +0200 akim
@@ -97,10 +97,14 @@
# | % perl -c ./autom4te
# | ./autom4te syntax OK
# Ignore it, it might change between releases.
-AT_CHECK([$PERL -c ../bin/autom4te], 0, [], [ignore])
-AT_CHECK([$PERL -c ../bin/autoheader], 0, [], [ignore])
-AT_CHECK([$PERL -c ../bin/autoscan], 0, [], [ignore])
-AT_CHECK([$PERL -c ../bin/autoupdate], 0, [], [ignore])
+AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autom4te],
+ 0, [], [ignore])
+AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autoheader],
+ 0, [], [ignore])
+AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autoscan],
+ 0, [], [ignore])
+AT_CHECK([autom4te_perllibdir=$top_srcdir/lib $PERL -c ../bin/autoupdate],
+ 0, [], [ignore])
AT_CLEANUP
@@ -386,27 +390,28 @@ configure:18: error: possibly undefined
# 1. Check that `acconfig.h' is still honored.
AT_DATA([configure.ac],
[[AC_INIT
-AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_HEADERS(config.h:config.hin)
AC_DEFINE(this, "whatever you want.")
]])
-AT_CHECK([autoheader -<configure.ac], 0,
-[[/* config.h.in. Generated automatically from Standard input by autoheader.
*/
+AT_CHECK_AUTOHEADER([], [], [], [ignore])
+AT_CHECK([cat config.hin], 0,
+[[/* config.hin. Generated from configure.ac by autoheader. */
/* Define this to whatever you want. */
#undef this
-]], ignore)
+]])
# 2. Check that missing templates are a fatal error.
AT_DATA([configure.ac],
[[AC_INIT
-AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_HEADERS(config.h:config.hin)
AC_DEFINE(that, "whatever you want.")
]])
-AT_CHECK([autoheader -<configure.ac], 1, [],
-[autoheader: No template for symbol `that'
-])
+# The test suite goes too fast for the cache time stamps...
+# Pass --force.
+AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
# 3. Check TOP and BOTTOM.
@@ -420,7 +425,7 @@ configure:18: error: possibly undefined
AT_DATA([configure.ac],
[[AC_INIT
-AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_HEADERS(config.h:config.hin)
AH_TOP([Top1 from configure.ac.])
AH_TOP([Top2 from configure.ac.])
AH_VERBATIM([Middle], [Middle from configure.ac.])
@@ -434,10 +439,10 @@ configure:18: error: possibly undefined
# together.
# Ignore STDERR which is the longuish complaint against autoheader junk
# files.
-AT_CHECK([autoheader -<configure.ac], 0,
-[[/* config.h.in. Generated automatically from Standard input by autoheader.
*/
+AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
+AT_CHECK([cat config.hin], 0,
+[[/* config.hin. Generated from configure.ac by autoheader. */
/* Top from acconfig.h. */
-
/* Middle from acconfig.h. */
Top1 from configure.ac.
@@ -450,8 +455,7 @@ configure:18: error: possibly undefined
Bottom2 from configure.ac.
/* Bottom from acconfig.h. */
-]], [ignore])
-
+]])
AT_CLEANUP
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 66-fyi-general-getopt.patch,
Akim Demaille <=