[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [dpkg] 23/23: perl: Split overlong regexes into multiline extended regexes



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: