satyr (owner)

Revisions

gist: 212074 Download_button fork
public
Description:
ArcRef
Public Clone URL: git://gist.github.com/212074.git
Embed All Files: show embed
arcref.pl #
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
#!perl
use strict;
use warnings;
use File::Basename;
 
unless(@ARGV){
  print "usage: $0 {def/mac name}\n";
  exit 1;
}
 
chdir dirname $0;
our $re = qr/\((?:x?def|mac|=)\s+$ARGV[0]\s+/;
for my $f ('ac.scm', glob '*.arc'){
  exit if findref($f);
}
 
sub findref {
  my $file = shift;
  unless(open Arc, "< $file"){
    warn "failed to open $file";
    return 0;
  }
  while(<Arc>){
    next unless $_ =~ $re;
    print "$file\n";
    print;
    print while ($_ = <Arc>) =~ /^./;
    return 1;
  }
  0
}