Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84457af

Browse files
committed
Taught svneol to look at .c and .h files too, and
it found a bunch more in need of svn:eol-style.
1 parent d87f81f commit 84457af

2 files changed

Lines changed: 95 additions & 92 deletions

File tree

PCbuild/make_buildinfo.c

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
1-
#include <windows.h>
2-
#include <sys/types.h>
3-
#include <sys/stat.h>
4-
#include <stdio.h>
5-
6-
/* This file creates the getbuildinfo.o object, by first
7-
invoking subwcrev.exe (if found), and then invoking cl.exe.
8-
As a side effect, it might generate PCBuild\getbuildinfo2.c
9-
also. If this isn't a subversion checkout, or subwcrev isn't
10-
found, it compiles ..\\Modules\\getbuildinfo.c instead.
11-
12-
Currently, subwcrev.exe is found from the registry entries
13-
of TortoiseSVN.
14-
15-
No attempt is made to place getbuildinfo.o into the proper
16-
binary directory. This isn't necessary, as this tool is
17-
invoked as a pre-link step for pythoncore, so that overwrites
18-
any previous getbuildinfo.o.
19-
20-
*/
21-
22-
int make_buildinfo2()
23-
{
24-
struct _stat st;
25-
HKEY hTortoise;
26-
char command[500];
27-
DWORD type, size;
28-
if (_stat(".svn", &st) < 0)
29-
return 0;
30-
if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS &&
31-
RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS)
32-
/* Tortoise not installed */
33-
return 0;
34-
command[0] = '"'; /* quote the path to the executable */
35-
size = sizeof(command) - 1;
36-
if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS ||
37-
type != REG_SZ)
38-
/* Registry corrupted */
39-
return 0;
40-
strcat(command, "bin\\subwcrev.exe");
41-
if (_stat(command+1, &st) < 0)
42-
/* subwcrev.exe not part of the release */
43-
return 0;
44-
strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c");
45-
puts(command); fflush(stdout);
46-
if (system(command) < 0)
47-
return 0;
48-
return 1;
49-
}
50-
51-
int main(int argc, char*argv[])
52-
{
53-
char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL ";
54-
int do_unlink, result;
55-
if (argc != 2) {
56-
fprintf(stderr, "make_buildinfo $(ConfigurationName)\n");
57-
return EXIT_FAILURE;
58-
}
59-
if (strcmp(argv[1], "Release") == 0) {
60-
strcat(command, "-MD ");
61-
}
62-
else if (strcmp(argv[1], "Debug") == 0) {
63-
strcat(command, "-D_DEBUG -MDd ");
64-
}
65-
else if (strcmp(argv[1], "ReleaseItanium") == 0) {
66-
strcat(command, "-MD /USECL:MS_ITANIUM ");
67-
}
68-
else if (strcmp(argv[1], "ReleaseAMD64") == 0) {
69-
strcat(command, "-MD ");
70-
strcat(command, "-MD /USECL:MS_OPTERON ");
71-
}
72-
else {
73-
fprintf(stderr, "unsupported configuration %s\n", argv[1]);
74-
return EXIT_FAILURE;
75-
}
76-
77-
if ((do_unlink = make_buildinfo2()))
78-
strcat(command, "getbuildinfo2.c -DSUBWCREV ");
79-
else
80-
strcat(command, "..\\Modules\\getbuildinfo.c");
81-
strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC");
82-
puts(command); fflush(stdout);
83-
result = system(command);
84-
if (do_unlink)
85-
unlink("getbuildinfo2.c");
86-
if (result < 0)
87-
return EXIT_FAILURE;
88-
return 0;
1+
#include <windows.h>
2+
#include <sys/types.h>
3+
#include <sys/stat.h>
4+
#include <stdio.h>
5+
6+
/* This file creates the getbuildinfo.o object, by first
7+
invoking subwcrev.exe (if found), and then invoking cl.exe.
8+
As a side effect, it might generate PCBuild\getbuildinfo2.c
9+
also. If this isn't a subversion checkout, or subwcrev isn't
10+
found, it compiles ..\\Modules\\getbuildinfo.c instead.
11+
12+
Currently, subwcrev.exe is found from the registry entries
13+
of TortoiseSVN.
14+
15+
No attempt is made to place getbuildinfo.o into the proper
16+
binary directory. This isn't necessary, as this tool is
17+
invoked as a pre-link step for pythoncore, so that overwrites
18+
any previous getbuildinfo.o.
19+
20+
*/
21+
22+
int make_buildinfo2()
23+
{
24+
struct _stat st;
25+
HKEY hTortoise;
26+
char command[500];
27+
DWORD type, size;
28+
if (_stat(".svn", &st) < 0)
29+
return 0;
30+
if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS &&
31+
RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS)
32+
/* Tortoise not installed */
33+
return 0;
34+
command[0] = '"'; /* quote the path to the executable */
35+
size = sizeof(command) - 1;
36+
if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS ||
37+
type != REG_SZ)
38+
/* Registry corrupted */
39+
return 0;
40+
strcat(command, "bin\\subwcrev.exe");
41+
if (_stat(command+1, &st) < 0)
42+
/* subwcrev.exe not part of the release */
43+
return 0;
44+
strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c");
45+
puts(command); fflush(stdout);
46+
if (system(command) < 0)
47+
return 0;
48+
return 1;
49+
}
50+
51+
int main(int argc, char*argv[])
52+
{
53+
char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL ";
54+
int do_unlink, result;
55+
if (argc != 2) {
56+
fprintf(stderr, "make_buildinfo $(ConfigurationName)\n");
57+
return EXIT_FAILURE;
58+
}
59+
if (strcmp(argv[1], "Release") == 0) {
60+
strcat(command, "-MD ");
61+
}
62+
else if (strcmp(argv[1], "Debug") == 0) {
63+
strcat(command, "-D_DEBUG -MDd ");
64+
}
65+
else if (strcmp(argv[1], "ReleaseItanium") == 0) {
66+
strcat(command, "-MD /USECL:MS_ITANIUM ");
67+
}
68+
else if (strcmp(argv[1], "ReleaseAMD64") == 0) {
69+
strcat(command, "-MD ");
70+
strcat(command, "-MD /USECL:MS_OPTERON ");
71+
}
72+
else {
73+
fprintf(stderr, "unsupported configuration %s\n", argv[1]);
74+
return EXIT_FAILURE;
75+
}
76+
77+
if ((do_unlink = make_buildinfo2()))
78+
strcat(command, "getbuildinfo2.c -DSUBWCREV ");
79+
else
80+
strcat(command, "..\\Modules\\getbuildinfo.c");
81+
strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC");
82+
puts(command); fflush(stdout);
83+
result = system(command);
84+
if (do_unlink)
85+
unlink("getbuildinfo2.c");
86+
if (result < 0)
87+
return EXIT_FAILURE;
88+
return 0;
8989
}

Tools/scripts/svneol.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"""
44
SVN helper script.
55
6-
Try to set the svn:eol-style property to "native" on every .py and .txt file
7-
in the directory tree rooted at the current directory.
6+
Try to set the svn:eol-style property to "native" on every .py, .txt, .c and
7+
.h file in the directory tree rooted at the current directory.
88
99
Files with the svn:eol-style property already set (to anything) are skipped.
1010
@@ -30,16 +30,19 @@
3030
svn: File 'Lib\test\test_pep263.py' has binary mime type property
3131
3232
TODO: This is slow, and especially on Windows, because it invokes a new svn
33-
command-line operation for every .py and .txt file.
33+
command-line operation for every file with the right extension.
3434
"""
3535

36+
import re
3637
import os
3738

39+
possible_text_file = re.compile(r"\.([hc]|py|txt)$").search
40+
3841
for root, dirs, files in os.walk('.'):
3942
if '.svn' in dirs:
4043
dirs.remove('.svn')
4144
for fn in files:
42-
if fn.endswith('.py') or fn.endswith('.txt'):
45+
if possible_text_file(fn):
4346
path = os.path.join(root, fn)
4447
p = os.popen('svn proplist "%s"' % path)
4548
guts = p.read()

0 commit comments

Comments
 (0)