aboutsummaryrefslogtreecommitdiff
path: root/showtodo
blob: 475e492ebab03db3d76e1bc6a25cd3e8d261e9b3 (plain)
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
#!/usr/bin/env perl

use strict;
use warnings;

# Note that this script only supports /* C-style */ comments.

while (my $f = glob("c/*.*")) {
	open my $fh, "<", $f;
	my $line;
	while (<$fh>) {
		$line++;
		next if not m{TODO:}; # Skip fast.

		next if not m{^\s*/?\*.*\s(TODO:.*)\s*(\*/)?};
		print "$f:$line: $1\n";
		next if $2;

		# Continue text if comment is not finished.
		my $pad = " " x length("$f:$line: ");
		while (<$fh>) {
			(my $text = $_) =~ s{^\s*\*?\s*|\s*\*/}{}g;
			print "$pad$text";
			last if m{\*/};
		}
	}
}