Annotation of libwww/config/makedefs.pl, revision 1.2

1.1       eric        1: #!/usr/local/bin/perl
                      2: 
                      3: $NumberDefs'at = 24;            # target at sign column
                      4: $NumberDefs'tab = 8;            # how wide a tab looks in your editor
                      5: $NumberDefs'offset = 0;         # starting number
                      6: $NumberDefs'index;
                      7: 
                      8: sub NumberDefs'numberEach
                      9: {
                     10:     package NumberDefs;
                     11:     local($name) = @_;
                     12:     if ($name eq "") {
                     13:        print "\n";
                     14:        next;
                     15:     }
                     16:     if ($offset == 0) {
                     17:        print "EXPORTS\n";
                     18:     }
                     19:     print $name;
                     20:     if ($name =~ /^;/) {
                     21:        ($module, $atsign, $start) = split(" ", $_);
                     22: #      print "\"", $module, "\" ", $start;
                     23:        if ($start && $start > $offset) {
                     24:            $offset = $start;
                     25:        } else {
1.2     ! frystyk    26:            $offset += 200;
1.1       eric       27:        }
                     28:        $index = $offset;
                     29:     }
                     30:     $len = length($name);
                     31:     if ($len >= $at) {
                     32:        print " ";
                     33:     } else {
                     34:        $tabz = (($at-$len)/$tab);
                     35:        for ($i = 0; $i < $tabz; $i++) {
                     36:            print "\t";
                     37:        }
                     38:     }
                     39:     print "@ ", $index, "\n";
                     40:     $index ++;
                     41: }
                     42: 
                     43: # numberAll - call this to renumber a def file
                     44: #
                     45: sub NumberDefs'numberAll
                     46: {
                     47:     package NumberDefs;
                     48:     $INPUT = $_[0];
                     49:     while(<$INPUT>) {
                     50:        local($name) =  split(" ",$_);
                     51:        &NumberDefs'numberEach($name);
                     52:     }
                     53: }
                     54: 
                     55: sub GrepPublic
                     56: {
                     57:     local($source) = @_;
                     58:     if (!open (SOURCE, "../".$source)) {
                     59:        warn "Can't open ../$source: $!\n"; 
                     60:        return;
                     61:     }
                     62:     &NumberDefs'numberEach(';'.$source); # add source file as a source
                     63:     while (<SOURCE>) {
                     64:        if (!/^PUBLIC\s/) {
                     65:             next;
                     66:         }
                     67:         if (!/(\w*)\W*\(/) {
                     68:             warn "assuming global: ", $_;
                     69:             next;
                     70:         }
                     71:         local($func) = $1;
                     72: #       printf "\$_:\"%s\" \$func:\"%s\"\n", $_, $func;
                     73:         &NumberDefs'numberEach($func);
                     74:     }
                     75: }
                     76: 
                     77: if (@ARGV[0] =~ /@(.*)/) {
                     78:     local($name) = $1;
                     79:     if ($name =~ /\w+/) {
                     80:        if (!open(LIST, $name)) {
                     81:            die "Can't open \"$1\", $!";
                     82:        }
                     83:        while (<LIST>) {
                     84:            chop;
                     85:            &GrepPublic($_);
                     86:            print "\n";
                     87:        }
                     88:        exit 0;
                     89:     }
                     90:     while (<STDIN>) {
                     91:        chop;
                     92:        &GrepPublic($_);
                     93:        print "\n";
                     94:     }
                     95:     exit 0;
                     96: }
                     97: foreach $source (@ARGV) {
                     98:     &GrepPublic($source);
                     99: }
                    100: 
                    101: #&NumberDefs'numberAll(STDIN);
                    102: 

Webmaster