Re: [dpkg] 23/23: perl: Split overlong regexes into multiline extended regexes
- To: debian-dpkg@lists.debian.org
- Subject: Re: [dpkg] 23/23: perl: Split overlong regexes into multiline extended regexes
- From: Sven Joachim <svenjoac@gmx.de>
- Date: Wed, 16 Sep 2015 17:29:10 +0200
- Message-id: <[🔎] 87h9mu8jsp.fsf@turtle.gmx.de>
- Mail-followup-to: debian-dpkg@lists.debian.org
- In-reply-to: <E1ZbKhj-0002Lb-T1@moszumanska.debian.org> (Guillem Jover's message of "Mon, 14 Sep 2015 03:45:19 +0000")
- References: <20150914034514.8658.72007@moszumanska.debian.org> <E1ZbKhj-0002Lb-T1@moszumanska.debian.org>
On 2015-09-14 05:45 +0200, Guillem Jover wrote:
> diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl
> index db970dd..c8b2336 100755
> --- a/scripts/dpkg-shlibdeps.pl
> +++ b/scripts/dpkg-shlibdeps.pl
> @@ -670,6 +670,18 @@ sub split_soname {
> }
> }
>
> +my $shlibs_re = qr{
> + ^\s*
> + (?:(\S+):\s+)? # Optional type
> + (\S+)\s+ # Library
> + (\S+) # Version
> + (?:
> + \s+
> + (\S.*\S) # Dependencies
> + )?
> + \s*$
> +}x;
> +
> sub extract_from_shlibs {
> my ($soname, $shlibfile) = @_;
> # Split soname in name/version
> @@ -686,7 +698,7 @@ sub extract_from_shlibs {
> while (<$shlibs_fh>) {
> s/\s*\n$//;
> next if m/^\#/;
> - if (!m/^\s*(?:(\S+):\s+)?(\S+)\s+(\S+)(?:\s+(\S.*\S))?\s*$/) {
> + if (!m/$shlibs_re/) {
> warning(g_("shared libs info file '%s' line %d: bad line '%s'"),
> $shlibfile, $., $_);
> next;
This has lead to a dpkg-shlibdeps failure:
,----
| Use of uninitialized value $shlibs_re in regexp compilation at /usr/bin/dpkg-shlibdeps line 701, <$shlibs_fh> line 1.
`----
I don't know all the details of Perl's lexical scoping wrt subroutines
(and the perlsub manpage did not help either), but I suppose the
definition of $shlibs_re needs to be moved up before the first call of
extract_from_shlibs, or put inside the extract_from_shlibs routine.
Cheers,
Sven
Reply to: