+++ /dev/null
-/*---------------------------------------------------------------------------*\r
- * <RCS keywords>\r
- *\r
- * C++ Library\r
- *\r
- * Copyright 1992-1994, David Gottner\r
- *\r
- * All Rights Reserved\r
- *\r
- * Permission to use, copy, modify, and distribute this software and its\r
- * documentation for any purpose and without fee is hereby granted,\r
- * provided that the above copyright notice, this permission notice and\r
- * the following disclaimer notice appear unmodified in all copies.\r
- *\r
- * I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL I\r
- * BE LIABLE FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY\r
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER\r
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\r
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\r
- *\r
- * Nevertheless, I would like to know about bugs in this library or\r
- * suggestions for improvment. Send bug reports and feedback to\r
- * davegottner@delphi.com.\r
- *---------------------------------------------------------------------------*/\r
-\r
-/* Modified to support --help and --version, as well as /? on Windows\r
- * by Georg Brandl. */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-int _PyOS_opterr = 1; /* generate error messages */\r
-int _PyOS_optind = 1; /* index into argv array */\r
-char *_PyOS_optarg = NULL; /* optional argument */\r
-\r
-int _PyOS_GetOpt(int argc, char **argv, char *optstring)\r
-{\r
- static char *opt_ptr = "";\r
- char *ptr;\r
- int option;\r
-\r
- if (*opt_ptr == '\0') {\r
-\r
- if (_PyOS_optind >= argc)\r
- return -1;\r
-#ifdef MS_WINDOWS\r
- else if (strcmp(argv[_PyOS_optind], "/?") == 0) {\r
- ++_PyOS_optind;\r
- return 'h';\r
- }\r
-#endif\r
-\r
- else if (argv[_PyOS_optind][0] != '-' ||\r
- argv[_PyOS_optind][1] == '\0' /* lone dash */ )\r
- return -1;\r
-\r
- else if (strcmp(argv[_PyOS_optind], "--") == 0) {\r
- ++_PyOS_optind;\r
- return -1;\r
- }\r
-\r
- else if (strcmp(argv[_PyOS_optind], "--help") == 0) {\r
- ++_PyOS_optind;\r
- return 'h';\r
- }\r
-\r
- else if (strcmp(argv[_PyOS_optind], "--version") == 0) {\r
- ++_PyOS_optind;\r
- return 'V';\r
- }\r
-\r
-\r
- opt_ptr = &argv[_PyOS_optind++][1];\r
- }\r
-\r
- if ( (option = *opt_ptr++) == '\0')\r
- return -1;\r
-\r
- if (option == 'J') {\r
- fprintf(stderr, "-J is reserved for Jython\n");\r
- return '_';\r
- }\r
-\r
- if (option == 'X') {\r
- fprintf(stderr,\r
- "-X is reserved for implementation-specific arguments\n");\r
- return '_';\r
- }\r
-\r
- if ((ptr = strchr(optstring, option)) == NULL) {\r
- if (_PyOS_opterr)\r
- fprintf(stderr, "Unknown option: -%c\n", option);\r
-\r
- return '_';\r
- }\r
-\r
- if (*(ptr + 1) == ':') {\r
- if (*opt_ptr != '\0') {\r
- _PyOS_optarg = opt_ptr;\r
- opt_ptr = "";\r
- }\r
-\r
- else {\r
- if (_PyOS_optind >= argc) {\r
- if (_PyOS_opterr)\r
- fprintf(stderr,\r
- "Argument expected for the -%c option\n", option);\r
- return '_';\r
- }\r
-\r
- _PyOS_optarg = argv[_PyOS_optind++];\r
- }\r
- }\r
-\r
- return option;\r
-}\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r