File: mkproto

package info (click to toggle)
eperl 2.2.14-21
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,304 kB
  • ctags: 738
  • sloc: ansic: 4,694; perl: 584; sh: 556; makefile: 353
file content (33 lines) | stat: -rwxr-xr-x 622 bytes parent folder | download | duplicates (10)
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
:
eval 'exec perl -S $0 ${1+"$@"}'
    if $running_under_some_shell;

$header = $ARGV[0];
shift @ARGV;
$sources = join(" ", @ARGV);

open(IN, "<$header");
open(OUT, ">$header.n");
while (<IN>) {
	if (m|^/\*_BEGIN_PROTO_\*/|) {
		while (<IN>) {
	        last if (m|^/\*_END_PROTO_\*/|);
		}
		print OUT "/*_BEGIN_PROTO_*/\n";
        open(CP, "cproto -DMKPROTO -e -f3 -v $sources 2>/dev/null|");
		while (<CP>) {
			if (m|^/\* .+\.c \*/|) {
				print OUT "\n";
			}
			print OUT $_;
		}
        close(CP);
		print OUT "/*_END_PROTO_*/\n";
		next;
	}
	print OUT $_;
}

close(OUT);
close(IN);
system("mv $header.n $header");