LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/python3/Modules - python.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 24 0.0 %
Date: 2012-12-17 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Minimal main program -- everything is loaded from the library */
       2             : 
       3             : #include "Python.h"
       4             : #include <locale.h>
       5             : 
       6             : #ifdef __FreeBSD__
       7             : #include <floatingpoint.h>
       8             : #endif
       9             : 
      10             : #ifdef MS_WINDOWS
      11             : int
      12             : wmain(int argc, wchar_t **argv)
      13             : {
      14             :     return Py_Main(argc, argv);
      15             : }
      16             : #else
      17             : 
      18             : #ifdef __APPLE__
      19             : extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size);
      20             : #endif
      21             : 
      22             : int
      23           0 : main(int argc, char **argv)
      24             : {
      25           0 :     wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
      26             :     /* We need a second copies, as Python might modify the first one. */
      27           0 :     wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1));
      28             :     int i, res;
      29             :     char *oldloc;
      30             :     /* 754 requires that FP exceptions run in "no stop" mode by default,
      31             :      * and until C vendors implement C99's ways to control FP exceptions,
      32             :      * Python requires non-stop mode.  Alas, some platforms enable FP
      33             :      * exceptions by default.  Here we disable them.
      34             :      */
      35             : #ifdef __FreeBSD__
      36             :     fp_except_t m;
      37             : 
      38             :     m = fpgetmask();
      39             :     fpsetmask(m & ~FP_X_OFL);
      40             : #endif
      41           0 :     if (!argv_copy || !argv_copy2) {
      42           0 :         fprintf(stderr, "out of memory\n");
      43           0 :         return 1;
      44             :     }
      45           0 :     oldloc = strdup(setlocale(LC_ALL, NULL));
      46           0 :     setlocale(LC_ALL, "");
      47           0 :     for (i = 0; i < argc; i++) {
      48             : #ifdef __APPLE__
      49             :         argv_copy[i] = _Py_DecodeUTF8_surrogateescape(argv[i], strlen(argv[i]));
      50             : #else
      51           0 :         argv_copy[i] = _Py_char2wchar(argv[i], NULL);
      52             : #endif
      53           0 :         if (!argv_copy[i]) {
      54           0 :             free(oldloc);
      55           0 :             fprintf(stderr, "Fatal Python error: "
      56             :                             "unable to decode the command line argument #%i\n",
      57             :                             i + 1);
      58           0 :             return 1;
      59             :         }
      60           0 :         argv_copy2[i] = argv_copy[i];
      61             :     }
      62           0 :     argv_copy2[argc] = argv_copy[argc] = NULL;
      63             : 
      64           0 :     setlocale(LC_ALL, oldloc);
      65           0 :     free(oldloc);
      66           0 :     res = Py_Main(argc, argv_copy);
      67           0 :     for (i = 0; i < argc; i++) {
      68           0 :         PyMem_Free(argv_copy2[i]);
      69             :     }
      70           0 :     PyMem_Free(argv_copy);
      71           0 :     PyMem_Free(argv_copy2);
      72           0 :     return res;
      73             : }
      74             : #endif

Generated by: LCOV version 1.10