diff Python/getopt.c @ 75147:0abffbe7cf22 2.7

Fix crash at startup with -W options.
author Antoine Pitrou <solipsis@pitrou.net>
date Tue, 21 Feb 2012 20:42:48 +0100
parents fd25030223b0
children d2df83d7c649
line wrap: on
line diff
--- a/Python/getopt.c	Tue Feb 21 18:12:02 2012 +0100
+++ b/Python/getopt.c	Tue Feb 21 20:42:48 2012 +0100
@@ -37,10 +37,18 @@
 int _PyOS_opterr = 1;          /* generate error messages */
 int _PyOS_optind = 1;          /* index into argv array   */
 char *_PyOS_optarg = NULL;     /* optional argument       */
+static char *opt_ptr = "";
+
+void _PyOS_ResetGetOpt(void)
+{
+    _PyOS_opterr = 1;
+    _PyOS_optind = 1;
+    _PyOS_optarg = NULL;
+    opt_ptr = "";
+}
 
 int _PyOS_GetOpt(int argc, char **argv, char *optstring)
 {
-    static char *opt_ptr = "";
     char *ptr;
     int option;