automake-commit
[Top][All Lists]
Advanced

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

[Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-1769


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-1769-g3a7b60b
Date: Wed, 18 Jan 2012 18:06:56 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=3a7b60b1ca8a2f2b86acf494d649bff66beb445b

The branch, master has been updated
       via  3a7b60b1ca8a2f2b86acf494d649bff66beb445b (commit)
       via  52246cc7355cedbc9cb992095870572beb767ca1 (commit)
      from  c45e3c37a9a0e9df08484ba3a6100af9761a2d97 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3a7b60b1ca8a2f2b86acf494d649bff66beb445b
Merge: c45e3c3 52246cc
Author: Stefano Lattarini <address@hidden>
Date:   Wed Jan 18 18:42:46 2012 +0100

    Merge branch 'maint'
    
    * maint:
      cmdline parsing: move into a dedicated perl module

-----------------------------------------------------------------------

Summary of changes:
 aclocal.in               |   54 ++-------------------
 automake.in              |   56 ++---------------------
 lib/Automake/Getopt.pm   |  115 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/Automake/Makefile.am |    1 +
 tests/getopt.test        |   39 ----------------
 tests/list-of-tests.mk   |    1 -
 6 files changed, 125 insertions(+), 141 deletions(-)
 create mode 100644 lib/Automake/Getopt.pm
 delete mode 100755 tests/getopt.test

diff --git a/aclocal.in b/aclocal.in
index 93ed5eb..8cffe71 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -944,6 +944,8 @@ sub parse_arguments ()
 
   my %cli_options =
     (
+     'help'            => sub { usage(0); },
+     'version'         => \&version,
      'acdir=s'         => \&handle_acdir_option,
      'system-acdir=s'  => sub { shift; @system_includes = @_; },
      'automake-acdir=s'        => sub { shift; @automake_includes = @_; },
@@ -957,55 +959,9 @@ sub parse_arguments ()
      'verbose'         => sub { setup_channel 'verb', silent => 0; },
      'W|warnings=s'     => \&parse_warnings,
      );
-  use Getopt::Long;
-  Getopt::Long::config ("bundling", "pass_through");
-
-  # See if --version or --help is used.  We want to process these before
-  # anything else because the GNU Coding Standards require us to
-  # `exit 0' after processing these options, and we can't guarantee this
-  # if we treat other options first.  (Handling other options first
-  # could produce error diagnostics, and in this condition it is
-  # confusing if aclocal does `exit 0'.)
-  my %cli_options_1st_pass =
-    (
-     'version' => \&version,
-     'help'    => sub { usage(0); },
-     # Recognize all other options (and their arguments) but do nothing.
-     map { $_ => sub {} } (keys %cli_options)
-     );
-  my @ARGV_backup = @ARGV;
-  Getopt::Long::GetOptions %cli_options_1st_pass
-    or exit 1;
-  @ARGV = @ARGV_backup;
-
-  # Now *really* process the options.  This time we know that --help
-  # and --version are not present, but we specify them nonetheless so
-  # that ambiguous abbreviation are diagnosed.
-  Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
-    or exit 1;
-
-  if (@ARGV)
-    {
-      my %argopts;
-      for my $k (keys %cli_options)
-       {
-         if ($k =~ /(.*)=s$/)
-           {
-             map { $argopts{(length ($_) == 1)
-                            ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
-           }
-       }
-      if (exists $argopts{$ARGV[0]})
-       {
-         fatal ("option `$ARGV[0]' requires an argument.\n"
-                . "Try `$0 --help' for more information");
-       }
-      else
-       {
-         fatal ("unrecognized option `$ARGV[0]'\n"
-                . "Try `$0 --help' for more information");
-       }
-    }
+
+  use Automake::Getopt ();
+  Automake::Getopt::parse_options %cli_options;
 
   if ($print_and_exit)
     {
diff --git a/automake.in b/automake.in
index bf9f0c0..df50238 100644
--- a/automake.in
+++ b/automake.in
@@ -8331,6 +8331,8 @@ sub parse_arguments ()
 
   my %cli_options =
     (
+     'version' => \&version,
+     'help'    => \&usage,
      'libdir=s'        => \$libdir,
      'gnu'             => sub { $strict = 'gnu'; },
      'gnits'           => sub { $strict = 'gnits'; },
@@ -8345,32 +8347,9 @@ sub parse_arguments ()
      'v|verbose'       => sub { setup_channel 'verb', silent => 0; },
      'W|warnings=s'     => address@hidden,
      );
-  use Getopt::Long;
-  Getopt::Long::config ("bundling", "pass_through");
-
-  # See if --version or --help is used.  We want to process these before
-  # anything else because the GNU Coding Standards require us to
-  # `exit 0' after processing these options, and we can't guarantee this
-  # if we treat other options first.  (Handling other options first
-  # could produce error diagnostics, and in this condition it is
-  # confusing if Automake does `exit 0'.)
-  my %cli_options_1st_pass =
-    (
-     'version' => \&version,
-     'help'    => \&usage,
-     # Recognize all other options (and their arguments) but do nothing.
-     map { $_ => sub {} } (keys %cli_options)
-     );
-  my @ARGV_backup = @ARGV;
-  Getopt::Long::GetOptions %cli_options_1st_pass
-    or exit 1;
-  @ARGV = @ARGV_backup;
 
-  # Now *really* process the options.  This time we know that --help
-  # and --version are not present, but we specify them nonetheless so
-  # that ambiguous abbreviation are diagnosed.
-  Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
-    or exit 1;
+  use Automake::Getopt ();
+  Automake::Getopt::parse_options %cli_options;
 
   set_strictness ($strict);
   my $cli_where = new Automake::Location;
@@ -8383,33 +8362,6 @@ sub parse_arguments ()
 
   return unless @ARGV;
 
-  if ($ARGV[0] =~ /^-./)
-    {
-      my %argopts;
-      for my $k (keys %cli_options)
-       {
-         if ($k =~ /(.*)=s$/)
-           {
-             map { $argopts{(length ($_) == 1)
-                            ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
-           }
-       }
-      if ($ARGV[0] eq '--')
-       {
-         shift @ARGV;
-       }
-      elsif (exists $argopts{$ARGV[0]})
-       {
-         fatal ("option `$ARGV[0]' requires an argument.\n"
-                . "Try `$0 --help' for more information");
-       }
-      else
-       {
-         fatal ("unrecognized option `$ARGV[0]'.\n"
-                . "Try `$0 --help' for more information");
-       }
-    }
-
   my $errspec = 0;
   foreach my $arg (@ARGV)
     {
diff --git a/lib/Automake/Getopt.pm b/lib/Automake/Getopt.pm
new file mode 100644
index 0000000..84cee5e
--- /dev/null
+++ b/lib/Automake/Getopt.pm
@@ -0,0 +1,115 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+package Automake::Getopt;
+
+=head1 NAME
+
+Automake::Getopt - GCS conforming parser for command line options
+
+=head1 SYNOPSIS
+
+  use Automake::Getopt;
+
+=head1 DESCRIPTION
+
+Export a function C<parse_options>, performing parsing of command
+line options in conformance to the GNU Coding standards.
+
+=cut
+
+use 5.006_002;
+use strict;
+use warnings FATAL => 'all';
+use Exporter ();
+use Getopt::Long ();
+use Automake::ChannelDefs qw/fatal/;
+use Carp qw/croak confess/;
+
+use vars qw (@ISA @EXPORT);
address@hidden = qw (Exporter);
address@hidden qw/getopt/;
+
+=item C<parse_options (%option)>
+
+Wrapper around C<Getopt::Long>, trying to conform to the GNU
+Coding Standards for error messages.
+
+=cut
+
+sub parse_options (%)
+{
+  my %option = @_;
+
+  Getopt::Long::Configure ("bundling", "pass_through");
+  # Unrecognized options are passed through, so GetOption can only fail
+  # due to internal errors or misuse of options specification.
+  Getopt::Long::GetOptions (%option)
+    or confess "error in options specification (likely)";
+
+  if (@ARGV && $ARGV[0] =~ /^-./)
+    {
+      my %argopts;
+      for my $k (keys %option)
+       {
+         if ($k =~ /(.*)=s$/)
+           {
+             map { $argopts{(length ($_) == 1)
+                            ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
+           }
+       }
+      if ($ARGV[0] eq '--')
+       {
+         shift @ARGV;
+       }
+      elsif (exists $argopts{$ARGV[0]})
+       {
+         fatal ("option `$ARGV[0]' requires an argument\n"
+                . "Try `$0 --help' for more information.");
+       }
+      else
+       {
+         fatal ("unrecognized option `$ARGV[0]'.\n"
+                . "Try `$0 --help' for more information.");
+       }
+    }
+}
+
+=back
+
+=head1 SEE ALSO
+
+L<Getopt::Long>
+
+=cut
+
+1; # for require
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/lib/Automake/Makefile.am b/lib/Automake/Makefile.am
index 9805024..ac9356a 100644
--- a/lib/Automake/Makefile.am
+++ b/lib/Automake/Makefile.am
@@ -25,6 +25,7 @@ dist_perllib_DATA = \
   DisjConditions.pm \
   FileUtils.pm \
   General.pm \
+  Getopt.pm \
   Item.pm \
   ItemDef.pm \
   Location.pm \
diff --git a/tests/getopt.test b/tests/getopt.test
deleted file mode 100755
index 41aca0c..0000000
--- a/tests/getopt.test
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2002, 2003, 2008, 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Automake --help, and --version should have priority over any other option
-# so that their `Exit 0' is coherent.
-
-. ./defs || Exit 1
-
-# This is expected to fail ...
-AUTOMAKE_fails -Wnonexistent
-grep ':.*nonexistent' stderr
-
-# ... but this should not.
-AUTOMAKE_run -Wnonexistent --help
-grep ':.*nonexistent' stderr && Exit 1
-
-
-# Similarly, this should fail ...
-AUTOMAKE_fails --nonexistent
-grep ':.*nonexistent' stderr
-
-# ... but this should not.
-AUTOMAKE_run --nonexistent --help
-grep ':.*nonexistent' stderr && Exit 1
-
-:
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index 8f7c490..31d70a7 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -437,7 +437,6 @@ gcj3.test \
 gcj4.test \
 gcj5.test \
 gcj6.test \
-getopt.test \
 gettext.test \
 gettext2.test \
 gettext3.test \


hooks/post-receive
-- 
GNU Automake



reply via email to

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