From: Ian Jackson Date: Sun, 21 Aug 2016 11:35:11 +0000 (+0100) Subject: normalise: introduce setcanddesc X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=622789750886b5b2e39f2fadf7efe3c962ead67e;p=appendix-a6.git normalise: introduce setcanddesc Signed-off-by: Ian Jackson --- diff --git a/normalise b/normalise index 7db0740..df9e467 100755 --- 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;