From: cjwatson <> Date: Fri, 22 Aug 2003 02:21:43 +0000 (-0800) Subject: [project @ 2003-08-21 19:21:43 by cjwatson] X-Git-Tag: release/2.6.0~815 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8481a1b6586190d5c80d9451a7bf5dee62efb26d;p=debbugs.git [project @ 2003-08-21 19:21:43 by cjwatson] Simplify status reading and writing in preparation for format change. There should now be exactly one list of status fields. --- diff --git a/scripts/errorlib.in b/scripts/errorlib.in index a13bb9f6..43ee9631 100755 --- a/scripts/errorlib.in +++ b/scripts/errorlib.in @@ -1,5 +1,5 @@ # -*- perl -*- -# $Id: errorlib.in,v 1.33 2003/08/06 18:45:41 cjwatson Exp $ +# $Id: errorlib.in,v 1.34 2003/08/21 19:21:43 cjwatson Exp $ use Mail::Address; @@ -70,26 +70,36 @@ sub getbugcomponent { } } +my @fields = qw(originator date subject msgid package + keywords done forwarded mergedwith severity); + sub readbug { local ($lref, $location) = @_; my $status = getbugcomponent($lref, 'status', $location); return undef unless defined $status; if (!open(S,$status)) { return undef; } + my %data; - chop($data{originator}= ); - chop($data{date}= ); - chop($data{subject}= ); - chop($data{msgid}= ); - chop($data{package}= ); - chop($data{keywords}= ); - chop($data{done}= ); - chop($data{forwarded}= ); - chop($data{mergedwith}= ); - chop($data{severity}= ); - chop($data{versions}= ); - chop($data{fixed_versions}= ); + my @lines; + local $_; + + while () { + chomp; + push @lines, $_; + } + + for my $field (@fields) { + if (@lines) { + $data{$field} = shift @lines; + } else { + $data{$field} = ''; + } + } + close(S); - $data{severity} = 'normal' if $data{severity} eq ''; + + $data{severity} = 'normal' if $data{severity} eq ''; + return \%data; } @@ -103,19 +113,16 @@ sub lockreadbug { sub makestatus { my $data = shift; - my $contents = - "$data->{originator}\n". - "$data->{date}\n". - "$data->{subject}\n". - "$data->{msgid}\n". - "$data->{package}\n". - "$data->{keywords}\n". - "$data->{done}\n". - "$data->{forwarded}\n". - "$data->{mergedwith}\n". - "$data->{severity}\n". - "$data->{versions}\n". - "$data->{fixed_versions}\n"; + my $contents = ''; + + for my $field (@fields) { + if (exists $data->{$field}) { + $contents .= "$data->{$field}\n"; + } else { + $contents .= "\n"; + } + } + return $contents; }