File: mkXinfo

package info (click to toggle)
libtk-tablematrix-perl 1.23-6
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,788 kB
  • sloc: ansic: 15,026; perl: 3,389; makefile: 120; sh: 16
file content (56 lines) | stat: -rwxr-xr-x 1,066 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
#!/usr/local/bin/perl -w

$file = shift;

@cargs = @ARGV;

@ARGV = grep(!/\.ft\./,<*.c>,<xpm/*.c>); 

print STDERR "Scanning .c files for X functions\n";
while (<>)
 {
  if (/\b(X[A-Za-z0-9]*)\s*\(/)
   {
    $XFunc{$1} = $ARGV ;
   }
 }

open(STDOUT,">$file") || die "Cannot open $file:$!";
$gard = "\U$file";             
$gard =~ s/\..*$//;                 
$gard =~ s#/#_#g;

print "#ifndef _$gard\n";
print "#define _$gard\n";
print "#ifndef _${gard}_H_\n";

print STDERR "Extracting protos with gcc\n";
die if (system("gcc","-aux-info","/tmp/X-info","-S","-o","/dev/null",@cargs));

open(INFO,"</tmp/X-info") || die "Cannot open /tmp/X-info:$!";
while (<INFO>)
 {
  if (m#/X11/X[^/]*\.h:\d+:NC\s*\*/\s*(.*)$#o)
   {
    $_ = $1;
    if (/\b(X[A-Za-z0-9]*)\s*\(/)
     {
      if (exists $XFunc{$1})
       {
        chomp;
        s/^(.*?)\(/$1 _ANSI_ARGS_((/;
        s/\);\s*$/));\n/;
        print;
       }
     }
    else
     {
      warn "No function:$_";
     }
   }
 }
close(INFO);

print "#endif /* _${gard}_H_ */\n";
print "#endif /* _$gard */\n";