1
/* Minimal main program -- everything is loaded from the library */
7
#include <floatingpoint.h>
12
wmain(int argc, wchar_t **argv)
14
return Py_Main(argc, argv);
19
main(int argc, char **argv)
22
/* We need a second copy, as Python might modify the first one. */
30
argv_copy = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1));
31
argv_copy2 = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1));
32
if (!argv_copy || !argv_copy2) {
33
fprintf(stderr, "out of memory\n");
37
/* 754 requires that FP exceptions run in "no stop" mode by default,
38
* and until C vendors implement C99's ways to control FP exceptions,
39
* Python requires non-stop mode. Alas, some platforms enable FP
40
* exceptions by default. Here we disable them.
44
fpsetmask(m & ~FP_X_OFL);
47
oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
49
fprintf(stderr, "out of memory\n");
53
setlocale(LC_ALL, "");
54
for (i = 0; i < argc; i++) {
55
argv_copy[i] = _Py_char2wchar(argv[i], NULL);
57
PyMem_RawFree(oldloc);
58
fprintf(stderr, "Fatal Python error: "
59
"unable to decode the command line argument #%i\n",
63
argv_copy2[i] = argv_copy[i];
65
argv_copy2[argc] = argv_copy[argc] = NULL;
67
setlocale(LC_ALL, oldloc);
68
PyMem_RawFree(oldloc);
69
res = Py_Main(argc, argv_copy);
70
for (i = 0; i < argc; i++) {
71
PyMem_RawFree(argv_copy2[i]);
73
PyMem_RawFree(argv_copy);
74
PyMem_RawFree(argv_copy2);