File: finddecl

package info (click to toggle)
afbackup 3.3.8.1beta2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,128 kB
  • ctags: 3,370
  • sloc: ansic: 46,932; sh: 4,654; tcl: 4,199; makefile: 536; csh: 416; perl: 133; sed: 93
file content (45 lines) | stat: -rwxr-xr-x 740 bytes parent folder | download | duplicates (7)
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
#!/bin/sh

exec perl -e '
open(CPP, "'"$CPP"' '$2'|grep -v ^#|");
while(<CPP>){
  chop($_);
  if($_ =~ /[ \t]+'$1'[ \t]*\(/){
    $decl=$_;
    until ($decl =~ /'$1'[ \t]*\(.*\)[ \t]*;/){
      $decl .= <CPP>;
      chop($decl);
    }

    $decl =~ /[ \t]*(.*)[ \t]*'$1'[ \t]*\((.*)\)[ \t]*;/;
    $rettype = $1;
    $args = $2;
    if($rettype =~ /^[ \t]*$/){
      $rettype = "int";
    }

    $rettype =~ s/[ \t]*extern[ \t]*//;
    $rettype =~ s/^[ \t]*//;
    $rettype =~ s/[ \t]*$//;

    @argv = split(",", $args);

    print "$rettype\n";

    foreach $arg (@argv){
      $arg =~ s/^[ \t]*//;
      $arg =~ s/[ \t]*$//;

      print "$arg\n";
    }

    close(CPP);
    exit(0);
  }
}

close(CPP);

print "Not found.\n";
exit(1);'