cpython: 4459d82ff127 (original) (raw)
--- a/PCbuild/make_buildinfo.c +++ b/PCbuild/make_buildinfo.c @@ -2,6 +2,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> +#include <io.h> #define CMD_SIZE 500 @@ -61,6 +62,51 @@ int make_buildinfo2(const char *tmppath) return 1; } +const char DELIMS[] = { " \n" }; + +int get_mercurial_info(char * hgbranch, char * hgtag, char * hgrev, int size) +{
- strcpy_s(filename, CMD_SIZE, "tmpXXXXXX");
- if (_mktemp_s(filename, CMD_SIZE) == 0) {
int rc;[](#l1.25)
strcpy_s(cmdline, CMD_SIZE, "hg id -bit > ");[](#l1.27)
strcat_s(cmdline, CMD_SIZE, filename);[](#l1.28)
rc = system(cmdline);[](#l1.29)
if (rc == 0) {[](#l1.30)
FILE * fp;[](#l1.31)
[](#l1.32)
if (fopen_s(&fp, filename, "r") == 0) {[](#l1.33)
char * cp = fgets(cmdline, CMD_SIZE, fp);[](#l1.34)
if (cp) {[](#l1.36)
char * context = NULL;[](#l1.37)
char * tp = strtok_s(cp, DELIMS, &context);[](#l1.38)
if (tp) {[](#l1.39)
strcpy_s(hgrev, size, tp);[](#l1.40)
tp = strtok_s(NULL, DELIMS, &context);[](#l1.41)
if (tp) {[](#l1.42)
strcpy_s(hgbranch, size, tp);[](#l1.43)
tp = strtok_s(NULL, DELIMS, &context);[](#l1.44)
if (tp) {[](#l1.45)
strcpy_s(hgtag, size, tp);[](#l1.46)
result = 1;[](#l1.47)
}[](#l1.48)
}[](#l1.49)
}[](#l1.50)
}[](#l1.51)
fclose(fp);[](#l1.52)
}[](#l1.53)
}[](#l1.54)
_unlink(filename);[](#l1.55)
- }
- return result;
+} + int main(int argc, charargv[]) { char command[CMD_SIZE] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; @@ -109,8 +155,27 @@ int main(int argc, charargv[]) strcat_s(command, CMD_SIZE, """); strcat_s(command, CMD_SIZE, tmppath); strcat_s(command, CMD_SIZE, "getbuildinfo2.c" -DSUBWCREV ");
- }
- else {
char hgtag[CMD_SIZE];[](#l1.70)
char hgbranch[CMD_SIZE];[](#l1.71)
char hgrev[CMD_SIZE];[](#l1.72)
if (get_mercurial_info(hgbranch, hgtag, hgrev, CMD_SIZE)) {[](#l1.74)
strcat_s(command, CMD_SIZE, "-DHGBRANCH=\\\"");[](#l1.75)
strcat_s(command, CMD_SIZE, hgbranch);[](#l1.76)
strcat_s(command, CMD_SIZE, "\\\"");[](#l1.77)
strcat_s(command, CMD_SIZE, " -DHGTAG=\\\"");[](#l1.79)
strcat_s(command, CMD_SIZE, hgtag);[](#l1.80)
strcat_s(command, CMD_SIZE, "\\\"");[](#l1.81)
strcat_s(command, CMD_SIZE, " -DHGVERSION=\\\"");[](#l1.83)
strcat_s(command, CMD_SIZE, hgrev);[](#l1.84)
strcat_s(command, CMD_SIZE, "\\\" ");[](#l1.85)
}[](#l1.86) strcat_s(command, CMD_SIZE, "..\\Modules\\getbuildinfo.c");[](#l1.87)
- } strcat_s(command, CMD_SIZE, " -Fo""); strcat_s(command, CMD_SIZE, tmppath); strcat_s(command, CMD_SIZE, "getbuildinfo.o" -I..\Include -I..\PC");