forked from FallenMoonNetwork/CanaryMod
-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_names.pl
executable file
·54 lines (46 loc) · 1.16 KB
/
update_names.pl
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
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
if ($#ARGV < 0) {
printf STDERR "Usage: %s <server.srg>\n", $0;
exit 1;
}
my %ob_deob = ();
open(SRG, $ARGV[0]);
while (<SRG>) {
if (m|^FD: \S+/(\S+) \S+/(\S+)\r?$| || m|^MD: \S+/(\S+) \S+ \S+/(\S+) \S+\r?$|) {
$ob_deob{$2} = $1;
}
}
close SRG;
#print Dumper(\%ob_deob);
foreach my $file (<src/*.java>) {
next if $file =~ /O[A-Z].*/;
my $oldfile = "$file.old";
if (-e $oldfile || !rename $file, $oldfile) {
printf STDERR "Error while renaming $file: " . ($! || "file exists") . "\n";
exit 1;
}
open(FILE, $oldfile);
open(NEWFILE, ">", $file);
my $nextline = undef;
while (<FILE>) {
if ($nextline) {
print NEWFILE $nextline;
$nextline = undef;
next;
}
if (m|^(\s+)// SRG (.*)$|) {
print NEWFILE;
my $space = $1;
my $code = $2;
$code =~ s!f(?:unc|ield)_\d+_[a-zA-Z]+_?!$ob_deob{$&}!g;
$nextline = $space . $code . "\n";
next;
}
print NEWFILE;
}
close NEWFILE;
close FILE;
}
# vim: set et sts=4 sw=4: