File: complng.pl

package info (click to toggle)
dosemu-freedos 1%3A0.0.b9r5a%2Betch.1-0etch1
  • links: PTS
  • area: contrib
  • in suites: etch
  • size: 19,744 kB
  • ctags: 23,279
  • sloc: ansic: 143,864; asm: 20,397; makefile: 3,868; perl: 1,106; yacc: 690; sh: 553; pascal: 297; xml: 150; cpp: 67
file content (51 lines) | stat: -rw-r--r-- 997 bytes parent folder | download | duplicates (2)
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
#!perl

# Compare a language file of two different ages

# Useage: $0 new old

die "Useage: $0 new old\n"
	unless $ARGV[0] && $ARGV[1];

die "Cannot open $ARGV[1]: $!\n"
	unless open(IN, $ARGV[1]);
while(<IN>) {
	next unless /^:/;
	$name = $';
	$name = $` if $name =~ /\#/;
	$name =~ s/\s+//g;
	$body = '';
	while(<IN>) {
		$body .= $_;
		last if /^[\.\,]\s*$/;
	}
	$string{$name} = $body;
}
close IN;

unlink("$ARGV[0].old");
die "Cannot backup $ARGV[0]: $!\n"
	unless rename($ARGV[0], "$ARGV[0].old");
die "Cannot open backup $ARGV[0].old: $!\n"
	unless open(IN, "$ARGV[0].old");
die "Cannot create $ARGV[0]: $!\n"
	unless open(OUT, ">$ARGV[0]");
while(<IN>) {
	if(/^:/) {
		$name = $';
		$name = $` if $name =~ /\#/;
		$name =~ s/\s+//g;
		$body = '';
		while(<IN>) {
			$body .= $_;
			last if /^[\.\,]\s*$/;
		}
		$name .= '#1' unless $string{$name} eq $body;
		print OUT ":$name\n", $body;
	} else {
		print OUT;
	}
}
close IN;
close OUT;