File: fixupdate.in

package info (click to toggle)
ifhp 3.5.20-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,424 kB
  • sloc: ansic: 15,055; sh: 12,037; perl: 1,461; makefile: 643; sed: 16
file content (69 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download | duplicates (12)
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
#!@PERL@
use strict;
for (@ARGV){
	my($hfile,$cfile,$s,$t,$h);
	#print "arg '$_'\n";
	$hfile = $_;
	($cfile = $hfile) =~ s/.*\///;
	$cfile =~ s/\.h$/.c/;
	if( not -f $cfile ){
		my @files = glob( "*/$cfile" );
		if( @files > 1 ){
			warn "too many matching sourc3 files - @files\n";
			exit 1;
		}
		if( @files == 0 ){
			warn "no matching source files\n";
			next;
		}
		$cfile = $files[0];
	}
	#print "cfile '$cfile', hfile '$hfile'\n";
	if( !open( CFILE, "<$cfile") ){
		warn "cannot open '$cfile'";
		next;
	}
	while (<CFILE>) {
		chomp;	# strip record separator
		if (/^[A-Za-z]/ .. /^{/) {
			chomp;
			if( /{/ ){
				$s .= ";\n";
				$t .= $s;
				$s = "";
			} elsif( $s ){
				$s .= "\n" . $_;
			} else {
				$s = $_;
			}
		}
		if (/VARARGS/ .. /^{/) {
			chomp;
			if( /{/ ){
				$s .= "\n;\n";
				$t .= $s;
				$s = "";
			} elsif( $s ){
				$s .= "\n" . $_;
			} else {
				$s = $_;
			}
		}
	}
	close CFILE ;
	$t .= "\n#endif\n";
	#print $t;
	open( HFILE, "<$hfile") or die "cannot open '$hfile'";
	while( <HFILE> ){
		$h .= $_;
		if( /PROTOTYPE/ ) {
			$h .= $t;
			last;
		}
	}
	# print $h;
	`cp $hfile $hfile.bak`;
	open( HFILE,">$hfile") or die "cannot open '$hfile'";
	print HFILE $h;
	close HFILE;
}