Use the optreset variable on BSD systems.

On BSD based operating systems the optreset variable should be used to
reset the internal getopt state. Setting optind to zero is a GNU
extension.
This commit is contained in:
Jef Driesen 2016-01-27 23:41:51 +01:00
parent ade8619ea6
commit 5add68b2d5
2 changed files with 6 additions and 0 deletions

View File

@ -107,6 +107,9 @@ AC_CHECK_HEADERS([linux/serial.h])
AC_CHECK_HEADERS([IOKit/serial/ioss.h])
AC_CHECK_HEADERS([getopt.h])
# Checks for global variable declarations.
AC_CHECK_DECLS([optreset])
# Checks for library functions.
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([localtime_r gmtime_r])

View File

@ -217,6 +217,9 @@ main (int argc, char *argv[])
argc -= optind;
argv += optind;
optind = RESET;
#if defined(HAVE_DECL_OPTRESET) && HAVE_DECL_OPTRESET
optreset = 1;
#endif
// Translate the help option into a command.
char *argv_help[] = {(char *) "help", NULL, NULL};