X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/c957a83bde4df2e2d3d1ed0963656856b48ef0a0..224c70764cab4e0e39a26aaf3ad3016552f62f55:/stdlib/FreeBSD/getopt.c.patch diff --git a/stdlib/FreeBSD/getopt.c.patch b/stdlib/FreeBSD/getopt.c.patch new file mode 100644 index 0000000..4b9ad71 --- /dev/null +++ b/stdlib/FreeBSD/getopt.c.patch @@ -0,0 +1,59 @@ +--- ../Libc/stdlib/FreeBSD/getopt.c 2004-11-25 11:38:41.000000000 -0800 ++++ getopt.c 2005-01-26 19:27:09.000000000 -0800 +@@ -48,16 +48,24 @@ + + #include "libc_private.h" + ++#ifndef BUILDING_VARIANT + int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ + char *optarg; /* argument associated with option */ ++#endif /* !BUILDING_VARIANT */ + + #define BADCH (int)'?' + #define BADARG (int)':' + #define EMSG "" + ++#if __DARWIN_UNIX03 ++#define PROGNAME nargv[0] ++#else ++#define PROGNAME _getprogname() ++#endif ++ + /* + * getopt -- + * Parse argc/argv argument vector. +@@ -103,8 +111,8 @@ + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, +- "%s: illegal option -- %c\n", _getprogname(), +- optopt); ++ "%s: illegal option -- %c\n", ++ PROGNAME, optopt); + return (BADCH); + } + +@@ -123,13 +131,19 @@ + optarg = nargv[optind]; + else { + /* option-argument absent */ ++#if __DARWIN_UNIX03 ++ /* Yes, the standard will put optind past the last ++ argument */ ++ ++optind; ++ optarg = NULL; ++#endif /* __DARWIN_UNIX03 */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", +- _getprogname(), optopt); ++ PROGNAME, optopt); + return (BADCH); + } + place = EMSG;