summaryrefslogtreecommitdiffstats
path: root/Modules/getbuildinfo.c
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2005-12-18 22:46:35 (GMT)
committerBarry Warsaw <barry@python.org>2005-12-18 22:46:35 (GMT)
commita3bdc2c2a5dbb6fd7f7f655f6970f7559dca0497 (patch)
tree7393c26f9dbc088851256dad197c72c5219abb69 /Modules/getbuildinfo.c
parentd24499dc53c82bcae6a97cc580cf4f3dde143bb4 (diff)
downloadcpython-a3bdc2c2a5dbb6fd7f7f655f6970f7559dca0497.zip
cpython-a3bdc2c2a5dbb6fd7f7f655f6970f7559dca0497.tar.gz
cpython-a3bdc2c2a5dbb6fd7f7f655f6970f7559dca0497.tar.bz2
Handle a couple of use cases discussed in python-dev w.r.t. calculating the
Subversion revision number. First, in an svn export, there will be no .svn directory, so use an in-file $Revision$ keyword string with the keyword chrome stripped off. Also, use $(srcdir) in the Makefile.pre.in to handle the case where Python is build outside the source tree.
Diffstat (limited to 'Modules/getbuildinfo.c')
-rw-r--r--Modules/getbuildinfo.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c
index 8b1ca22..446340b 100644
--- a/Modules/getbuildinfo.c
+++ b/Modules/getbuildinfo.c
@@ -21,20 +21,38 @@
#endif
#ifndef BUILD
-#define BUILD "0"
+#define BUILD "$Revision$"
#endif
const char *
-Py_GetBuildInfo(void)
+Py_GetBuildNumber(void)
{
- static char buildinfo[50];
- PyOS_snprintf(buildinfo, sizeof(buildinfo),
- "%s, %.20s, %.9s", BUILD, DATE, TIME);
- return buildinfo;
+ static char buildno[20];
+ static int buildno_okay;
+
+ if (!buildno_okay) {
+ char *build = BUILD;
+ int len = strlen(build);
+
+ if (len > 13 &&
+ !strncmp(build, "$Revision: ", 11) &&
+ !strcmp(build + len - 2, " $"))
+ {
+ memcpy(buildno, build + 11, len - 13);
+ }
+ else {
+ memcpy(buildno, build, 19);
+ }
+ buildno_okay = 1;
+ }
+ return buildno;
}
const char *
-Py_GetBuildNumber(void)
+Py_GetBuildInfo(void)
{
- return BUILD;
+ static char buildinfo[50];
+ PyOS_snprintf(buildinfo, sizeof(buildinfo),
+ "#%s, %.20s, %.9s", Py_GetBuildNumber(), DATE, TIME);
+ return buildinfo;
}