- Segmentation fault running import-yaml.pl with included example

Signed-off-by: Paul Beckingham <paul@beckingham.net>
This commit is contained in:
Markus Beppler 2014-07-27 23:39:37 -04:00 committed by Paul Beckingham
parent 2f65b23af1
commit 865bee5f11

View file

@ -62,13 +62,22 @@ while (my $yaml = <>)
$json .= ",\"entry\":\"${entry}\"" if $entry ne '';
$json .= ",\"end\":\"${end}\"" if $end ne '';
$json .= ",\"due\":\"${due}\"" if $due ne '';
$json .= ",\"tags\":\"${tags}\"" if $tags ne '';
$json .= ",\"description\":\"${description}\"}";
for my $key (sort keys %annotations)
if ($tags ne '')
{
$json .= ",\"${key}\":\"" . $annotations{$key} . "\""
$tags =~ s/,/","/g;
$json .= ",\"tags\":[\"${tags}\"]";
}
if (%annotations)
{
$json .= ",\"annotations\":[";
my $pre = "";
for my $key (sort keys %annotations) {
$json .= "${pre}{\"entry\":\"${key}\",\"description\":\"${annotations{$key}}\"}";
$pre = ",";
}
$json .= "]";
}
$json .= ",\"description\":\"${description}\"}";
push @tasks, $json;
@ -89,7 +98,7 @@ while (my $yaml = <>)
$anno_desc = $1;
$mid_anno = 0;
$annotations{'annotation_' . epoch ($anno_entry)} = $anno_desc;
$annotations{$anno_entry} = $anno_desc;
}
}
else
@ -111,16 +120,6 @@ while (my $yaml = <>)
print "[\n", join (",\n", @tasks), "\n]\n";
exit 0;
################################################################################
sub epoch
{
my ($input) = @_;
my ($Y, $M, $D, $h, $m, $s) = $input =~ /(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z/;
return timegm ($s, $m, $h, $D, $M-1, $Y-1900);
}
################################################################################
__DATA__