annotate Modules/getbuildinfo.c @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents fe5b90b1e8ea
children 00217100b9e7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21178
bc51de643b5e More sprintf -> PyOS_snprintf.
Tim Peters <tim.peters@gmail.com>
parents: 18835
diff changeset
1 #include "Python.h"
5569
818cfff3aa5d Include config.h so it can define const away for K&R.
Guido van Rossum <guido@python.org>
parents: 5016
diff changeset
2
11243
6aac31cd2102 Patch by Mark Hammond to avoid certain header files on Windows/CE.
Guido van Rossum <guido@python.org>
parents: 9970
diff changeset
3 #ifndef DONT_HAVE_STDIO_H
5016
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 #include <stdio.h>
11243
6aac31cd2102 Patch by Mark Hammond to avoid certain header files on Windows/CE.
Guido van Rossum <guido@python.org>
parents: 9970
diff changeset
5 #endif
5016
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 #ifndef DATE
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 #ifdef __DATE__
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 #define DATE __DATE__
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 #else
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 #define DATE "xx/xx/xx"
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 #endif
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 #endif
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 #ifndef TIME
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 #ifdef __TIME__
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 #define TIME __TIME__
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 #else
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 #define TIME "xx:xx:xx"
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 #endif
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 #endif
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
23 /* on unix, SVNVERSION is passed on the command line.
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
24 * on Windows, the string is interpolated using
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
25 * subwcrev.exe
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
26 */
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
27 #ifndef SVNVERSION
36321
ae07b0e7d70a Generate getbuildinfo.o each time the linker is invoked;
Martin v. Löwis <martin@v.loewis.de>
parents: 36213
diff changeset
28 #define SVNVERSION "$WCRANGE$$WCMODS?M:$"
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
29 #endif
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41716
diff changeset
30
68281
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
31 /* XXX Only unix build process has been tested */
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
32 #ifndef HGVERSION
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
33 #define HGVERSION ""
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
34 #endif
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
35 #ifndef HGTAG
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
36 #define HGTAG ""
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
37 #endif
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
38 #ifndef HGBRANCH
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
39 #define HGBRANCH ""
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
40 #endif
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
41
5016
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 const char *
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 11243
diff changeset
43 Py_GetBuildInfo(void)
5016
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 {
69028
fe5b90b1e8ea let's keep parenthesis around sizeof
Benjamin Peterson <benjamin@python.org>
parents: 68345
diff changeset
45 static char buildinfo[50 + sizeof(HGVERSION) +
fe5b90b1e8ea let's keep parenthesis around sizeof
Benjamin Peterson <benjamin@python.org>
parents: 68345
diff changeset
46 ((sizeof(HGTAG) > sizeof(HGBRANCH)) ?
fe5b90b1e8ea let's keep parenthesis around sizeof
Benjamin Peterson <benjamin@python.org>
parents: 68345
diff changeset
47 sizeof(HGTAG) : sizeof(HGBRANCH))];
68281
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
48 const char *revision = _Py_hgversion();
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
49 const char *sep = *revision ? ":" : "";
68281
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
50 const char *hgid = _Py_hgidentifier();
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
51 if (!(*hgid))
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
52 hgid = "default";
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
53 PyOS_snprintf(buildinfo, sizeof(buildinfo),
68281
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
54 "%s%s%s, %.20s, %.9s", hgid, sep, revision,
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
55 DATE, TIME);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
56 return buildinfo;
5016
f1af097a5e5d work build# into version string
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 }
36094
e90e7d9e9891 Revert most of r41765. Don't use $Revision$ in Py_GetBuildNumber(). Keep the
Barry Warsaw <barry@python.org>
parents: 36088
diff changeset
58
e90e7d9e9891 Revert most of r41765. Don't use $Revision$ in Py_GetBuildNumber(). Keep the
Barry Warsaw <barry@python.org>
parents: 36088
diff changeset
59 const char *
36207
825a041813fb Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents: 36204
diff changeset
60 _Py_svnversion(void)
36094
e90e7d9e9891 Revert most of r41765. Don't use $Revision$ in Py_GetBuildNumber(). Keep the
Barry Warsaw <barry@python.org>
parents: 36088
diff changeset
61 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
62 /* the following string can be modified by subwcrev.exe */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
63 static const char svnversion[] = SVNVERSION;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
64 if (svnversion[0] != '$')
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
65 return svnversion; /* it was interpolated, or passed on command line */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 54293
diff changeset
66 return "Unversioned directory";
36094
e90e7d9e9891 Revert most of r41765. Don't use $Revision$ in Py_GetBuildNumber(). Keep the
Barry Warsaw <barry@python.org>
parents: 36088
diff changeset
67 }
68281
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
68
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
69 const char *
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
70 _Py_hgversion(void)
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
71 {
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
72 return HGVERSION;
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
73 }
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
74
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
75 const char *
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
76 _Py_hgidentifier(void)
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
77 {
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
78 const char *hgtag, *hgid;
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
79 hgtag = HGTAG;
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
80 if ((*hgtag) && strcmp(hgtag, "tip") != 0)
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
81 hgid = hgtag;
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
82 else
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
83 hgid = HGBRANCH;
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
84 return hgid;
ce93b75add15 Port build identification from default branch.
Georg Brandl <georg@python.org>
parents: 61463
diff changeset
85 }