From 6ba1b759a97e9230592a1cd5680038e3a2ba4845 Mon Sep 17 00:00:00 2001 From: millert <> Date: Fri, 22 Nov 2013 21:32:49 +0000 Subject: [PATCH] The getopt() prototype and externs don't belong in stdlib.h. Berkeley moved them to unistd.h to match POSIX in 1995 but we never did. The exception to this is getsubopt() which POSIX says should be in stdlib.h. The non-standard suboptarg extern remains in the BSD-only section of stdlib.h. Neither getsubopt() nor suboptarg belong in unistd.h or getopt.h. They were only there to allow us to protect all the getopt() bits from being multiply defined. OK guenther@ --- src/include/getopt.h | 6 ++---- src/include/stdlib.h | 13 +++++-------- src/include/unistd.h | 5 +---- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/include/getopt.h b/src/include/getopt.h index 0311b078..dd518644 100644 --- a/src/include/getopt.h +++ b/src/include/getopt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: getopt.h,v 1.2 2008/06/26 05:42:04 ray Exp $ */ +/* $OpenBSD: getopt.h,v 1.3 2013/11/22 21:32:49 millert Exp $ */ /* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ /*- @@ -36,7 +36,7 @@ #include /* - * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions + * GNU-like getopt_long() */ #define no_argument 0 #define required_argument 1 @@ -64,14 +64,12 @@ int getopt_long_only(int, char * const *, const char *, #ifndef _GETOPT_DEFINED_ #define _GETOPT_DEFINED_ int getopt(int, char * const *, const char *); -int getsubopt(char **, char * const *, char **); extern char *optarg; /* getopt(3) external variables */ extern int opterr; extern int optind; extern int optopt; extern int optreset; -extern char *suboptarg; /* getsubopt(3) external variable */ #endif __END_DECLS diff --git a/src/include/stdlib.h b/src/include/stdlib.h index be7b137f..971388aa 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdlib.h,v 1.53 2013/10/21 20:33:24 deraadt Exp $ */ +/* $OpenBSD: stdlib.h,v 1.54 2013/11/22 21:32:49 millert Exp $ */ /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ /*- @@ -248,6 +248,10 @@ int posix_openpt(int); char *mkdtemp(char *); #endif +#if __XPG_VISIBLE >= 420 || __POSIX_VISIBLE >= 20080 +int getsubopt(char **, char * const *, char **); +#endif + #if __BSD_VISIBLE void *alloca(size_t); @@ -274,14 +278,7 @@ const char * getprogname(void); void setprogname(const char *); -#ifndef _GETOPT_DEFINED_ -#define _GETOPT_DEFINED_ -int getopt(int, char * const *, const char *); -extern char *optarg; /* getopt(3) external variables */ -extern int opterr, optind, optopt, optreset; -int getsubopt(char **, char * const *, char **); extern char *suboptarg; /* getsubopt(3) external variable */ -#endif /* _GETOPT_DEFINED_ */ int mkstemps(char *, int); diff --git a/src/include/unistd.h b/src/include/unistd.h index 5a49e70c..0f1aa048 100644 --- a/src/include/unistd.h +++ b/src/include/unistd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unistd.h,v 1.80 2013/10/24 07:34:56 guenther Exp $ */ +/* $OpenBSD: unistd.h,v 1.81 2013/11/22 21:32:49 millert Exp $ */ /* $NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $ */ /*- @@ -391,9 +391,6 @@ size_t confstr(int, char *, size_t) int getopt(int, char * const *, const char *); extern char *optarg; /* getopt(3) external variables */ extern int opterr, optind, optopt, optreset; -/* XXX - getsubopt does not belong here */ -int getsubopt(char **, char * const *, char **); -extern char *suboptarg; /* getsubopt(3) external variable */ #endif /* _GETOPT_DEFINED_ */ #endif