aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcountify17
-rwxr-xr-xlistify17
-rwxr-xr-xvotify17
3 files changed, 45 insertions, 6 deletions
diff --git a/countify b/countify
index c882fc7..2de6ba8 100755
--- a/countify
+++ b/countify
@@ -24,13 +24,26 @@ use strict;
(my $version = '$Revision: 1.3 $') =~ s/.*?(\d.*\d).*/$zero version $1\n/;
my %opt;
+sub grabfile_int {
+ my $f = shift;
+ open FILE, "<", $f;
+ $i = <FILE>;
+ close FILE;
+ chomp $i;
+ return $i + 0;
+}
+
# Collect the open elections
my (@open_elections, $usage_elections);
opendir(D, "$Votify::datadir/") or die;
@open_elections = sort grep {
s/^start-// and do {
- my ($starttime) = (stat _)[9] if stat("$Votify::datadir/start-$_");
- my ($stoptime) = (stat _)[9] if stat("$Votify::datadir/stop-$_");
+ my ($startfile) = sprintf "%s/start-%s", $Votify::datadir, $_;
+ my ($stopfile) = sprintf "%s/stop-%s", $Votify::datadir, $_;
+ my ($starttime) = grabfile_int($startfile);
+ my ($stoptime) = grabfile_int($stopfile);
+ $starttime = (stat _)[9] if stat($startfile) and (!defined($starttime) or ($starttime <= 0));
+ $stoptime = (stat _)[9] if stat($stopfile) and (!defined($stoptime) or ($stoptime <= 0));
((not defined $starttime or $starttime < time) and
(not defined $stoptime or $stoptime > time))
}
diff --git a/listify b/listify
index 641d473..632e444 100755
--- a/listify
+++ b/listify
@@ -24,14 +24,27 @@ use strict;
(my $version = '$Revision: 1.5 $') =~ s/.*?(\d.*\d).*/$zero version $1\n/;
my (%opt, %elections);
+sub grabfile_int {
+ my $f = shift;
+ open FILE, "<", $f;
+ $i = <FILE>;
+ close FILE;
+ chomp $i;
+ return $i + 0;
+}
+
# Collect the open elections
my (@open_elections, $usage_elections);
opendir(D, "$Votify::datadir/") or die;
@open_elections = sort grep {
s/^start-// and do {
my ($name) = $_;
- my ($starttime) = (stat _)[9] if stat("$Votify::datadir/start-$_");
- my ($stoptime) = (stat _)[9] if stat("$Votify::datadir/stop-$_");
+ my ($startfile) = sprintf "%s/start-%s", $Votify::datadir, $_;
+ my ($stopfile) = sprintf "%s/stop-%s", $Votify::datadir, $_;
+ my ($starttime) = grabfile_int($startfile);
+ my ($stoptime) = grabfile_int($stopfile);
+ $starttime = (stat _)[9] if stat($startfile) and (!defined($starttime) or ($starttime <= 0));
+ $stoptime = (stat _)[9] if stat($stopfile) and (!defined($stoptime) or ($stoptime <= 0));
my $valid = ((not defined $starttime or $starttime < time) and
(not defined $stoptime or $stoptime > time));
if($valid) {
diff --git a/votify b/votify
index c8d4e40..2e295bc 100755
--- a/votify
+++ b/votify
@@ -24,13 +24,26 @@ use strict;
(my $version = '$Revision: 1.5 $') =~ s/.*?(\d.*\d).*/$zero version $1\n/;
my (%opt);
+sub grabfile_int {
+ my $f = shift;
+ open FILE, "<", $f;
+ $i = <FILE>;
+ close FILE;
+ chomp $i;
+ return $i + 0;
+}
+
# Collect the open elections
my (@open_elections, $usage_elections);
opendir(D, "$Votify::datadir/") or die;
@open_elections = sort grep {
s/^start-// and do {
- my ($starttime) = (stat _)[9] if stat("$Votify::datadir/start-$_");
- my ($stoptime) = (stat _)[9] if stat("$Votify::datadir/stop-$_");
+ my ($startfile) = sprintf "%s/start-%s", $Votify::datadir, $_;
+ my ($stopfile) = sprintf "%s/stop-%s", $Votify::datadir, $_;
+ my ($starttime) = grabfile_int($startfile);
+ my ($stoptime) = grabfile_int($stopfile);
+ $starttime = (stat _)[9] if stat($startfile) and (!defined($starttime) or ($starttime <= 0));
+ $stoptime = (stat _)[9] if stat($stopfile) and (!defined($stoptime) or ($stoptime <= 0));
((not defined $starttime or $starttime < time) and
(not defined $stoptime or $stoptime > time))
}