summaryrefslogtreecommitdiff
path: root/localmarkdown2sms
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2009-08-08 19:36:13 +0200
committerJonas Smedegaard <dr@jones.dk>2009-08-08 19:36:13 +0200
commitd6deece01161ee8c1a573e927ffc2da6f2448b6f (patch)
tree357c22d2f3e48c9021056bc2f81270cba83d9b4f /localmarkdown2sms
parentbe7f19b67f56707605334e717d873604382dc98f (diff)
Fix more use of un-key'ed content. Suppress repeated warnings for same issues.
Diffstat (limited to 'localmarkdown2sms')
-rwxr-xr-xlocalmarkdown2sms16
1 files changed, 11 insertions, 5 deletions
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];
}
}