+2010-06-28 Gary V. Vaughan <gary@gnu.org>
+
+ Add an XSI replacement for func_split_short_opt, with test cases.
+ * libltdl/config/getopt.m4sh (m4go_shortnoargs): Remove 'v' now
+ that getopt.m4sh doesn't steal that letter for the --version
+ short option.
+ * libltdl/config/ltmain.m4sh (M4SH_GETOPTS): We can now use 'v'
+ as a short option for '--verbose'.
+ * libltdl/config/getopt.m4sh (m4go_printopts): Add back in the
+ leading '-' for remaining non-argument short options.
+ (func_split_short_opt): Use the correct sed script variable.
+ * libltdl/m4/libtool.m4 (_LT_CHECK_SHELL_FEATURES): Also ensure
+ that XSI substring extraction is supported.
+ (_LT_PROG_XSI_SHELLFNS): Use XSI substring extraction to split
+ short options to avoid unnecessary forks if the host shell
+ supports that.
+ * tests/getopt-m4sh.at: New tests for getopt.m4sh coverage.
+ * Makefile.am (TESTSUITE_AT): Add getopt-m4sh.at.
+ (TESTS_ENVIRONMENT): Pass M4SH and SED for substition into the
+ m4sh expansion performed in tests/getopt-m4sh.at.
+
2010-06-27 Gary V. Vaughan <gary@gnu.org>
Add missing case branch terminators.
# OPTION, [|])' to insert the separator pipe symbols - which requires
# that `m4go_shortargs' be undefined if the first option appended is not
# prefixed by a leading `|'.
-m4_define([m4go_shortnoargs], [-\?*|-h*|-v*])
+m4_define([m4go_shortnoargs], [-\?*|-h*])
# M4SH_GETOPTS(SHORT-SPEC1, LONG-MATCH1, DEF1, INIT1,
[ # Separate non-argument short options:
]m4go_shortnoargs[)
func_split_short_opt "$opt"
- set dummy "$func_split_short_opt_name" "$func_split_short_opt_arg" ${1+"[$]@"}
+ set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"[$]@"}
shift
;;
my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
- func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_arg"`
+ func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
} # func_split_short_opt may be replaced by XSI optimised implementation
AC_MSG_RESULT([$lt_shell_append])
_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+AC_MSG_CHECKING([whether the shell understands variable substring :-syntax])
+lt_shell_substring=no
+( _lt_dummy="-bar"
+ test "${_lt_dummy:0:2},${_lt_dummy:2}" = -b,ar ) >/dev/null 2>&1 \
+&& lt_shell_substring=yes
+AC_MSG_RESULT([$lt_shell_substring])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_substring='$lt_shell_substring'])
+
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
lt_unset=unset
else
_LT_PROG_XSI_REPLACE([func_append], [ eval "${1}+=\\${2}"])
fi
+if test x"$lt_shell_substring" = xyes; then
+ _LT_PROG_XSI_REPLACE([func_split_short_opt], [dnl
+ func_split_short_opt_name=${1:0:2}
+ func_split_short_opt_arg=${1:2}])
+fi
+
if test x"$_lt_xsi_replace_fail" = x":"; then
AC_MSG_WARN([Unable to substitute faster XSI functions in $ofile])
fi
--- /dev/null
+# getopts-m4sh.at -- test getopts.m4sh option parsers -*- Autotest -*-
+#
+# Copyright (C) 2010 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2010
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool 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 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+####
+
+AT_BANNER([Shell option parser generator.])
+
+auxdir="$abs_top_srcdir/libltdl/config"
+
+
+# _LT_AT_GETOPT_M4SH_SETUP
+# ------------------------
+m4_define([_LT_AT_GETOPT_M4SH_SETUP],
+[m4_pattern_allow([AS_INIT])
+m4_pattern_allow([m4_include])
+AT_DATA([options.m4sh],
+[[AS_INIT[]m4_include([getopt.m4sh])
+options=
+M4SH_GETOPTS(
+ [f], [--force], [], [options="$options force"],
+ [i], [--install], [], [options="$options install"],
+ [v], [--verbose], [], [options="$options verbose"],
+ [!], [--ltdl], [false],[options="$options ltdl=$optarg"],
+[echo $options])
+]])
+m4_pattern_forbid([m4_include])
+m4_pattern_forbid([AS_INIT])
+
+$M4SH -B $abs_top_srcdir/libltdl/config options.m4sh \
+ | $SED \
+ -e "s,@LN_S\@,$LN_S,g" \
+ -e "s,@SED\@,$SED,g" \
+ > options
+])# _LT_AT_GETOPT_M4SH_SETUP
+
+
+# _LT_AT_XSI_FUNC_EXTRACT(FUNC-NAME)
+# ----------------------------------
+# Extract the XSI decorated function FUNC-NAME from libtool
+m4_define([_LT_AT_XSI_FUNC_EXTRACT],
+[dnl {{
+$SED '/^# $1/q' options > options.tmp
+$SED -n '/^$1/,/^} # XSI $1 /p' $abs_top_builddir/libtool >> options.tmp
+$SED '1,/^} # $1 /d' options >> options.tmp
+rm -f options && mv options.tmp options])
+
+
+## ----------------------- ##
+## Short option splitting. ##
+## ----------------------- ##
+
+AT_SETUP([short option splitting])
+
+AT_DATA(expout,
+[[force verbose install
+]])
+
+_LT_AT_GETOPT_M4SH_SETUP
+
+AT_CHECK([$SHELL ./options -fvi], 0, [expout])
+
+AT_CLEANUP
+
+
+AT_SETUP([enhanced shell short option splitting])
+
+# Don't bother with additional XSI checks unless functions were substituted
+AT_CHECK([fgrep '# XSI func_split_short_opt' $abs_top_builddir/libtool >/dev/null 2>&1 || (exit 77)])
+
+AT_DATA(expout,
+[[force verbose install
+]])
+
+_LT_AT_GETOPT_M4SH_SETUP
+_LT_AT_XSI_FUNC_EXTRACT(func_split_short_opt)
+
+AT_CHECK([$SHELL ./options -fvi], 0, [expout])
+
+AT_CLEANUP
+
+
+## ---------------------- ##
+## Long option splitting. ##
+## ---------------------- ##
+
+AT_SETUP([long option splitting])
+
+AT_DATA(expout,
+[[ltdl=long
+]])
+
+_LT_AT_GETOPT_M4SH_SETUP
+
+AT_CHECK([$SHELL ./options --ltdl=long], 0, [expout])
+
+AT_CLEANUP
+
+
+AT_SETUP([XSI long option splitting])
+
+# Don't bother with additional XSI checks unless functions were substituted
+AT_CHECK([fgrep '# XSI func_split_long_opt' $abs_top_builddir/libtool >/dev/null 2>&1 || (exit 77)])
+
+AT_DATA(expout,
+[[ltdl=long
+]])
+
+_LT_AT_GETOPT_M4SH_SETUP
+_LT_AT_XSI_FUNC_EXTRACT(func_split_long_opt)
+
+AT_CHECK([$SHELL ./options --ltdl=long], 0, [expout])
+
+AT_CLEANUP