Dpkg::BuildFlags: Fix strip method to always work with duplicates
commit5f6e45fbbd0637d4d9cc35b9a4ee4d494c1418b4
authorGuillem Jover <guillem@debian.org>
Fri, 6 Jan 2023 19:51:30 +0000 (6 20:51 +0100)
committerGuillem Jover <guillem@debian.org>
Sat, 7 Jan 2023 12:32:18 +0000 (7 13:32 +0100)
tree603a048acb71dbc5bbec1381b3d733ba68587925
parent5ecd8ed2f70d3f28c3990dbb725cff691e6c1f7d
Dpkg::BuildFlags: Fix strip method to always work with duplicates

The regex was not correctly matching at the beginning of the line with
leading spaces, which could be left by a previous replacement from
the same s/// operator. Instead switch to split the flag value and
filter based on a hash, which means we do not need to care about such
space issues anymore.

This change should not change the semantics for space separated options
in the flags, as the code was already splitting the passed values on
spaces, and then remapping on the entire flag value.

Improve strip unit tests to cover all these cases.

Closes: #1028044
scripts/Dpkg/BuildFlags.pm
scripts/t/Dpkg_BuildFlags.t