Imported Robodoc.
[robodoc.git] / Source / todo.pl
1 #!/usr/bin/perl -w
2 #
3 use strict;
4 use IO::File;
5
6 my $count = 0;
7
8 sub scan_file {
9     my $file = shift;
10     my $sourcefile = IO::File->new("<$file") or
11     die "can't open $file";
12     my @source = <$sourcefile>;
13     my @todos;
14     my $key = "???";
15     foreach my $line (@source) {
16         if ($line =~ /TODO/i) {
17             push(@todos, $line);
18         }
19     }
20     if (scalar(@todos)) {
21         print "File: $file\n";
22         foreach my $line (@todos) {
23             if ($line =~ m/TODO(.*)$/i) {
24                 print "    TODO $1\n";
25                 ++$count;
26             }
27         }
28     }
29 }
30
31
32 sub scan_directory {
33     my $file;
34     opendir(DIR, '.') or die;
35     while (defined($file = readdir(DIR))) {
36         if ($file =~ m/\.(c|h)$/i) {
37             scan_file($file);
38         }
39     }
40     closedir(DIR);
41 }
42
43
44 sub main {
45     if (@ARGV) {
46         foreach my $file (@ARGV) {
47             if ($file =~ m/\.(c|h)$/) {
48                 scan_file $file;
49             }
50         }
51     } else {
52         scan_directory;
53     }
54     print $count, " TODOs to go\n";
55
56 }
57
58 main;
59
60