[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI Re: 07AT_ARG_OPTION.diff
From: |
Derek Robert Price |
Subject: |
FYI Re: 07AT_ARG_OPTION.diff |
Date: |
Tue, 19 Aug 2003 14:25:05 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Paul Eggert wrote:
|address@hidden writes:
|
|>I sent this some months ago, Akim inquired as to its purpose, then
|>nothing else happened. I was hoping to finally finish CVS's
|>Autotest suite and I think this is the last of two patches that
|>would enable me to do so.
|
|
|I don't really know what that patch is for, but then I don't really
|understand Autotest either. I have the impression that Akim is busy
|on other matters, so if he doesn't comment on this topic in the next
|ten days or so, please just install it.
Installed with minor merges and corrections:
Index: ChangeLog
2003-08-19 Derek Price <address@hidden>
* lib/autotest/general.m4: Comment various HELP_* diversions.
(PARSE_ARGS_BEGIN): New section for option parsing related
initialization.
(AT_ARG_OPTION,AT_ARG_OPTION_ARG,_AT_ARG_OPTION): New macros to define
package specific options and associated help.
Index: lib/autotest/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autotest/general.m4,v
retrieving revision 1.151
diff -u -r1.151 general.m4
- --- lib/autotest/general.m4 14 Aug 2003 13:49:06 -0000 1.151
+++ lib/autotest/general.m4 19 Aug 2003 17:08:56 -0000
@@ -66,14 +66,23 @@
~ # Defined below:
~ # - DEFAULTS
~ # Overall initialization, value of $at_groups_all.
+# - PARSE_ARGS_BEGIN
+# Setup defaults required for option processing.
~ # - PARSE_ARGS
~ # Option processing. After AT_INIT, user options can be entered
here as
~ # cases of a case statement.
~ # - PARSE_ARGS_END
~ # Finish up the option processing.
~ # - HELP
- -# Start printing the help message. User help can be appended to
this as
- -# self-contained cat'd here-docs.
+# Start printing the help message.
+# - HELP_MODES
+# Modes help text. Additional modes can be appended as self-contained
+# cat'd here-docs as generated by AS_HELP_STRING.
+# - HELP_TUNING
+# TUning help text. Additional tuning options can be appended as
+# self-contained cat'd here-docs as generated by AS_HELP_STRING.
+# - HELP_OTHER
+# User help can be appended to this as self-contained cat'd here-docs.
~ # - HELP_END
~ # Finish up the help texts.
~ # - PREPARE_TESTS
@@ -89,8 +98,9 @@
~ # The code for each test, the ``normal'' diversion
~ m4_define([_m4_divert(DEFAULTS)], 100)
- -m4_define([_m4_divert(PARSE_ARGS)], 200)
- -m4_define([_m4_divert(PARSE_ARGS_END)], 201)
+m4_define([_m4_divert(PARSE_ARGS_BEGIN)], 200)
+m4_define([_m4_divert(PARSE_ARGS)], 201)
+m4_define([_m4_divert(PARSE_ARGS_END)], 202)
~ m4_define([_m4_divert(HELP)], 300)
~ m4_define([_m4_divert(HELP_MODES)], 301)
~ m4_define([_m4_divert(HELP_TUNING)], 302)
@@ -887,6 +898,128 @@
~ m4_divert_push([KILL])
~ m4_wrap([m4_divert_pop([KILL])[]])
~ ])# AT_INIT
+
+
+# _AT_ARG_OPTION(OPTIONS,HELP-TEXT,[ARGS],[ACTION-IF-GIVEN],
+# [ACTION-IF-NOT-GIVEN])
+#
-
---------------------------------------------------------------------------
+# Internal implementation of AT_ARG_OPTION & AT_ARG_OPTION_ARG
+m4_defun([_AT_ARG_OPTION],
+[m4_divert_once([HELP_OTHER],
+[cat <<_ATEOF
+
+Other options:
+_ATEOF
+])dnl m4_divert_once HELP_OTHER
+m4_divert_text([HELP_OTHER],
+[cat <<_ATEOF
+$2
+_ATEOF])dnl
+dnl Turn our options into our desired strings
+m4_ifdef([AT_first_option],[m4_undefine([AT_first_option])])dnl
+m4_ifdef([AT_case],[m4_undefine([AT_case])])dnl
+m4_ifdef([AT_case_no],[m4_undefine([AT_case_no])])dnl
+m4_ifdef([AT_case_arg],[m4_undefine([AT_case_arg])])dnl
+m4_foreach([AT_option], m4_split(m4_normalize([$1]),[[ \|]+]),
+[m4_define_default([AT_first_option],AT_option)dnl
+m4_append([AT_case],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option, [ |
])dnl
+m4_append([AT_case_no],[--no]AT_option, [ | ])dnl
+m4_append([AT_case_arg],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*],
[ | ])dnl
+])dnl m4_foreach AT_option
+dnl keep track so we or the user may process ACTION-IF-NOT-GIVEN
+m4_divert_once([PARSE_ARGS_BEGIN],
+[
+##
+## Set up package specific options.
+##
+])dnl
+m4_divert_text([PARSE_ARGS_BEGIN],
+[dnl Provide a default value for options without arguments.
+m4_ifvaln([$3],,[at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false])dnl
+at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=false
+])dnl m4_divert_text DEFAULTS
+m4_ifval([$3],[m4_divert_once([PARSE_ARGS_END],
+[
+##
+## Verify our last option didn't require an argument
+##
+AS_IF([test -n "$at_prev"],[AS_ERROR([`$at_prev' requires an
argument.])])])])
+m4_divert_text([PARSE_ARGS],
+[dnl Parse the options and args when necessary.
+m4_ifvaln([$3],
+[ AT_case )
+ at_prev=--m4_bpatsubst([AT_first_option], -, _)
+ ;;
+ AT_case_arg )
+ at_arg_[]m4_bpatsubst([AT_first_option], -, _)=$at_optarg
+ at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
+ $4
+ ;;],
+[ AT_case )
+ at_optarg=:
+ at_arg_[]m4_bpatsubst([AT_first_option], -, _)=:
+ at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
+ m4_ifval([$4],[$4])dnl
+ ;;
+ AT_case_no )
+ at_optarg=false
+ at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false
+ at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
+ m4_ifval([$4],[$4])dnl
+ ;;])dnl m4_ifvaln $3
+])dnl m4_divert_text PARSE_ARGS
+m4_ifvaln([$5],
+[m4_divert_once([PARSE_ARGS_END],
+[
+##
+## Process package specific options when _not_ supplied.
+##])dnl m4_divert_once PARSE_ARGS_END
+m4_divert_text([PARSE_ARGS_END],
+[
+AS_IF([$at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)],,[$5])dnl
+])dnl m4_divert_text PARSE_ARGS_END
+])dnl m4_ifvaln $5
+])dnl _AT_ARG_OPTION
+
+
+# AT_ARG_OPTION(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
+# ------------------------------------------------------------------------
+# Accept a set of OPTIONS with arguments. Add HELP-TEXT to the HELP_OTHER
+# diversion.
+#
+# Preceding dashes should not be passed into OPTIONS. Users will be
required
+# to pass `--' before long options and `-' before single character options.
+#
+# $at_arg_OPTION will be set to `:' if this option is received, `false' if
+# if --noOPTION is received, and `false' by default.
+#
+# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with
+# $at_optarg set to `:' or `false' as appropriate. $opt_arg is actually
+# just a copy of $at_arg_OPTION.
+#
+# ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
+# if no option from OPTIONS was found.
+m4_defun([AT_ARG_OPTION],[_AT_ARG_OPTION([$1],[$2],,[$3],[$4])])
+
+
+#
AT_ARG_OPTION_ARG(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
+#
-
---------------------------------------------------------------------------
+# Accept a set of OPTIONS with arguments, seperated by commas. Add
HELP-TEXT
+# to the HELP_OTHER diversion.
+#
+# Preceding dashes should not be passed into OPTIONS. Users will be
required
+# to pass `--' before long options and `-' before single character options.
+#
+# By default, any argument to these options will be assigned to the shell
+# variable $at_arg_OPTION, where OPTION is the first option in OPTIONS with
+# any `-' characters replaced with `_'.
+#
+# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with
+# $at_optarg set. $at_optarg is actually just a copy of $at_arg_OPTION.
+#
+# ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
+# if no option from OPTIONS was found.
+m4_defun([AT_ARG_OPTION_ARG],[_AT_ARG_OPTION([$1],[$2],1,[$3],[$4])])
~ # AT_TESTED(PROGRAMS)
Derek
- --
~ *8^)
Email: address@hidden
Get CVS support at <http://ximbiot.com>!
- --
I would rather be exposed to the inconveniences attending too much
liberty than to those attending too small a degree of it.
- Thomas Jefferson
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Netscape - http://enigmail.mozdev.org
iD8DBQE/QmuALD1OTBfyMaQRAtOQAJ96ZfN8pb8XBHGrOJ/M9JHhjVaq5wCdHZ8w
Cy77imNLCAsyRAOyFqMxJlU=
=QBqD
-----END PGP SIGNATURE-----