ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/genconst
(Generate patch)

Comparing deliantra/server/server/genconst (file contents):
Revision 1.1 by root, Sun Apr 4 04:58:46 2010 UTC vs.
Revision 1.4 by root, Thu Nov 17 23:28:05 2016 UTC

1#! perl 1#! perl
2 2
3my %const_iv; 3my %const_iv;
4 4
5while (<>) { 5sub gl() {
6 $_ = <>;
7
8 defined $_ or last file;
9
6 1 while s/\/\*.*?\*\///; 10 1 while s/\/\*.*?\*\///;
11 s/\/\*.*$//; # we don't handle multiline-/* comments, so hack around
7 s/\/\/.*$//; 12 s/\/\/.*$//;
13 s/^\s+//;
8 s/\s+$//; 14 s/\s+$//;
9 15
16 $_
17}
18
19file:
20while () {
21 gl;
10 if (/^#define\s+([A-Z_0-9]+)\s+(0x[0-9a-fA-F]+|[0-9]+)$/) { 22 if (/^#define\s+([A-Z_0-9]+)\s+(0x[0-9a-fA-F]+|[0-9\.]+)$/) {
11 undef $const_iv{$1}; 23 undef $const_iv{$1};
24 } elsif (/^enum\b/) {
25 while () {
26 gl;
27 if (/^([a-zA-Z_0-9]+)\s*(?:,|=|$)/) {
28 undef $const_iv{$1};
29 } elsif (/^\}/) {
30 last;
31 }
32 }
12 } 33 }
13} 34}
14 35
15open my $fh, ">", "const_iv.h~"
16 or die "const_iv.h~: $!";
17for (sort keys %const_iv) { 36for (sort keys %const_iv) {
18 print $fh "const_iv($_)\n"; 37 print "const_iv($_)\n";
19} 38}
20close $fh;
21rename "const_iv.h~", "const_iv.h";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines