From 4d75cb93a3b707e40ef34a381809b72dd68d8962 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@digia.com>
Date: Thu, 19 Sep 2013 17:21:39 +0200
Subject: [PATCH] qmake: Expose ARGC to qmake functions to be able to check
 argument count

ARGS already exists, but is a flattened list of the arguments, so both
foo(bar, baz) and foo(bar baz) will give count(ARGS, 2), making it
unreliable for validating arguments to qmake functions.

Change-Id: I0bcc16614c64000169431327da48fd1a26708e67
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
(cherry picked from qtbase/09205d573413da8a2ac3826198fe36bb2dc4349f)
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
---
 src/shared/proparser/qmakeevaluator.cpp | 2 ++
 src/shared/proparser/qmakeevaluator_p.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp
index ed1d0a619e5..1da18a3980f 100644
--- a/src/shared/proparser/qmakeevaluator.cpp
+++ b/src/shared/proparser/qmakeevaluator.cpp
@@ -109,6 +109,7 @@ void QMakeEvaluator::initStatics()
     statics.strfalse = QLatin1String("false");
     statics.strCONFIG = ProKey("CONFIG");
     statics.strARGS = ProKey("ARGS");
+    statics.strARGC = ProKey("ARGC");
     statics.strDot = QLatin1String(".");
     statics.strDotDot = QLatin1String("..");
     statics.strever = QLatin1String("ever");
@@ -1635,6 +1636,7 @@ ProStringList QMakeEvaluator::evaluateFunction(
             m_valuemapStack.top()[ProKey(QString::number(i+1))] = argumentsList[i];
         }
         m_valuemapStack.top()[statics.strARGS] = args;
+        m_valuemapStack.top()[statics.strARGC] = ProStringList(ProString(QString::number(argumentsList.count())));
         vr = visitProBlock(func.pro(), func.tokPtr());
         if (vr == ReturnReturn)
             vr = ReturnTrue;
diff --git a/src/shared/proparser/qmakeevaluator_p.h b/src/shared/proparser/qmakeevaluator_p.h
index d17b4843124..50c063be895 100644
--- a/src/shared/proparser/qmakeevaluator_p.h
+++ b/src/shared/proparser/qmakeevaluator_p.h
@@ -71,6 +71,7 @@ struct QMakeStatics {
     QString strfalse;
     ProKey strCONFIG;
     ProKey strARGS;
+    ProKey strARGC;
     QString strDot;
     QString strDotDot;
     QString strever;
-- 
GitLab