static int quiet_errors=0; /* 0 is not quiet. */
static int quiet_output=0; /* 0 is not quiet. */
static int quote=1; /* 1 is do quote. */
-static int alternative=0; /* 0 is getopt_long, 1 is getopt_long_only */
+
+/* Allow changing which getopt is in use with function pointer */
+int (*getopt_long_fp) (int argc, char *const *argv, const char *optstr,
+ const struct option * longopts, int *longindex);
/* Function prototypes */
static const char *normalize(const char *arg);
opterr=0;
optind=0; /* Reset getopt(3) */
- while ((opt = (alternative?
- getopt_long_only(argc,argv,optstr,longopts,&longindex):
- getopt_long(argc,argv,optstr,longopts,&longindex)))
+ while ((opt = (getopt_long_fp(argc,argv,optstr,longopts,&longindex)))
!= EOF)
if (opt == '?' || opt == ':' )
exit_code = GETOPT_EXIT_CODE;
textdomain(PACKAGE);
init_longopt();
+ getopt_long_fp = getopt_long;
if (getenv("GETOPT_COMPATIBLE"))
compatible=1;
while ((opt=getopt_long(argc,argv,shortopts,longopts,NULL)) != EOF)
switch (opt) {
case 'a':
- alternative=1;
+ getopt_long_fp = getopt_long_only;
break;
case 'h':
print_help();