Debian Codegraph @

pTk/mkXinfo

raw
1 #!/usr/local/bin/perl -w
2
3 $file = shift;
4
5 @cargs = @ARGV;
6
7 @ARGV = grep(!/\.ft\./,<*.c>,<xpm/*.c>);
8
9 print STDERR "Scanning .c files for X functions\n";
10 while (<>)
11 {
12 if (/\b(X[A-Za-z0-9]*)\s*\(/)
13 {
14 $XFunc{$1} = $ARGV ;
15 }
16 }
17
18 open(STDOUT,">$file") || die "Cannot open $file:$!";
19 $gard = "\U$file";
20 $gard =~ s/\..*$//;
21 $gard =~ s#/#_#g;
22
23 print "#ifndef _$gard\n";
24 print "#define _$gard\n";
25 print "#ifndef _${gard}_H_\n";
26
27 print STDERR "Extracting protos with gcc\n";
28 die if (system("gcc","-aux-info","/tmp/X-info","-S","-o","/dev/null",@cargs));
29
30 open(INFO,"</tmp/X-info") || die "Cannot open /tmp/X-info:$!";
31 while (<INFO>)
32 {
33 if (m#/X11/X[^/]*\.h:\d+:NC\s*\*/\s*(.*)$#o)
34 {
35 $_ = $1;
36 if (/\b(X[A-Za-z0-9]*)\s*\(/)
37 {
38 if (exists $XFunc{$1})
39 {
40 chomp;
41 s/^(.*?)\(/$1 _ANSI_ARGS_((/;
42 s/\);\s*$/));\n/;
43 print;
44 }
45 }
46 else
47 {
48 warn "No function:$_";
49 }
50 }
51 }
52 close(INFO);
53
54 print "#endif /* _${gard}_H_ */\n";
55 print "#endif /* _$gard */\n";
56