X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=getopt%2Fgetopt.c;h=f5632d7ccc420cf99ad48871391a5451d8e91e83;hp=4744e43390ac66c9d46ad35d38460627906c78be;hb=98f57d3adc542bb7753434ce31c92a6680bd6244;hpb=58319f51aa5804c90fe5edd8e5f0386b7a297827 diff --git a/getopt/getopt.c b/getopt/getopt.c index 4744e43..f5632d7 100644 --- a/getopt/getopt.c +++ b/getopt/getopt.c @@ -28,7 +28,7 @@ #endif #ifdef HAVE_CONFIG_H -# include +//# include #endif #if !defined __STDC__ || !__STDC__ @@ -109,7 +109,9 @@ Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ +#if ! defined(HAVE_GETOPT) && ! defined(HAVE_GETOPT_LONG) char *optarg; +#endif /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -124,13 +126,19 @@ char *optarg; how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ +#if ! defined(HAVE_GETOPT) && ! defined(HAVE_GETOPT_LONG) int optind = 1; +#endif /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ +#if ! defined(HAVE_GETOPT) && ! defined(HAVE_GETOPT_LONG) int __getopt_initialized; +#else +extern int __getopt_initialized; +#endif /* The next char to be scanned in the option-element in which the last option character we returned was found. @@ -144,13 +152,17 @@ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ +#if ! defined(HAVE_GETOPT) && ! defined(HAVE_GETOPT_LONG) int opterr = 1; +#endif /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ +#if ! defined(HAVE_GETOPT) && ! defined(HAVE_GETOPT_LONG) int optopt = '?'; +#endif /* Describe how to deal with options that follow non-option ARGV-elements. @@ -968,6 +980,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) } } +#ifndef HAVE_GETOPT int getopt (argc, argv, optstring) int argc; @@ -979,6 +992,7 @@ getopt (argc, argv, optstring) (int *) 0, 0); } +#endif #endif /* Not ELIDE_CODE. */