]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.10/PyMod-2.7.10/Modules/main.c
AppPkg/.../Python-2.7.10: AppPkg.dsc, pyconfig.h, PyMod-2.7.10
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / PyMod-2.7.10 / Modules / main.c
index 1abed3725ae731c8b75f953afa340bb3a75a7f10..c7d6c5f68b2b2ee888eb622ec8d6b5685632533a 100644 (file)
@@ -1,4 +1,8 @@
-/* Python interpreter main program */\r
+/** @file\r
+  Python interpreter main program.\r
+\r
+  Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>\r
+**/\r
 \r
 #include "Python.h"\r
 #include "osdefs.h"\r
@@ -40,7 +44,7 @@ static char **orig_argv;
 static int  orig_argc;\r
 \r
 /* command line options */\r
-#define BASE_OPTS "3bBc:dEhiJm:OQ:RsStuUvVW:xX?"\r
+#define BASE_OPTS "#3bBc:dEhiJm:OQ:sStuUvVW:xX?"\r
 \r
 #ifndef RISCOS\r
 #define PROGRAM_OPTS BASE_OPTS\r
@@ -59,6 +63,7 @@ static char *usage_line =
 /* Long usage message, split into parts < 512 bytes */\r
 static char *usage_1 = "\\r
 Options and arguments (and corresponding environment variables):\n\\r
+-#     : alias stderr to stdout for platforms without STDERR output.\n\\r
 -B     : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\\r
 -c cmd : program passed in as string (terminates option list)\n\\r
 -d     : debug output from parser; also PYTHONDEBUG=x\n\\r
@@ -71,9 +76,6 @@ static char *usage_2 = "\
 -m mod : run library module as a script (terminates option list)\n\\r
 -O     : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\\r
 -OO    : remove doc-strings in addition to the -O optimizations\n\\r
--R     : use a pseudo-random salt to make hash() values of various types be\n\\r
-         unpredictable between separate invocations of the interpreter, as\n\\r
-         a defense against denial-of-service attacks\n\\r
 -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\\r
 -s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\\r
 -S     : don't imply 'import site' on initialization\n\\r
@@ -102,15 +104,9 @@ PYTHONPATH   : '%c'-separated list of directories prefixed to the\n\
 static char *usage_5 = "\\r
 PYTHONHOME   : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\\r
                The default module search path uses %s.\n\\r
-PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\\r
+PYTHONCASEOK : ignore case in 'import' statements (UEFI default).\n\\r
 PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\\r
 ";\r
-static char *usage_6 = "\\r
-PYTHONHASHSEED: if this variable is set to 'random', the effect is the same\n\\r
-   as specifying the -R option: a random value is used to seed the hashes of\n\\r
-   str, bytes and datetime objects.  It can also be set to an integer\n\\r
-   in the range [0,4294967295] to get hash values with a predictable seed.\n\\r
-";\r
 \r
 \r
 static int\r
@@ -127,7 +123,6 @@ usage(int exitcode, char* program)
         fputs(usage_3, f);\r
         fprintf(f, usage_4, DELIM);\r
         fprintf(f, usage_5, DELIM, PYTHONHOMEHELP);\r
-        fputs(usage_6, f);\r
     }\r
 #if defined(__VMS)\r
     if (exitcode == 0) {\r
@@ -251,6 +246,7 @@ Py_Main(int argc, char **argv)
     int help = 0;\r
     int version = 0;\r
     int saw_unbuffered_flag = 0;\r
+    int saw_pound_flag = 0;\r
     PyCompilerFlags cf;\r
 \r
     cf.cf_flags = 0;\r
@@ -266,26 +262,27 @@ Py_Main(int argc, char **argv)
        (including -W and -X options). */\r
     _PyOS_opterr = 0;  /* prevent printing the error in 1st pass */\r
     while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {\r
-        if (c == 'm' || c == 'c') {\r
-            /* -c / -m is the last option: following arguments are\r
-               not interpreter options. */\r
-            break;\r
-        }\r
-        switch (c) {\r
+      if (c == 'm' || c == 'c') {\r
+        /* -c / -m is the last option: following arguments are\r
+           not interpreter options. */\r
+        break;\r
+      }\r
+      switch (c) {\r
+        case '#':\r
+          if (saw_pound_flag == 0) {\r
+            if(freopen("stdout:", "w", stderr) == NULL) {\r
+              puts("ERROR: Unable to reopen stderr as an alias to stdout!");\r
+            }\r
+            saw_pound_flag = 0xFF;\r
+          }\r
+          break;\r
         case 'E':\r
-            Py_IgnoreEnvironmentFlag++;\r
-            break;\r
-        case 'R':\r
-            Py_HashRandomizationFlag++;\r
-            break;\r
-        }\r
+          Py_IgnoreEnvironmentFlag++;\r
+          break;\r
+        default:\r
+          break;\r
+      }\r
     }\r
-    /* The variable is only tested for existence here; _PyRandom_Init will\r
-       check its value further. */\r
-    if (!Py_HashRandomizationFlag &&\r
-        (p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0')\r
-        Py_HashRandomizationFlag = 1;\r
-\r
     _PyRandom_Init();\r
 \r
     PySys_ResetWarnOptions();\r
@@ -426,7 +423,7 @@ Py_Main(int argc, char **argv)
             PySys_AddWarnOption(_PyOS_optarg);\r
             break;\r
 \r
-        case 'R':\r
+        case '#':\r
             /* Already handled above */\r
             break;\r
 \r