Hi,

The parsing of valac flags is too permissive and incorrectly matches
some input, possibly leading to garbage in DIST_COMMON -- and then,
build failures.

The problem is that parsing of valac flags uses a non-anchored pattern
and so any argument happening to be a subset of a parsed argument will
match it, e.g. `vapi` will match against `--vapi` or `--internal-vapi`.

E.g. when using the following:

        something_VALAFLAGS = --vapidir vapi --pkg foo

`--pkg` is recognized as an interesting argument (and so, added to
`DIST_COMMON`) because `vapi` (the argument for `--vapidir`) matched
against `--vapi`.

Please find attached a patch fixing the issue.

Regards,
Colomban
>From 16bb54572db217e14e0a024bacf33ab693ea10ec Mon Sep 17 00:00:00 2001
From: Colomban Wendling <b...@herbesfolles.org>
Date: Wed, 15 Oct 2014 16:22:13 +0200
Subject: [PATCH] vala: Fix parsing valac flags
To: lists....@herbesfolles.org

When parsing valac flags, ensure complete matches not to e.g. match
`vapi` against `--vapi` or `--internal-vapi`.  This fixes parsing when
one of the flags value is a subset of one of the flags we match.

E.g. when using the following:

	something_VALAFLAGS=--vapidir vapi --pkg foo

`--pkg` used to be recognized as an interesting argument (and so, added
to `DIST_COMMON`) because `vapi` (the argument for `--vapidir`) matched
against `--vapi`.
---
 bin/automake.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/automake.in b/bin/automake.in
index 4cee0d0..832b208 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -5436,8 +5436,8 @@ sub lang_vala_finish_target
       my $lastflag = '';
       foreach my $flag ($flags->value_as_list_recursive)
 	{
-	  if (grep (/$lastflag/, ('-H', '-h', '--header', '--internal-header',
-	                          '--vapi', '--internal-vapi', '--gir')))
+	  if (grep (/^$lastflag$/, ('-H', '-h', '--header', '--internal-header',
+	                            '--vapi', '--internal-vapi', '--gir')))
 	    {
 	      my $headerfile = "\$(srcdir)/$flag";
 	      $output_rules .= "$headerfile: \$(srcdir)/${derived}_vala.stamp\n"
-- 
2.1.1

Reply via email to