File: removeSlash.pl

package info (click to toggle)
scorched3d 41.3dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 159,620 kB
  • ctags: 26,898
  • sloc: cpp: 110,179; xml: 36,743; ansic: 31,536; makefile: 4,321; sh: 3,708; perl: 1,522; java: 209; python: 188; sql: 146
file content (61 lines) | stat: -rw-r--r-- 952 bytes parent folder | download
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
use strict;

my @dirs =
(
	"3dsparse",
	"actions",
	"common",
	"coms",
	"dialogs",
	"engine",
	"GLEXT",
	"GLW",
	"ode",
	"landscape",
	"client",
	"server",
	"tankgraph",
	"sprites",
	"tank",
	"weapons"
);

my $dir;
foreach $dir (@dirs)
{
	opendir(IN, "..\\src\\$dir") || die "ERROR: DIR \"$dir\"";
	my @files = grep { /\.h/ || /\.cpp/ } readdir(IN);
	closedir(IN);

	my $file;
	foreach $file (@files)
	{
		open (INFILE, "..\\src\\$dir\\$file") || die "ERROR: File \"..\\$dir/$file\"";
		my @filelines = <INFILE>;
		close (INFILE);

		my @newfilelines = ();
		my $save = undef;
		for my $line (@filelines)
		{
			if ($line =~ /#include/)
			{
				if ($line =~ /\\/)
				{
					$save = 1;
					$line =~ s/\\/\//g;
				}
			}

			push @newfilelines, $line;
		}

		if (defined $save)
		{
			print $file."\n";
			open (OUTFILE, ">..\\src\\$dir\\$file") || die "ERROR: File \"..\\$dir/$file\"";
			print OUTFILE @newfilelines;
			close (OUTFILE);			
		}
	}
}