diff find-todo.pl @ 0:fc9323a41f5a

start base : Sonic Visualiser sv1-1.0rc1
author lbajardsilogic
date Fri, 11 May 2007 09:08:14 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/find-todo.pl	Fri May 11 09:08:14 2007 +0000
@@ -0,0 +1,69 @@
+#!/usr/bin/perl -w
+require 5;
+use strict;
+
+# Command line should contain a list of files to look in.
+#
+# A likely invocation would be
+#  find . \( -name \*.h -o -name \*.cpp \) -print | xargs perl ./find-todo.pl
+#
+# Unusual or binary files will be ignored.
+
+my $todo_count = 0;
+my $file_count = 0;
+my $unfinished_count = 0;
+
+sub print_file_maybe
+{
+    my ($pf, $file) = @_;
+    if (! $$pf) {
+	print "\n$file:\n";
+	$$pf = 1;
+	$file_count++;
+    }
+}
+
+foreach (@ARGV) {
+
+    my $file = $_;
+    next if ($file =~ /~$/);
+    open FILE, $file or next;
+    my $in_todo = 0;
+    my $printed_file = 0;
+    my $line = 0;
+
+    while (<FILE>) {
+
+	$line++;
+	last if (m.^[\200-\377].); # probably a binary file
+
+	if ($in_todo) {
+
+	    if (m, /[/\*](!!!)?\s* (.*) $ ,x) {
+		print "          $2\n";
+	    } else {
+		$in_todo = 0;
+	    }
+
+	} else {
+
+	    if (m, /[/\*] !!!\s* (.*) $ ,x) {
+		print_file_maybe(\$printed_file, $file);
+		print sprintf("%8d", $line), ": $1\n";
+		$in_todo = 1;
+		$todo_count++;
+
+	    } elsif (m, /[/\*] \Q...\E \s* (.*) $ ,x) {
+		print_file_maybe(\$printed_file, $file);
+		print sprintf("%8d", $line), ": [U] $1\n";
+		$unfinished_count++;
+	    }
+	}
+    }
+
+    close FILE;
+}
+
+print "\nTotal: $todo_count problem items, $unfinished_count unfinished " .
+    "markers in $file_count files\n\n";
+