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);
18
main(int argc, char **argv)
20
wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*argc);
21
/* We need a second copies, as Python might modify the first one. */
22
wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*argc);
25
/* 754 requires that FP exceptions run in "no stop" mode by default,
26
* and until C vendors implement C99's ways to control FP exceptions,
27
* Python requires non-stop mode. Alas, some platforms enable FP
28
* exceptions by default. Here we disable them.
34
fpsetmask(m & ~FP_X_OFL);
36
if (!argv_copy || !argv_copy2) {
37
fprintf(stderr, "out of memory\n");
40
oldloc = strdup(setlocale(LC_ALL, NULL));
41
setlocale(LC_ALL, "");
42
for (i = 0; i < argc; i++) {
43
#ifdef HAVE_BROKEN_MBSTOWCS
44
/* Some platforms have a broken implementation of
45
* mbstowcs which does not count the characters that
46
* would result from conversion. Use an upper bound.
48
size_t argsize = strlen(argv[i]);
50
size_t argsize = mbstowcs(NULL, argv[i], 0);
53
if (argsize == (size_t)-1) {
54
fprintf(stderr, "Could not convert argument %d to string\n", i);
57
argv_copy[i] = (wchar_t *)PyMem_Malloc((argsize+1)*sizeof(wchar_t));
58
argv_copy2[i] = argv_copy[i];
60
fprintf(stderr, "out of memory\n");
63
count = mbstowcs(argv_copy[i], argv[i], argsize+1);
64
if (count == (size_t)-1) {
65
fprintf(stderr, "Could not convert argument %d to string\n", i);
69
setlocale(LC_ALL, oldloc);
71
res = Py_Main(argc, argv_copy);
72
for (i = 0; i < argc; i++) {
73
PyMem_Free(argv_copy2[i]);
75
PyMem_Free(argv_copy);
76
PyMem_Free(argv_copy2);