home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / utils / hdr.pl < prev    next >
Encoding:
Perl Script  |  1996-09-21  |  908 b   |  52 lines

  1. #!/bin/perl
  2. # -*- perl -*-
  3.  
  4. $inc = "d:/v2/include";
  5.  
  6.  
  7. $pattern = shift;
  8.  
  9. print "\n";
  10.  
  11. opendir(INC, $inc);
  12. @files = sort readdir(INC);
  13. closedir(INC);
  14.  
  15. for $file (@files) {
  16.     next if $file =~ /^\./;
  17.     if ( -d $file ) {
  18.     push(@subs, $file);
  19.     } else {
  20.     &scan_file($file);
  21.     }
  22. }
  23.  
  24. for $dir (@subs) {
  25.     opendir(INC, "$inc/$dir");
  26.     @files = sort readdir(INC);
  27.     closedir(INC);
  28.  
  29.     for $file (@files) {
  30.     next if $file =~ /^\./;
  31.     &scan_file("$dir/$file");
  32.     }
  33. }
  34.  
  35. sub scan_file {
  36.     local($file) = @_;
  37.     open(F, "$inc/$file");
  38.     $tag = '?';
  39.     while (<F>) {
  40.     if (/$pattern/io) {
  41.         print "$file:$tag: $_";
  42.     }
  43.     $tag = 'A' if /\#ifndef __dj_ENFORCE_ANSI_FREESTANDING/;
  44.     $tag = 'P' if /\#ifndef __STRICT_ANSI__/;
  45.     $tag = 'D' if /\#ifndef _POSIX_SOURCE/;
  46.     $tag = 'I' if /\#ifndef __dj_ENFORCE_FUNCTION_CALLS/;
  47.     }
  48.     close(F);
  49. }
  50.  
  51. print "\n";
  52.