From: Abir Viqar Date: Thu, 3 Oct 2013 20:48:34 +0000 (-0400) Subject: Porting/corelist-perldelta.pl - Cleanup DeltaParser X-Git-Tag: upstream/5.20.0~961^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c014dfade439c530cde995c21eddff12e9179657;p=platform%2Fupstream%2Fperl.git Porting/corelist-perldelta.pl - Cleanup DeltaParser * Comment generation of accessor methods * Make _parse_delta() more explicit by calling the section parsing methods explicitly * Ensure that the new_modules, updated_modules, and removed_modules attributes exist even if the perldelta file does not contain the corresponding sections --- diff --git a/Porting/corelist-perldelta.pl b/Porting/corelist-perldelta.pl index 6b8ebba..19ab0d3 100755 --- a/Porting/corelist-perldelta.pl +++ b/Porting/corelist-perldelta.pl @@ -224,6 +224,10 @@ sub do_check { return $self; } + # creates the accessor methods: + # new_modules + # updated_modules + # removed_modules for my $k (keys %sections) { no strict 'refs'; my $m = "${k}_modules"; @@ -233,29 +237,17 @@ sub do_check { sub _parse_delta { my ($self, $pod) = @_; - map { - my ($t, $s) = @{ $_ }; - - # Keep the section title if it has one: - if( $s->[0]->[0] eq 'head2' ) { - #warn "Keeping section title '$s->[0]->[2]'"; - $titles{ $t } = $s->[0]->[2] - if $s->[0]->[2]; - }; - - $self->${\"_parse_${t}_section"}($s) - } map { - my $s = $self->_look_for_section($pod => $sections{$_}) - or die "failed to parse $_ section"; - [$_, $s]; - } keys %sections; - - for my $s (keys %sections) { - my $m = "${s}_modules"; - - $self->{$m} = [sort { - lc $a->[0] cmp lc $b->[0] - } @{ $self->{$m} }]; + my $new_section = $self->_look_for_section( $pod, $sections{new} ); + my $updated_section = $self->_look_for_section( $pod, $sections{updated} ); + my $removed_section = $self->_look_for_section( $pod, $sections{removed} ); + + $self->_parse_new_section($new_section); + $self->_parse_updated_section($updated_section); + $self->_parse_removed_section($removed_section); + + for (qw/new_modules updated_modules removed_modules/) { + $self->{$_} = + [ sort { lc $a->[0] cmp lc $b->[0] } @{ $self->{$_} } ]; } return; @@ -264,6 +256,8 @@ sub do_check { sub _parse_new_section { my ($self, $section) = @_; + $self->{new_modules} = []; + return unless $section; $self->{new_modules} = $self->_parse_section($section => sub { my ($el) = @_; @@ -310,6 +304,9 @@ sub do_check { sub _parse_removed_section { my ($self, $section) = @_; + + $self->{removed_modules} = []; + return unless $section; $self->{removed_modules} = $self->_parse_section($section => sub { my ($el) = @_;