From d6deece01161ee8c1a573e927ffc2da6f2448b6f Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 8 Aug 2009 19:36:13 +0200 Subject: Fix more use of un-key'ed content. Suppress repeated warnings for same issues. --- localmarkdown2sms | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'localmarkdown2sms') diff --git a/localmarkdown2sms b/localmarkdown2sms index ddc1366..8db1096 100755 --- a/localmarkdown2sms +++ b/localmarkdown2sms @@ -38,6 +38,8 @@ my ($path) = shift @ARGV; foreach my $file (read_dir( $path )) { my ($key, $i); + # suppress repeated warnings for same issue + my ($warn_nonkey_delay, $warn_nonkey_content); next unless ($file =~ /\.mdwn$/); foreach my $line (read_file( File::Spec->catfile($path, $file))) { chomp $line; @@ -45,7 +47,7 @@ foreach my $file (read_dir( $path )) { # headline if ($line =~ /^(#+)\s*(.*?)\s*$/) { # tidy latest reply (TODO: use sub) - if (defined($i) and defined($reply{$key}[$i])) { + if (defined($key) and defined($reply{$key}[$i])) { $reply{$key}[$i] =~ s/^\s*(\w.*?)\s*$/$1/s || delete $reply{$key}[$i]; } my $level = length($1); @@ -59,6 +61,8 @@ foreach my $file (read_dir( $path )) { } if (!defined( $delay{$key})) { $delay{$key}[0] = 0; + $warn_nonkey_delay = undef; + $warn_nonkey_content = undef; } else { warn( "skipping non-unique key \"$key\" in file \"$file\"" ); $key = undef; @@ -76,10 +80,11 @@ foreach my $file (read_dir( $path )) { warn( "delay (${delay}s) resolved from fuzzy string \"$content\" in file \"$file\"" ); } } else { - warn( "skipping non-key'ed delay line \"$1\" in file \"$file\"" ); + warn( "ignoring non-key'ed delay line \"$1\" in file \"$file\"" ) unless ($warn_nonkey_delay); + $warn_nonkey_delay = 1; } } else { - warn( "skipping non-parsable headline \"$line\" in file \"$file\""); + warn( "ignoring non-parsable headline \"$line\" in file \"$file\""); } # reply } elsif ( defined( $key )) { @@ -92,11 +97,12 @@ foreach my $file (read_dir( $path )) { $content =~ s/\h*$//g; # strip all trailing spaces $reply{$key}[$i] = $content; } else { - warn( "skipping non-key'ed content \"$line\" in file \"$file\"" ); + warn( "skipping non-key'ed content \"$line\" in file \"$file\"" ) unless ($warn_nonkey_content); + $warn_nonkey_content = 1; } } # tidy latest reply (TODO: use sub) - if (defined($i) and defined($reply{$key}[$i])) { + if (defined($key) and defined($reply{$key}[$i])) { $reply{$key}[$i] =~ s/^\s*(\w.*?)\s*$/$1/s || delete $reply{$key}[$i]; } } -- cgit v1.2.3