LCOV - code coverage report
Current view: top level - Modules - getbuildinfo.c (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 15 20 75.0 %
Date: 2017-04-19 Functions: 3 4 75.0 %

          Line data    Source code
       1             : #include "Python.h"
       2             : 
       3             : #ifndef DONT_HAVE_STDIO_H
       4             : #include <stdio.h>
       5             : #endif
       6             : 
       7             : #ifndef DATE
       8             : #ifdef __DATE__
       9             : #define DATE __DATE__
      10             : #else
      11             : #define DATE "xx/xx/xx"
      12             : #endif
      13             : #endif
      14             : 
      15             : #ifndef TIME
      16             : #ifdef __TIME__
      17             : #define TIME __TIME__
      18             : #else
      19             : #define TIME "xx:xx:xx"
      20             : #endif
      21             : #endif
      22             : 
      23             : /* on unix, SVNVERSION is passed on the command line.
      24             :  * on Windows, the string is interpolated using
      25             :  * subwcrev.exe
      26             :  */
      27             : #ifndef SVNVERSION
      28             : #define SVNVERSION "$WCRANGE$$WCMODS?M:$"
      29             : #endif
      30             : 
      31             : /* XXX Only unix build process has been tested */
      32             : #ifndef HGVERSION
      33             : #define HGVERSION ""
      34             : #endif
      35             : #ifndef HGTAG
      36             : #define HGTAG ""
      37             : #endif
      38             : #ifndef HGBRANCH
      39             : #define HGBRANCH ""
      40             : #endif
      41             : 
      42             : const char *
      43           3 : Py_GetBuildInfo(void)
      44             : {
      45             :     static char buildinfo[50 + sizeof(HGVERSION) +
      46             :                           ((sizeof(HGTAG) > sizeof(HGBRANCH)) ?
      47             :                            sizeof(HGTAG) : sizeof(HGBRANCH))];
      48           3 :     const char *revision = _Py_hgversion();
      49           3 :     const char *sep = *revision ? ":" : "";
      50           3 :     const char *hgid = _Py_hgidentifier();
      51           3 :     if (!(*hgid))
      52           3 :         hgid = "default";
      53           3 :     PyOS_snprintf(buildinfo, sizeof(buildinfo),
      54             :                   "%s%s%s, %.20s, %.9s", hgid, sep, revision,
      55             :                   DATE, TIME);
      56           3 :     return buildinfo;
      57             : }
      58             : 
      59             : const char *
      60           0 : _Py_svnversion(void)
      61             : {
      62             :     /* the following string can be modified by subwcrev.exe */
      63             :     static const char svnversion[] = SVNVERSION;
      64           0 :     if (svnversion[0] != '$')
      65           0 :         return svnversion; /* it was interpolated, or passed on command line */
      66           0 :     return "Unversioned directory";
      67             : }
      68             : 
      69             : const char *
      70           6 : _Py_hgversion(void)
      71             : {
      72           6 :     return HGVERSION;
      73             : }
      74             : 
      75             : const char *
      76           6 : _Py_hgidentifier(void)
      77             : {
      78             :     const char *hgtag, *hgid;
      79           6 :     hgtag = HGTAG;
      80           6 :     if ((*hgtag) && strcmp(hgtag, "tip") != 0)
      81           0 :         hgid = hgtag;
      82             :     else
      83           6 :         hgid = HGBRANCH;
      84           6 :     return hgid;
      85             : }

Generated by: LCOV version 1.10