1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
use IO::File;
use File::Find;
if ($ARGV[0] == '-6') {
find(\&tovc6, '.');
}
elsif ($ARGV[0] == '-5') {
find(\&tovc5, '.');
}
elsif ($ARGV[0] == '-w3') {
find(\&tow3, '.');
}
elsif ($ARGV[0] == '-w4') {
find(\&tow4, '.');
}
else {
print "Specify -5 or -6 for Visual Studio 5 or 6 (98) .dsp format\n";
print "Specify -w3 or -w4 for .dsp build with warning level 3 or 4 (strict)\n\n";
die "Missing argument";
}
sub tovc5 {
if (m|.dsp$|) {
$oname = $_;
$tname = '.#' . $_;
$verchg = 0;
$srcfl = new IO::File $oname, "r" || die;
$dstfl = new IO::File $tname, "w" || die;
while ($src = <$srcfl>) {
if ($src =~ s|Format Version 6\.00|Format Version 5\.00|) {
$verchg = -1;
}
if ($src =~ s|^(# ADD CPP .*)/ZI (.*)|$1/Zi $2|) {
$verchg = -1;
}
if ($src =~ s|^(# ADD BASE CPP .*)/ZI (.*)|$1/Zi $2|) {
$verchg = -1;
}
if ($src !~ m|^# PROP AllowPerConfigDependencies|) {
print $dstfl $src; }
else {
$verchg = -1;
}
}
undef $srcfl;
undef $dstfl;
if ($verchg) {
unlink $oname || die;
rename $tname, $oname || die;
print "Converted VC6 project " . $oname . " to VC5 in " . $File::Find::dir . "\n";
}
else {
unlink $tname;
}
}
}
sub tovc6 {
if (m|.dsp$|) {
$oname = $_;
$tname = '.#' . $_;
$verchg = 0;
$srcfl = new IO::File $_, "r" || die;
$dstfl = new IO::File $tname, "w" || die;
while ($src = <$srcfl>) {
if ($src =~ s|Format Version 5\.00|Format Version 6\.00|) {
$verchg = -1;
}
if ($src =~ s|^(# ADD CPP .*)/Zi (.*)|$1/ZI $2|) {
$verchg = -1;
}
if ($src =~ s|^(# ADD BASE CPP .*)/Zi (.*)|$1/ZI $2|) {
$verchg = -1;
}
if ($src =~ s|^(!MESSAGE .*)\\\n|$1|) {
$cont = <$srcfl>;
$src = $src . $cont;
$verchg = -1;
}
print $dstfl $src;
if ($verchg && $src =~ m|^# Begin Project|) {
print $dstfl "# PROP AllowPerConfigDependencies 0\n";
}
}
undef $srcfl;
undef $dstfl;
if ($verchg) {
unlink $oname || die;
rename $tname, $oname || die;
print "Converted VC5 project " . $oname . " to VC6 in " . $File::Find::dir . "\n";
}
else {
unlink $tname;
}
}
}
sub tow3 {
if (m|.dsp$|) {
$oname = $_;
$tname = '.#' . $_;
$verchg = 0;
$srcfl = new IO::File $oname, "r" || die;
$dstfl = new IO::File $tname, "w" || die;
while ($src = <$srcfl>) {
if ($src =~ s|^(# ADD CPP .*)/W4 (.*)|$1/W3 $2|) {
$verchg = -1;
}
if ($src =~ s|^(# ADD BASE CPP .*)/W4 (.*)|$1/W3 $2|) {
$verchg = -1;
}
print $dstfl $src;
}
undef $srcfl;
undef $dstfl;
if ($verchg) {
unlink $oname || die;
rename $tname, $oname || die;
print "Converted project " . $oname . " to warn:3 in " . $File::Find::dir . "\n";
}
else {
unlink $tname;
}
}
}
sub tow4 {
if (m|.dsp$|) {
$oname = $_;
$tname = '.#' . $_;
$verchg = 0;
$srcfl = new IO::File $oname, "r" || die;
$dstfl = new IO::File $tname, "w" || die;
while ($src = <$srcfl>) {
if ($src =~ s|^(# ADD CPP .*)/W3 (.*)|$1/W4 $2|) {
$verchg = -1;
}
if ($src =~ s|^(# ADD BASE CPP .*)/W3 (.*)|$1/W4 $2|) {
$verchg = -1;
}
print $dstfl $src;
}
undef $srcfl;
undef $dstfl;
if ($verchg) {
unlink $oname || die;
rename $tname, $oname || die;
print "Converted project " . $oname . " to warn:4 " . $File::Find::dir . "\n";
}
else {
unlink $tname;
}
}
}
|