chiark / gitweb /
normalise: introduce setcanddesc
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Aug 2016 11:35:11 +0000 (12:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Aug 2016 11:35:11 +0000 (12:35 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
normalise

index 7db0740..df9e467 100755 (executable)
--- a/normalise
+++ b/normalise
@@ -35,6 +35,16 @@ sub normalise_opts ($) {
     return " | @o";
 }
 
+sub setcanddesc ($$) {
+    my ($cand,$desc) = @_;
+
+    if (length $desc) {
+       badinput "multiple descriptions for $cand" if
+           defined $candidates{$cand}{Desc};
+       $candidates{$cand}{Desc} = $desc;
+    }
+}
+
 while (<>) {
     next unless m/\S/;
     next if m/^\#/;
@@ -47,11 +57,7 @@ while (<>) {
 print STDERR Dumper($1,$2,$3);
        my ($cand,$desc,$opts) = ($1,$2,$3);
        push @{ $candidates{$cand}{Opts} }, normalise_opts $opts;
-       if (length $desc) {
-           badinput "multiple descriptions for $cand" if
-               defined $candidates{$cand}{Desc};
-           $candidates{$cand}{Desc} = $desc;
-       }
+       setcanddesc $cand, $desc;
     } elsif (m/^($candvoter_re?)?\s*\:([^|]*)(?:\|(.*))?$/) {
        my ($voter,$opts) = ($1,$3);
        my @p;