X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_getopt.c;h=a74ff88de7a6bcc140c492cd2da5d5158414d471;hb=4544c97f2699490bdfef560e6dbcd71de09db7b2;hp=dbb3f3f76dd76630b112c01e875adcf657d2a2af;hpb=aff0a2728543eee1ac21f3fa02f171caae8d9362;p=rrdtool.git diff --git a/src/rrd_getopt.c b/src/rrd_getopt.c index dbb3f3f..a74ff88 100644 --- a/src/rrd_getopt.c +++ b/src/rrd_getopt.c @@ -112,6 +112,14 @@ Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ +/* + * On some versions of Solaris, opterr and friends are defined in core libc + * rather than in a separate getopt module. Define these variables only + * if configure found they aren't there by default. (We assume that testing + * opterr is sufficient for all of these except optreset.) + */ +#ifndef HAVE_INT_OPTERR + char *optarg = NULL; /* Index in ARGV of the next element to be scanned. @@ -126,9 +134,28 @@ char *optarg = NULL; Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* 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. */ + +int optopt = '?'; + /* 1003.2 says this must be 1 before any call. */ int optind = 1; +#else + extern int opterr; + extern int optind; + extern int optopt; + extern char *optarg; +#endif + + /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ @@ -144,16 +171,6 @@ int __getopt_initialized = 0; static char *nextchar; -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* 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. */ - -int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. @@ -257,7 +274,8 @@ static char *const *original_argv; to getopt is that one passed to the process. */ static void store_args( int argc, - char *const *argv) __attribute__ ((unused)); + char *const *argv); + static void store_args( int argc, char *const *argv)