[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix autotest option parsing
From: |
Eric Blake |
Subject: |
fix autotest option parsing |
Date: |
Sat, 24 Feb 2007 20:48:19 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I noticed three problems in autotest-generated testsuites with regards to
option parsing. This patches two of them:
1) POSIX suggests that implementations support compressed short options,
even though it is not canonical style. I was bothered when I tried to
save typing with 'tests/testsuite -lkm4sugar', and had to use the longer
'tests/testsuite -l -k m4sugar' instead.
2) GNU Coding standards require that 'tests/testsuite --version --help'
output version info, not help.
3) Not patched here. We should support -- to end options, to be
consistent with POSIX, as in 'tests/testsuite -- foo=bar -2'. But
technically, all the non-options that testsuite currently supports are
VARIABLE=VALUE and TESTS. VARIABLE never starts with -. And although
TESTS can start with a -, we already require that TESTS consist only of
digits and dashes, and can already distinguish when TESTS is intermixed
with options, so we aren't really in a situation where we can confuse a
non-option with an option to the point that -- is essential.
This patch has a minor drawback - I had to use set to manage the argument
parsing loop, so any code within a particular option (such as --keywords)
can no longer use set for its own purposes; this is a potential regression
if user code inserted custom --option processing that used set to the end
of the PARSE_ARGS m4 diversion. So this particular version of the patch
is mainly for soliciting feedback.
If this code is acceptable, I will need to add a test to the testsuite
that exercises these features.
2007-02-24 Eric Blake <address@hidden>
* lib/autotest/general.m4 (AT_help_all): Recognize compressed
short options. Obey GNU Coding Standards when presented both
--help and --version.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFF4QcA84KuGfSFAYARAhZdAJ9LWrA/htPPgXXnKQyNCPRiIoc2oQCgyyuz
qblI94y/DJxerEdGuR4eKSU=
=9+/P
-----END PGP SIGNATURE-----
Index: lib/autotest/general.m4
===================================================================
RCS file: /sources/autoconf/autoconf/lib/autotest/general.m4,v
retrieving revision 1.220
diff -u -p -r1.220 general.m4
--- lib/autotest/general.m4 24 Feb 2007 21:48:24 -0000 1.220
+++ lib/autotest/general.m4 25 Feb 2007 03:21:23 -0000
@@ -282,8 +282,11 @@ at_help_all="AS_ESCAPE(m4_defn([AT_help_
m4_divert_push([PARSE_ARGS])dnl
at_prev=
-for at_option
+while test address@hidden:@] -gt 0
do
+ at_option=$[1]
+ shift
+
# If the previous option needs an argument, assign it.
if test -n "$at_prev"; then
at_option=$at_prev=$at_option
@@ -298,16 +301,18 @@ do
# Accept the important Cygnus configure options, so we can diagnose typos.
case $at_option in
- --help | -h )
+ --help | -h* )
at_help_p=:
+ break
;;
--list | -l )
at_list_p=:
;;
- --version | -V )
+ --version | -V* )
at_version_p=:
+ break
;;
--clean | -c )
@@ -380,11 +385,9 @@ do
at_groups_selected=$at_help_all
at_save_IFS=$IFS
IFS=,
- set X $at_optarg
- shift
- IFS=$at_save_IFS
- for at_keyword
+ for at_keyword in $at_optarg
do
+ IFS=$at_save_IFS
at_invert=
case $at_keyword in
'!'*)
@@ -396,6 +399,7 @@ do
at_groups_selected=`AS_ECHO(["$at_groups_selected"]) |
grep -i $at_invert ["^[1-9][^;]*;.*[; ]$at_keyword[ ;]"]`
done
+ IFS=$at_save_IFS
# Smash the newlines.
at_groups_selected=`AS_ECHO(["$at_groups_selected"]) | sed 's/;.*//' |
tr "$as_nl" ' '
@@ -404,8 +408,25 @@ do
;;
m4_divert_pop([PARSE_ARGS])dnl
dnl Process *=* last to allow for user specified --option=* type arguments.
+dnl The user had better not use 'set' in their action.
m4_divert_push([PARSE_ARGS_END])dnl
+ # Separate single-letter options without arguments
+ -l* | -c* | -d* | -e* | -v* | -x* )
+ at_tmp1=`expr "x$at_option" : 'x\(-.\)'`
+ at_tmp2=`expr "x$at_option" : 'x-.\(.*\)'`
+ set X "$at_tmp1" "-$at_tmp2" "address@hidden"
+ shift
+ ;;
+
+ # Recognize single-letter options with no space before argument
+ -k*)
+ at_prev=--keywords
+ at_tmp=`expr "x$at_option" : 'x-k\(.*\)'`
+ set X "$at_tmp" "address@hidden"
+ shift
+ ;;
+
*=*)
at_envvar=`expr "x$at_option" : 'x\([[^=]]*\)='`
# Reject names that are not valid shell variable names.
- fix autotest option parsing,
Eric Blake <=