From bab35e6fd3fd343ecad45213580fca95679f42daa9771a48d6d73eab0db30656 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Mon, 20 Feb 2012 13:19:27 +0000 Subject: [PATCH] - fix sorting of tag lines that are not on the beginning of the file OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-format_spec_file?expand=0&rev=64 --- obs-service-format_spec_file.changes | 5 +++++ prepare_spec | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/obs-service-format_spec_file.changes b/obs-service-format_spec_file.changes index e4610cf..b2e50a9 100644 --- a/obs-service-format_spec_file.changes +++ b/obs-service-format_spec_file.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Feb 20 13:19:09 UTC 2012 - coolo@suse.com + +- fix sorting of tag lines that are not on the beginning of the file + ------------------------------------------------------------------- Mon Feb 20 08:15:52 UTC 2012 - coolo@suse.com diff --git a/prepare_spec b/prepare_spec index 24ddfbb..5c48ee0 100644 --- a/prepare_spec +++ b/prepare_spec @@ -624,7 +624,7 @@ read_and_parse_old_spec ( $specfile, $base_package ); for my $tag (qw(BuildRequires Requires Provides)) { my $linesmoved = 1; - while ($linesmoved) { + sortcycle: while ($linesmoved) { $linesmoved = 0; my @firstlines = (); my @tags = (); @@ -637,10 +637,16 @@ for my $tag (qw(BuildRequires Requires Provides)) { if (@tags > 0) { my @sortedtags = sort sort_tags_helper @tags; $linesmoved = !compare_arrays(\@tags, \@sortedtags); - @oldspec = (@firstlines, @sortedtags, $l, @oldspec); - @firstlines = (); - @tags = (); - last; + if ($linesmoved) { + @oldspec = (@firstlines, @sortedtags, $l, @oldspec); + @firstlines = (); + @tags = (); + next sortcycle; + } else { + @firstlines = (@firstlines, @tags, $l); + @tags = (); + next; + } } else { push(@firstlines, $l); }