aboutsummaryrefslogtreecommitdiff
path: root/src/getopt.m4
diff options
context:
space:
mode:
Diffstat (limited to 'src/getopt.m4')
-rw-r--r--src/getopt.m451
1 files changed, 40 insertions, 11 deletions
diff --git a/src/getopt.m4 b/src/getopt.m4
index a086c76..44e2408 100644
--- a/src/getopt.m4
+++ b/src/getopt.m4
@@ -64,25 +64,40 @@ dnl GROUP(STRING)
dnl Begin a named group of options
dnl
define([<GROUP>],[<dnl
-divert(3)
- { NULL, NULL, 0, N_("prep([<$1>])") },
+divert(3)ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+ { NULL, NULL, 0, N_("prep([<$1>])") },dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)>])
define([<__GATHER_OPTIONS>],[<
define([<KEY>],ifelse([<$2>],,[<OPTION_>]upcase(patsubst($1,-,_)),'$2'))
ifelse([<$2>],,[<
-divert(1)
- KEY,
+divert(1)ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+ KEY,dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)
>])
define([<SELECTOR>],ifdef([<SELECTOR>],SELECTOR) case KEY:)
ifelse([<$1>],,,[<
-divert(2)
- { "$1", ARGTYPE, 0, KEY },
+divert(2)ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+ { "$1", ARGTYPE, 0, KEY },dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)>])
dnl
define([<SHORT_OPTS>],SHORT_OPTS[<>]dnl
-ifelse([<$2>],,,$2[<>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::)))
+ifelse([<$2>],,,dnl
+ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+"$2[<>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::)"dnl
+ifdef([<IFCOND>],[<
+#endif
+>])))
dnl
ifelse([<$1>],,,dnl
[<define([<LONG_TAG>],ifelse(LONG_TAG,,[<--$1>],[<LONG_TAG; --$1>]))>])
@@ -118,6 +133,12 @@ patsubst([<$3>],[<\[.*\]>]),,[<optional_argument>],dnl
__GATHER_OPTIONS($@)
>])
+define([<IFDEF>],[<
+pushdef([<IFCOND>],[<$1>])
+$2
+popdef([<IFCOND>])
+>])
+
dnl ALIAS(long-opt, short-opt)
dnl Declare aliases for the previous OPTION statement.
dnl long-opt Long option.
@@ -135,12 +156,16 @@ dnl statement, with optional ALIAS statements in between.
dnl
define([<BEGIN>],[<
ifelse([<DOCSTRING>],,,[<
-divert(3)
+divert(3)dnl
+ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
{ "translit(dnl
ifelse(SHORT_TAG,,LONG_TAG,[<SHORT_TAG[<>]ifelse(LONG_TAG,,,; LONG_TAG)>]),
[<;>],[<,>])", ifelse(ARGNAME,,[<NULL, 0>],
[<ifelse(ARGTYPE,[<optional_argument>],
-[<patsubst(ARGNAME,[<\[\(.*\)\]>],[<N_("\1"), 1>])>],[<N_("ARGNAME"), 0>])>]), N_("DOCSTRING") },
+[<patsubst(ARGNAME,[<\[\(.*\)\]>],[<N_("\1"), 1>])>],[<N_("ARGNAME"), 0>])>]), N_("DOCSTRING") },dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)>])
popdef([<ARGTYPE>])
popdef([<ARGNAME>])
@@ -148,6 +173,8 @@ popdef([<DOCSTRING>])
divert(4)dnl
popdef([<LONG_TAG>])dnl
popdef([<SHORT_TAG>])dnl
+ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
SELECTOR
{
>])
@@ -157,7 +184,9 @@ dnl Finish the associated action
dnl
define([<END>],[<
break;
- }
+ }dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)
undefine([<SELECTOR>])>])
@@ -173,7 +202,7 @@ define([<GETOPT>],[<
int c;
ifelse([<$#>],3,opterr = 0;)
- while ((c = getopt_long($1, $2, "SHORT_OPTS",
+ while ((c = getopt_long($1, $2, SHORT_OPTS,
long_options, NULL)) != EOF)
{
switch (c)

Return to:

Send suggestions and report system problems to the System administrator.