libtool-patches
[Top][All Lists]
Advanced

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

[patch 19/19] 272-gary-sync-m4sh-utils.diff Queue


From: Gary V. Vaughan
Subject: [patch 19/19] 272-gary-sync-m4sh-utils.diff Queue
Date: Mon, 10 Oct 2005 11:26:43 +0100
User-agent: quilt/0.42-1

 Makefile.am                    |    3 
 clcommit.m4sh                  |  136 +++++-------------
 libltdl/config/general.m4sh    |   26 +++
 libltdl/config/getopt.m4sh     |  295 ++++++++++++++++++++++++++++++++++++++++-
 libltdl/config/mailnotify.m4sh |   89 +++---------
 tests/getopt.at                |  245 ++++++++++++++++++++++++++++++++++
 tests/testsuite.at             |    2 
 7 files changed, 632 insertions(+), 164 deletions(-)

Index: libtool--devo--1.0/ChangeLog
from  Gary V. Vaughan  <address@hidden>
        * clcommit.m4sh, libltdl/config/general.m4sh,
        libltdl/config/getopt.m4sh, libltdl/config/mailnotify.m4sh: Merge
        in changes from upstream.  Mostly cosmetic, plus better option
        processing with a new func_fastopt function.
        * tests/getopt.at: New tests for func_getopt().
        * tests/testsuite.at: Include them.
        * Makefile.am: Use them.

Index: libtool--devo--1.0/Makefile.am
===================================================================
--- libtool--devo--1.0.orig/Makefile.am
+++ libtool--devo--1.0/Makefile.am
@@ -366,6 +366,7 @@ dist-hook:
 
 TESTSUITE      = tests/testsuite
 TESTSUITE_AT   = tests/testsuite.at \
+                 tests/getopt.at \
                  tests/am-subdir.at \
                  tests/duplicate_members.at \
                  tests/inherited_flags.at \
@@ -386,7 +387,7 @@ TESTSUITE_AT        = tests/testsuite.at \
 EXTRA_DIST     += $(TESTSUITE) $(TESTSUITE_AT) tests/package.m4
 
 # Be sure to reexport important environment variables:
-TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
+TESTS_ENVIRONMENT = MAKE="$(MAKE)" SED="$(SED)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
        CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \
        LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \
        OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \
Index: libtool--devo--1.0/clcommit.m4sh
===================================================================
--- libtool--devo--1.0.orig/clcommit.m4sh
+++ libtool--devo--1.0/clcommit.m4sh
@@ -2,11 +2,11 @@ m4_define([_m4_divert(SCRIPT)], 100)
 m4_divert_push([SCRIPT])#!/bin/sh
 # @configure_input@
 
-# clcommit (GNU @PACKAGE@) version 0.16
+# clcommit (GNU @PACKAGE@) version 1.0
 # Written by Gary V. Vaughan <address@hidden>
 # and Alexandre Oliva <address@hidden>
 
-# Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2004, 2005 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -77,8 +77,8 @@ m4_divert_push([SCRIPT])#!/bin/sh
 : ${MAILNOTIFY="mailnotify"}
 : ${MKSTAMP="mkstamp"}
 
-test -f "config/$MAILNOTIFY" && MAILNOTIFY="config/$MAILNOTIFY"
-test -f "config/$MKSTAMP" && MKSTAMP="config/$MKSTAMP"
+test -f "libltdl/config/$MAILNOTIFY" && MAILNOTIFY="libltdl/config/$MAILNOTIFY"
+test -f "libltdl/config/$MKSTAMP" && MKSTAMP="libltdl/config/$MKSTAMP"
 
 PROGRAM=clcommit
 
@@ -101,14 +101,6 @@ mailnotify_flags=
 sendmail_to=
 exit_cmd=:
 
-# try to find out whether read supports -r
-if echo bt | tr b '\\' | { read -r line; test "X$line" = 'X\t'; } 2>/dev/null
-then
-  read_r='read -r'
-else
-  read_r=read
-fi
-
 # Locations for important files:
 signature_file=
 log_dir="`func_mktempdir`"
@@ -116,21 +108,24 @@ log_file="$log_dir/log"
 
 trap '$RM -r "$log_dir"; exit $EXIT_FAILURE' 1 2 15
 
-set -e
-
 # Parse options once, thoroughly.  This comes as soon as possible in
 # the script to make things like `clcommit --version' happen quickly.
 {
-  # sed scripts:
-  my_sed_single_opt='1s/^\(..\).*$/\1/;q'
-  my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
-  my_sed_long_opt='1s/^\(--[[^=]]*\)=.*/\1/;q'
-  my_sed_long_arg='1s/^--[[^=]]*=//'
+  options=`func_fastopt -o '?1C:cF:fghlm:nqrS:s:tvz:' \
+       --long=changelog:,ChangeLog:,compress:,debug,dryrun,fast,file \
+       --long=first,force,from:,help,local,message:,quiet,rcfile:: \
+       --long=sendmail:,signature:,summary:,tla,verbose,version \
+    -- ${1+"$@"}`
+  test $? -eq 0 || exit_cmd=exit
+
+  eval set dummy "$options"; shift
 
   # this just eases exit handling
   while test $# -gt 0; do
-    opt="$1"
+    opt=$1
     shift
+    test $# -gt 0 && func_quote_arg "$1"
+
     case $opt in
 
       --debug)         func_echo "enabling shell trace mode"
@@ -139,12 +134,9 @@ set -e
                        ;;
 
       --fast)          set dummy --force --first ${1+"$@"}; shift      ;;
+      -f|--force)      opt_update=false; PAGER=cat                     ;;
 
-      -f|--force)      opt_update=false; PAGER=cat             ;;
-
-      --from)          test $# = 0 && func_missing_arg $opt && break
-                       func_quote_for_eval "$1"
-                       mailnotify_flags="$mailnotify_flags 
--from=$func_quote_for_eval_result"
+      --from)          mailnotify_flags="$mailnotify_flags 
--from=$func_quote_arg_result"
                        shift
                        ;;
 
@@ -153,7 +145,6 @@ set -e
                        ;;
 
       -m|--message|--msg)
-                       test $# = 0 && func_missing_arg $opt && break
                        if $opt_first || test -f "$log_file"; then
                          func_error "you can have at most one of -m, -F and -1"
                          break
@@ -162,8 +153,7 @@ set -e
                        shift
                        ;;
 
-      -F|--file)       test $# = 0 && func_missing_arg $opt && break
-                       if $opt_first || test -f "$log_file"; then
+      -F|--file)       if $opt_first || test -f "$log_file"; then
                          func_error "you can have at most one of -m, -F and -1"
                          break
                        fi
@@ -181,7 +171,6 @@ set -e
                        ;;
 
       -C|--[[cC]]hange[[lL]]og)
-                       test $# = 0 && func_missing_arg $opt && break
                        if test -f "$1"; then :; else
                          func_error "ChangeLog file \`$1' does not exist"
                          break
@@ -190,58 +179,43 @@ set -e
                        shift
                        ;;
 
-      -n|--dry-run)    opt_commit=false; opt_update=:          ;;
-
-      -q|--quiet)      cvs_flags="$cvs_flags -q"               ;;
+      -n|--dry-run)    opt_commit=false; opt_update=:                  ;;
+      -q|--quiet)      cvs_flags="$cvs_flags -q"                       ;;
 
-      -r|--rcfile)     rc_file="./.clcommitrc"
-                       if test $# -gt 0; then
-                         case $1 in
-                           -*)                         ;;
-                           *)  rc_file="$1"; shift     ;;
-                         esac
-                       fi
-                       if test -f "$rc_file"; then :; else
-                         func_error "rcfile \`$rc_file' does not exist"
+      -r|--rcfile)     case $1 in
+                         '') rcfile=./.clcommitrc              ;;
+                         *)  rcfile=$1                         ;;
+                       esac
+                       shift
+                       if test -f "$rcfile"; then :; else
+                         func_error "rcfile \`$rcfile' does not exist"
                          exit_cmd=exit
                          break
                        fi
                        # The funny quoting allows keeping one option per
-                       # line in $rc_file:
-                       eval set dummy `echo \`cat $rc_file\` 
\\\${1+\"address@hidden"}`
+                       # line in $rcfile:
+                       eval set dummy `echo \`cat $rcfile\` 
\\\${1+\"address@hidden"}`
                        shift
                        ;;
 
-      -s|--sendmail)   test $# = 0 && func_missing_arg $opt && break
-                       func_quote_for_eval "$1"
-                       sendmail_to="$func_quote_for_eval_result"
-                       shift
-                       ;;
+      -s|--sendmail)   sendmail_to=$func_quote_arg_result; shift       ;;
 
-      --signature)     test $# = 0 && func_missing_arg $opt && break
-                       signature_file="$HOME/.signature"
-                       case $1 in
-                         -*) ;;
-                         *)  signature_file="$1"; shift ;;
+      --signature)     case $1 in
+                         '') signature_file=$HOME/.signature   ;;
+                         *)  signature_file=$1                 ;;
                        esac
+                       shift
                        if test -f "$signature_file"; then :; else
                          func_error "\`$signature_file': file not found"
                          break
                        fi
                        ;;
 
-      -S|--summary)    test $# = 0 && func_missing_arg $opt && break
-                       summary="$1"
-                       shift
-                       ;;
-
-      -t|--tla)                opt_tla=:                               ;;
+      -S|--summary)    summary=$1; shift                               ;;
+      -t|--tla)                opt_tla=:                                       
;;
+      -v|--verbose)    opt_verbose=:                                   ;;
 
-      -v|--verbose)    opt_verbose=:                           ;;
-
-      -z|--compress)
-                       test $# = 0 && func_missing_arg $opt && break
-                       case "$1" in
+      -z|--compress)   case $1 in
                          [[0-9]]) :;;
                          *)  func_error "invalid argument for $opt"
                              break
@@ -251,36 +225,10 @@ set -e
                        shift
                        ;;
 
-      # Separate optargs to long options:
-      --*=*)
-                       arg=`echo "$opt" | $SED "$my_sed_long_arg"`
-                       opt=`echo "$opt" | $SED "$my_sed_long_opt"`
-                       set dummy "$opt" "$arg" ${1+"$@"}
-                       shift
-                       ;;
-
-      # Separate optargs to short options:
-      -m*|-F*|-C*|-S*|-s*|-z*)
-                       arg=`echo "$opt" |$SED "$my_sed_single_rest"`
-                       opt=`echo "$opt" |$SED "$my_sed_single_opt"`
-                       set dummy "$opt" "$arg" ${1+"$@"}
-                       shift
-                       ;;
-
-      # Separate non-argument short options:
-      -f*|-1*|-n*|-q*)
-                       rest=`echo "$opt" |$SED "$my_sed_single_rest"`
-                       opt=`echo "$opt" |$SED "$my_sed_single_opt"`
-                       set dummy "$opt" "-$rest" ${1+"$@"}
-                       shift
-                       ;;
-
       -\?|-h)          func_usage                                      ;;
       --help)          func_help                                       ;;
       --version)       func_version                                    ;;
       --)              break                                           ;;
-      -*)              func_fatal_help "unrecognized option \`$opt'"   ;;
-      *)               set dummy "$opt" ${1+"$@"};     shift; break            
;;
     esac
   done
 
@@ -471,9 +419,11 @@ func_mailnotify ()
 
 
 
-## ----- ##
-## main. ##
-## ----- ##
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+set -e
 
 {
   $opt_update && func_check_conflicts
Index: libtool--devo--1.0/libltdl/config/general.m4sh
===================================================================
--- libtool--devo--1.0.orig/libltdl/config/general.m4sh
+++ libtool--devo--1.0/libltdl/config/general.m4sh
@@ -1,7 +1,7 @@
 m4_if([# general.m4sh -- general shell script boiler plate -*- Autoconf -*-
 # Written by Gary V. Vaughan <address@hidden>, 2004
 
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -16,8 +16,10 @@ m4_if([# general.m4sh -- general shell s
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
+# along with this program; if not, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -52,6 +54,16 @@ lt_nl='
 '
 IFS="  $lt_nl"
 
+# Try to find out whether read supports -r, to prevent treating \ as
+# an escape character or for line continuations.  Use $read_r when
+# reading a file in a loop instead of calling read directly:
+if echo bt | tr b '\\' | { read -r line; test "X$line" = 'X\t'; } 2>/dev/null
+then
+  read_r='read -r'
+else
+  read_r=read
+fi
+
 dirname="s,/[[^/]]*$,,"
 basename="s,^.*/,,"
 
@@ -185,6 +197,14 @@ func_grep ()
 }
 
 
+# func_extract haystack expression
+# Extract part of HAYSTACK using EXPRESSION, without output or exit status.
+func_extract ()
+{
+    $as_expr x"$1" : x"$2" 2>/dev/null || :
+}
+
+
 # func_mkdir_p directory-path
 # Make sure the entire path to DIRECTORY-PATH is available.
 func_mkdir_p ()
Index: libtool--devo--1.0/libltdl/config/getopt.m4sh
===================================================================
--- libtool--devo--1.0.orig/libltdl/config/getopt.m4sh
+++ libtool--devo--1.0/libltdl/config/getopt.m4sh
@@ -1,7 +1,7 @@
 m4_if([# getopt.m4sh -- getopt helper functions                 -*- Autoconf 
-*-
 # Written by Gary V. Vaughan <address@hidden>, 2004
 
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -16,8 +16,10 @@ m4_if([# getopt.m4sh -- getopt helper fu
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
+# along with this program; if not, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -77,8 +79,293 @@ func_help ()
 # exit_cmd.
 func_missing_arg ()
 {
-    func_error "missing argument for $1"
+    case $1 in
+      --*) func_error "option \`$1' requires an argument"              ;;
+      *)
+       func_error "option requires an argument --" \
+         `func_extract "$1" '-*\(.\)'`
+       ;;
+    esac
     exit_cmd=exit
 }
 
+# func_unknown_option opt
+# Diagnosis for an invalid option to the func_getopt client code.
+func_unknown_option ()
+{
+    case $1 in
+      --*) func_error "unrecognized option \`$1'"                      ;;
+      *)   func_error "invalid option --" `func_extract "$1" '-*\(.\)'`        
;;
+    esac
+    exit_cmd=exit
+}
+
+# func__invalid_spec specifier
+# Diagnosis for shortopt specifiers that are anything other than a
+# letter (optionally followed by one or two colons).
+func__invalid_spec ()
+{
+    func_error "invalid getopt specification: \`$1'"
+    exit_cmd=exit
+}
+
+# func__categorise_spec specifier
+# split up the options into optional, required and non-argument
+# specs for both long and short options
+func__categorise_spec ()
+{
+    _go_spec="$1"
+
+    # extract trailing colons, and then strip leading minuses, if any
+    _go_argtype=`func_extract "$_go_spec" '[[^:]]*\(:*\)'`
+    _go_spec=`func_extract "$_go_spec" '\([[^:]]*\):*'`
+
+    case x$_go_argtype in
+      x::) _go_optspec=$_go_optspec$_go_spec, ;;
+      x:)  _go_reqspec=$_go_reqspec$_go_spec, ;;
+      x)   _go_nonspec=$_go_nonspec$_go_spec, ;;
+      *)   func__invalid_spec "$1"             ;;
+     esac
+
+    if expr x"$_go_spec" : x'-*.$' >/dev/null; then
+      _go_shortopt="$_go_shortopt$_go_spec"
+    fi
+}
+
+# func_quote_arg arg
+# Escape single quotes in ARG.
+func_quote_arg ()
+{
+    _go_arg="$1"
+
+    case $_go_arg in
+      *[[\']]*)
+        _go_arg=`$ECHO "X$_go_arg" | $Xsed -e "s,','\\\\\\\\'',g"`
+       ;;
+    esac
+
+    func_quote_arg_result="'$_go_arg'"
+}
+
+# func_getopt [options] -o|--options optstring [options] -- parameters
+# At the moment only the --longoptions option is implemented.  Typical
+# use of this function might be:
+#
+#   options=`func_getopt -o hvx:: --long=help,verbose,foo:: -- ${1+"$@"}`
+#   test "$?" -eq 0 || exit_cmd=exit
+#   eval set dummy "$options"; shift
+#   while test "$#" -gt 0; do
+#     opt="$1"; shift
+#     case $opt in
+#       ...parse normalized options...
+#      --) break ;;
+#   done
+#   $exit_cmd 2
+#
+# A single colon following either a long or short option denotes that
+# the preceding option requires an argument.  Similarly a double colon
+# denotes an optional argument con be given with the preceding option --
+# to pass arguments to such options they must be specified with an '='
+# sign for long options, or not be separated from the short option they
+# are attached to.
+#
+# When func_getopt returns with status 0, and set has been called as
+# shown above, the parameters are all normalised.  If status is non-0,
+# errors will have been diagnosed and the remaining parameters
+# normalized.  Normalization means that all options that can take an
+# argument are provided with one (possibly empty for :: type options);
+# short options given as one argument (-hv) are separated out (-h -v);
+# long option arguments given with --foo=arg syntax are converted to
+# --foo arg; a '--' is always given at the end of the option parameters;
+# option arguments and additional arguments after '--' are all quoted.
+#
+# The shell variable `exit_cmd' will be set to either `:' if there
+# were no problems normalizing, or else `exit' otherwise.
+func_getopt ()
+{
+    # regexps for func_extract:
+    _go_re_opt='-*\(.*\)$'
+    _go_re_split_opt='\(-*.\).*$'
+    _go_re_split_rest='-*.\(.*\)$'
+    _go_re_long_opt='\(-*[[^=]]*\)=.*$'
+    _go_re_long_arg='-*[[^=]]*=\(.*\)$'
+
+    # Parse options for func_getopt itself first:
+    while test "$#" -gt 0; do
+      _go_opt="$1"
+      shift
+
+      case $_go_opt in
+        
--longoptions|--longoption|--longoptio|--longopti|--longopt|--longop|--longo|--long|--lon|--lo|--l|-l)
+                       test "$#" -eq 0 && func_missing_arg "$_go_opt" && break
+
+                       _go_save_IFS="$IFS"
+                       IFS=,
+                       for _go_optarg in $1; do
+                         IFS="$_go_save_IFS"
+                         _go_optarg=--`func_extract "$_go_optarg" 
"$_go_re_opt"`
+                         func__categorise_spec "$_go_optarg"
+                       done
+                       IFS="$_go_save_IFS"
+                       shift
+                       ;;
+
+        --options|--option|--optio|--opti|--opt|--op|--o|-o)
+                       test "$#" -eq 0 && func_missing_arg "$_go_opt" && break
+                       _go_shortopts="$1"
+                       while test -n "$_go_shortopts"; do
+                         _go_optarg=`func_extract "$_go_shortopts" '\(.:*\)'`
+                         _go_shortopts=`func_extract "$_go_shortopts" 
'.:*\(.*\)'`
+                         func__categorise_spec "-$_go_optarg"
+                       done
+                       shift
+                       ;;
+
+       # Separate optargs to long options:
+       --*=*)          _go_arg=`func_extract "$_go_opt" "$_go_re_long_arg"`
+                       _go_opt=`func_extract "$_go_opt" "$_go_re_long_opt"`
+                       set dummy "$_go_opt" "$_go_arg" ${1+"$@"}; shift
+                       ;;
+
+       # Separate optargs to short options:
+       -l*)            _go_arg=`func_extract "$_go_opt" "$_go_re_split_rest"`
+                       _go_opt=`func_extract "$_go_opt" "$_go_re_split_opt"`
+                       set dummy "$_go_opt" "$_go_arg" ${1+"$@"}; shift
+                       ;;
+
+       # Separate non-argument short options:
+       # -x*|-y*)      _go_arg=`func_extract "$_go_opt" "$_go_re_split_rest"`
+       #               _go_opt=`func_extract "$_go_opt" "$_go_re_split_opt"`
+       #               set dummy "$_go_opt" "-$_go_arg" ${1+"$@"}; shift
+       #               ;;
+
+       --)             break                                           ;;
+       -*)             func_unknown_option "$_go_opt"                  ;;
+       *)              set dummy "$_go_opt" ${1+"$@"}; shift; break    ;;
+      esac
+    done
+
+    # Then break out the program parameters according to getopt options:
+    _go_new=
+    while test "$#" -gt 0; do
+      _go_opt="$1"
+      shift
+      case $_go_opt in
+       --)     break                                                   ;;
+
+       -*)     # handle options that require an argument
+               _go_longopt=`func_extract "$_go_opt" "$_go_re_long_opt"`
+               case ,$_go_reqspec in
+                 *,$_go_longopt,*)
+                   _go_opt=`func_extract "$_go_opt" "$_go_re_long_arg"`
+                   func_quote_arg "$_go_opt"
+                   _go_new="$_go_new $_go_longopt $func_quote_arg_result"
+                   continue
+                   ;;
+                 *,$_go_opt,*)
+                   test "$#" -eq 0 && func_missing_arg "$_go_opt" \
+                     && break
+                   func_quote_arg "$1"
+                   _go_new="$_go_new $_go_opt $func_quote_arg_result"
+                   shift
+                   continue
+                   ;;
+               esac
+
+               # handle optional arguments
+               _go_shopt=`func_extract "$_go_opt" "$_go_re_split_opt"`
+               case ,$_go_optspec in
+                 *,$_go_longopt,*)     # --optlong=optarg
+                   _go_opt=`func_extract "$_go_opt" "$_go_re_long_arg"`
+                   func_quote_arg "$_go_opt"
+                   _go_new="$go_new $_go_longopt $func_quote_arg_result"
+                   continue
+                   ;;
+                 *,$_go_opt,*)         # --optlong
+                   _go_new="$_go_new $_go_opt ''"
+                   continue
+                   ;;
+                 *,$_go_shopt,*)       # -Soptarg
+                   func_quote_arg `func_extract "$_go_opt" 
"$_go_re_split_rest"`
+                   _go_new="$_go_new $_go_shopt $func_quote_arg_result"
+                   continue
+                   ;;
+               esac
+
+               # handle non-argument options
+               case ,$_go_nonspec in
+                 *,$_go_opt,*)
+                   _go_new="$_go_new $_go_opt"
+                   continue
+                   ;;
+               esac
+
+               # separate short options
+               case $_go_shortopt in
+                 *$_go_shopt*)
+                   _go_rest=`func_extract "$_go_opt" "$_go_re_split_rest"`
+
+                   # If _go_shopt doesn't require an argument, and
+                   # the following character is a valid shortopt
+                   # then precede it with a '-' too...:
+                   _go_sharg=`func_extract "-$_go_rest" "$_go_re_split_opt"`
+                   case $_go_shortopt,$_go_reqspec in
+                     *,$_go_shopt,*)                           ;;
+                     *$_go_sharg*)   _go_rest="-$_go_rest"     ;;
+                   esac
+
+                   set dummy "$_go_shopt" "$_go_rest" ${1+"$@"}; shift
+                   continue
+                   ;;
+               esac
+
+               # anything else is invalid
+               func_unknown_option "$_go_opt"
+               ;;
+
+       *)      func_quote_arg "$_go_opt"
+               _go_parms="$_go_parms $func_quote_arg_result"
+               ;;
+      esac
+    done
+
+    while test "$#" -gt 0; do
+      func_quote_arg "$1"
+      _go_parms="$_go_parms $func_quote_arg_result"
+      shift
+    done
+
+    echo "$_go_new --$_go_parms"
+
+    # Make sure $? is set for the caller.  If you have 'set -e' prior
+    # to calling func_getopt, and we have diagnosed an error, this
+    # expression evaluating to false will cause the script to exit.
+    test x"$exit_cmd" = x:
+}
+
+
+# func_fastopt [options] -o|--options optstring [options] -- parameters
+# This is a wrapper for func_getopt that skips all the time consuming
+# option processing when it notices --help or --version in PARAMETERS.
+func_fastopt ()
+{
+    _go_fast=''
+
+    # --version and --help should respond as fast as possible
+    for _go_opt in ${1+"$@"}; do
+      if test x"$_go_opt" = x-- || test x"$_go_fast" != x; then
+        _go_fast=$_go_opt
+        case $_go_fast in
+          --version|--help) echo "$_go_opt --"; break ;;
+        esac
+      fi
+    done
+
+    # Be sure to call func_getopt last to preserve $?
+    case $_go_fast in
+      --version|--help) : ;;
+      *)  func_getopt ${1+"$@"} ;;
+    esac
+}
+
 exit_cmd=:
Index: libtool--devo--1.0/libltdl/config/mailnotify.m4sh
===================================================================
--- libtool--devo--1.0.orig/libltdl/config/mailnotify.m4sh
+++ libtool--devo--1.0/libltdl/config/mailnotify.m4sh
@@ -2,10 +2,10 @@ m4_define([_m4_divert(SCRIPT)], 100)
 m4_divert_push([SCRIPT])#!/bin/sh
 # @configure_input@
 
-# mailnotify (GNU @PACKAGE@) version 0.6
+# mailnotify (GNU @PACKAGE@) version 0.7
 # Written by Gary V. Vaughan <address@hidden>
 
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -77,34 +77,28 @@ sed_mail_address='s,^.*<\(.*\)>.*$,\1,'
 # Parse options once, thoroughly.  This comes as soon as possible in
 # the script to make things like `mailnotify --version' happen quickly.
 {
-  # sed scripts:
-  my_sed_single_opt='1s/^\(..\).*$/\1/;q'
-  my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
-  my_sed_long_opt='1s/^\(--[[^=]]*\)=.*/\1/;q'
-  my_sed_long_arg='1s/^--[[^=]]*=//'
+  options=`func_fastopt -o '?C:F:f:hm:no:qs:v' \
+       --long=debug,carbon-copy:,from:,filename:,help,mime-type: \
+       --long=output-file:,subject:,verbose,version \
+    -- ${1+"$@"}`
+  test $? -eq 0 || exit_cmd=exit
+
+  eval set dummy "$options"; shift
 
   while test $# -gt 0; do
-    opt="$1"
+    opt=$1
     shift
+    test $# -gt 0 && func_quote_arg "$1"
+
     case $opt in
       --debug)         func_echo "enabling shell trace mode"
                        set -x
                        ;;
 
-      -C|--carbon-copy) test $# -eq 0 && func_missing_arg "$opt" && break
-                       func_quote_for_eval "$1"
-                       cc="$func_quote_for_eval_result"
-                       shift
-                       ;;
+      -C|--carbon-copy) cc=$func_quote_arg_result;   shift             ;;
+      -F|--from)       from=$func_quote_arg_result; shift              ;;
 
-      -F|--from)       test $# -eq 0 && func_missing_arg "$opt" && break
-                       func_quote_for_eval "$1"
-                       from="$func_quote_for_eval_result"
-                       shift
-                       ;;
-
-      -f|--filename)   test $# -eq 0 && func_missing_arg "$opt" && break
-                       if test -f "$1"; then :; else
+      -f|--filename)   if test -f "$1"; then :; else
                          func_error "\`$1' does not exist"
                          exit_cmd=exit
                          break
@@ -113,8 +107,7 @@ sed_mail_address='s,^.*<\(.*\)>.*$,\1,'
                        shift
                        ;;
 
-      -m|--mime-type)  test $# -eq 0 && func_missing_arg "$opt" && break
-                       case $1 in
+      -m|--mime-type)  case $1 in
                          text/*) ;;
                          */*) func_error "only text/* mime-types supported"
                               ;;
@@ -133,47 +126,13 @@ sed_mail_address='s,^.*<\(.*\)>.*$,\1,'
                        multipart=`expr 1 + $multipart`
                        ;;
 
-      -o|--output-file)        test $# -eq 0 && func_missing_arg "$opt" && 
break
-                       func_quote_for_eval "$1"
-                       outputfile="$func_quote_for_eval_result"
-                       shift
-                       ;;
-
-      -s|--subject)    test $# -eq 0 && func_missing_arg "$opt" && break
-                       func_quote_for_eval "$1"
-                       subject="$func_quote_for_eval_result"
-                       shift
-                       ;;
-
-      -v|--verbose)    opt_verbose=:                   ;;
-
-      # Separate optargs to long options:
-      
--carbon-copy=*|--from=*|--filename=*|--mime-type=*|--output-file=*|--subject=*)
-                       arg=`echo "$opt" | $SED "$my_sed_long_arg"`
-                       opt=`echo "$opt" | $SED "$my_sed_long_opt"`
-                       set -- "$opt" "$arg" ${1+"$@"}
-                       ;;
-
-      # Separate optargs to short options:
-      -C*|-F*|-f*|-m*|-o*|-s*)
-                       arg=`echo "$opt" |$SED "$my_sed_single_rest"`
-                       opt=`echo "$opt" |$SED "$my_sed_single_opt"`
-                       set -- "$opt" "$arg" ${1+"$@"}
-                       ;;
-
-      # Separate non-argument short options:
-      -n*|-v*)
-                       rest=`echo "$opt" |$SED "$my_sed_single_rest"`
-                       opt=`echo "$opt" |$SED "$my_sed_single_opt"`
-                       set -- "$opt" "-$rest" ${1+"$@"}
-                       ;;
-
+      -o|--output-file)        outputfile=$1; shift                            
;;
+      -s|--subject)    subject=$func_quote_arg_result; shift           ;;
+      -v|--verbose)    opt_verbose=:                                   ;;
       -\?|-h)          func_usage                                      ;;
       --help)          func_help                                       ;;
       --version)       func_version                                    ;;
       --)              break                                           ;;
-      -*)              func_fatal_help "unrecognized option \`$opt'"   ;;
-      *)               set -- "$opt" ${1+"$@"};      break             ;;
     esac
   done
 
@@ -194,6 +153,8 @@ sed_mail_address='s,^.*<\(.*\)>.*$,\1,'
   fi
   eval test -f \"\$datafile$multipart\" ||
     eval func_fatal_error \"\$datafile$multipart: file not found\"
+
+  $exit_cmd $EXIT_FAILURE
 }
 
 
@@ -324,9 +285,11 @@ func_sendmail ()
 
 
 
-## ----- ##
-## main. ##
-## ----- ##
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+set -e
 
 {
   tmp_dir="`func_mktempdir`"
Index: libtool--devo--1.0/tests/getopt.at
===================================================================
--- /dev/null
+++ libtool--devo--1.0/tests/getopt.at
@@ -0,0 +1,245 @@
+# Hand crafted tests for GNU Libtool getopt.                   -*-Autotest-*-
+# Copyright 2005 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+m4_pattern_allow([^AS_SHELL_SANITIZE$])
+m4_pattern_allow([^(m4_(define|divert_push|include)|_m4_divert)$])
+
+# NOTE:
+#
+#   These tests were developed using GNU getopt(1), by running
+#
+#      GETOPT=getopt make check-local TESTSUITE_FLAGS='-d -v 1 2 3'
+#
+#   Add new tests using this method, and *then* if the shell
+#   implementation differs (without GETOPT set), correct it.
+
+AT_BANNER([Getopt shell function operation.])
+
+# _LT_GETOPT_SETUP(ARGS)
+# ----------------------
+m4_define([_LT_GETOPT_SETUP],
+[lt_auxdir=$abs_top_srcdir/libltdl/config
+
+: ${AUTOM4TE=autom4te}
+: ${M4SH=$AUTOM4TE --language=m4sh}
+
+AT_DATA([getopt.in],
+[[m4_define([_m4_divert(SCRIPT)], 100)
+m4_divert_push([SCRIPT])#! /bin/sh
+
+: ${GETOPT=func_getopt}
+
+PROGRAM=getopt
+
+AS_SHELL_SANITIZE
+$as_unset CDPATH
+
+m4_include([getopt.m4sh])
+
+options=`$GETOPT $1 -- ${1+"$][@"}`
+status=$?
+
+echo -n $options
+
+exit $status
+]])
+
+$M4SH -B $lt_auxdir getopt.in > getopt
+chmod a+x getopt
+])# _LT_GETOPT_SETUP
+
+
+## ---------------------- ##
+## Getopt single options. ##
+## ---------------------- ##
+
+AT_SETUP([short options])
+
+_LT_GETOPT_SETUP([-o hvx:y::z])
+
+AT_CHECK([./getopt -h], [0], [-h --])
+AT_CHECK([./getopt -v], [0], [-v --])
+AT_CHECK([./getopt -p], [1], [--], [getopt: invalid option -- p
+])
+AT_CHECK([./getopt -hv], [0], [-h -v --])
+AT_CHECK([./getopt -x], [1], [--], [getopt: option requires an argument -- x
+])
+AT_CHECK([./getopt -x -v], [0], [-x '-v' --])
+AT_CHECK([./getopt -xv], [0], [-x 'v' --])
+AT_CHECK([./getopt -x -p], [0], [-x '-p' --])
+AT_CHECK([./getopt -xp], [0], [-x 'p' --])
+AT_CHECK([./getopt -x argument], [0], [-x 'argument' --])
+AT_CHECK([./getopt -xargument], [0], [-x 'argument' --])
+AT_CHECK([./getopt -y], [0], [-y '' --])
+AT_CHECK([./getopt -y -v], [0], [-y '' -v --])
+AT_CHECK([./getopt -yv], [0], [-y 'v' --])
+AT_CHECK([./getopt -y -p], [1], [-y '' --], [getopt: invalid option -- p
+])
+AT_CHECK([./getopt -yp], [0], [-y 'p' --])
+AT_CHECK([./getopt -y argument], [0], [-y '' -- 'argument'])
+AT_CHECK([./getopt -yargument], [0], [-y 'argument' --])
+AT_CHECK([./getopt -y -x -p], [0], [-y '' -x '-p' --])
+AT_CHECK([./getopt -y -xp], [0], [-y '' -x 'p' --])
+AT_CHECK([./getopt -yxp], [0], [-y 'xp' --])
+AT_CHECK([./getopt -x -y -p], [1], [-x '-y' --], [getopt: invalid option -- p
+])
+AT_CHECK([./getopt -xyp], [0], [-x 'yp' --])
+
+AT_CLEANUP
+
+AT_SETUP([long options])
+
+_LT_GETOPT_SETUP([-o hv --long help,version,foo:,bar::,baz])
+
+AT_CHECK([./getopt --help], [0], [--help --])
+AT_CHECK([./getopt --version], [0], [--version --])
+AT_CHECK([./getopt --quux], [1], [--], [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --help --version], [0], [--help --version --])
+AT_CHECK([./getopt --foo], [1], [--],
+       [getopt: option `--foo' requires an argument
+])
+AT_CHECK([./getopt --foo --version], [0], [--foo '--version' --])
+AT_CHECK([./getopt --foo=--version], [0], [--foo '--version' --])
+AT_CHECK([./getopt --foo --quux], [0], [--foo '--quux' --])
+AT_CHECK([./getopt --foo=--quux], [0], [--foo '--quux' --])
+AT_CHECK([./getopt --foo argument], [0], [--foo 'argument' --])
+AT_CHECK([./getopt --foo=argument], [0], [--foo 'argument' --])
+AT_CHECK([./getopt --bar], [0], [--bar '' --])
+AT_CHECK([./getopt --bar --version], [0], [--bar '' --version --])
+AT_CHECK([./getopt --bar=--version], [0], [--bar '--version' --])
+AT_CHECK([./getopt --bar --quux], [1], [--bar '' --],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --bar=--quux], [0], [--bar '--quux' --])
+AT_CHECK([./getopt --bar argument], [0], [--bar '' -- 'argument'])
+AT_CHECK([./getopt --bar=argument], [0], [--bar 'argument' --])
+AT_CHECK([./getopt --bar --foo --quux], [0],
+       [--bar '' --foo '--quux' --])
+AT_CHECK([./getopt --bar --foo=--quux], [0],
+       [--bar '' --foo '--quux' --])
+AT_CHECK([./getopt --bar=--foo --quux], [1], [--bar '--foo' --],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --foo --bar --quux], [1], [--foo '--bar' --],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --foo --bar=--quux], [0],
+       [--foo '--bar=--quux' --])
+
+AT_CLEANUP
+
+AT_SETUP([non-option arguments])
+
+_LT_GETOPT_SETUP([-o hvx:y::z --long=help,version,foo:,bar::,baz])
+
+AT_CHECK([./getopt], [0], [--])
+AT_CHECK([./getopt --], [0], [--])
+AT_CHECK([./getopt -- --], [0], [-- '--'])
+AT_CHECK([./getopt parameter], [0], [-- 'parameter'])
+AT_CHECK([./getopt -- parameter], [0], [-- 'parameter'])
+AT_CHECK([./getopt -- 'parameter 1'], [0], [-- 'parameter 1'])
+AT_CHECK([./getopt -- "parameter'1"], [0], [-- 'parameter'\''1'])
+AT_CHECK([./getopt -h], [0], [-h --])
+AT_CHECK([./getopt -h --], [0], [-h --])
+AT_CHECK([./getopt -- -h], [0], [-- '-h'])
+AT_CHECK([./getopt --help], [0], [--help --])
+AT_CHECK([./getopt --help --], [0], [--help --])
+AT_CHECK([./getopt -- --help], [0], [-- '--help'])
+AT_CHECK([./getopt -p], [1], [--], [getopt: invalid option -- p
+])
+AT_CHECK([./getopt -p --], [1], [--], [getopt: invalid option -- p
+])
+AT_CHECK([./getopt -- -p], [0], [-- '-p'])
+AT_CHECK([./getopt -xparm], [0], [-x 'parm' --])
+AT_CHECK([./getopt -xparm parm2], [0], [-x 'parm' -- 'parm2'])
+AT_CHECK([./getopt -x parm], [0], [-x 'parm' --])
+AT_CHECK([./getopt -x parm parm2], [0], [-x 'parm' -- 'parm2'])
+AT_CHECK([./getopt -x -- parm], [0], [-x '--' -- 'parm'])
+AT_CHECK([./getopt -x -- parm parm2], [0], [-x '--' -- 'parm' 'parm2'])
+AT_CHECK([./getopt -yparm], [0], [-y 'parm' --])
+AT_CHECK([./getopt -yparm parm2], [0], [-y 'parm' -- 'parm2'])
+AT_CHECK([./getopt -y parm], [0], [-y '' -- 'parm'])
+AT_CHECK([./getopt -y parm parm2], [0], [-y '' -- 'parm' 'parm2'])
+AT_CHECK([./getopt -y -- parm], [0], [-y '' -- 'parm'])
+AT_CHECK([./getopt -y -- parm parm2], [0], [-y '' -- 'parm' 'parm2'])
+AT_CHECK([./getopt --quux], [1], [--],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --quux parm], [1], [-- 'parm'],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --quux --], [1], [--],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --quux parm --], [1], [-- 'parm'],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt -- --quux], [0], [-- '--quux'])
+AT_CHECK([./getopt -- --quux parm], [0], [-- '--quux' 'parm'])
+AT_CHECK([./getopt -- --quux 'parm 1'], [0], [-- '--quux' 'parm 1'])
+AT_CHECK([./getopt --foo=parm], [0], [--foo 'parm' --])
+AT_CHECK([./getopt --foo='parm 1'], [0], [--foo 'parm 1' --])
+AT_CHECK([./getopt --foo=parm parm2], [0], [--foo 'parm' -- 'parm2'])
+AT_CHECK([./getopt --foo parm], [0], [--foo 'parm' --])
+AT_CHECK([./getopt --foo parm parm2], [0], [--foo 'parm' -- 'parm2'])
+AT_CHECK([./getopt --foo -- parm], [0], [--foo '--' -- 'parm'])
+AT_CHECK([./getopt --foo -- 'parm 1'], [0], [--foo '--' -- 'parm 1'])
+AT_CHECK([./getopt --foo -- parm parm2], [0],
+       [--foo '--' -- 'parm' 'parm2'])
+AT_CHECK([./getopt --bar=parm], [0], [--bar 'parm' --])
+AT_CHECK([./getopt --bar='parm 1'], [0], [--bar 'parm 1' --])
+AT_CHECK([./getopt --bar=parm parm2], [0], [--bar 'parm' -- 'parm2'])
+AT_CHECK([./getopt --bar parm], [0], [--bar '' -- 'parm'])
+AT_CHECK([./getopt --bar parm parm2], [0], [--bar '' -- 'parm' 'parm2'])
+AT_CHECK([./getopt --bar -- parm], [0], [--bar '' -- 'parm'])
+AT_CHECK([./getopt --bar -- 'parm 1'], [0], [--bar '' -- 'parm 1'])
+AT_CHECK([./getopt --bar -- parm parm2], [0],
+       [--bar '' -- 'parm' 'parm2'])
+AT_CHECK([./getopt --bar -- parm parm2], [0],
+       [--bar '' -- 'parm' 'parm2'])
+AT_CHECK([./getopt --quux=parm], [1], [--],
+       [getopt: unrecognized option `--quux=parm'
+])
+AT_CHECK([./getopt --quux='parm 1'], [1], [--],
+       [getopt: unrecognized option `--quux=parm 1'
+])
+AT_CHECK([./getopt --quux='parm 1$'\''*&\\'], [1], [--],
+       [getopt: unrecognized option `--quux=parm 1$'*&\\'
+])
+AT_CHECK([./getopt --quux=parm parm2], [1], [-- 'parm2'],
+       [getopt: unrecognized option `--quux=parm'
+])
+AT_CHECK([./getopt --quux parm], [1], [-- 'parm'],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --quux parm parm2], [1], [-- 'parm' 'parm2'],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --quux -- parm], [1], [-- 'parm'],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --quux 'parm 1'], [1], [-- 'parm 1'],
+       [getopt: unrecognized option `--quux'
+])
+AT_CHECK([./getopt --quux -- parm parm2], [1], [-- 'parm' 'parm2'],
+       [getopt: unrecognized option `--quux'
+])
+
+
+AT_CLEANUP
Index: libtool--devo--1.0/tests/testsuite.at
===================================================================
--- libtool--devo--1.0.orig/tests/testsuite.at
+++ libtool--devo--1.0/tests/testsuite.at
@@ -222,6 +222,8 @@ dnl AT_TESTED([grep autoreconf autom4te 
 
 AT_INIT
 
+# shell getopt implementation sanity checks
+m4_include([getopt.at])
 # libtoolize tests
 m4_include([libtoolize.at])
 # Testing func_extract_archives

--
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook




reply via email to

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