diff options
-rw-r--r-- | qmake/doc/src/qmake-manual.qdoc | 10 | ||||
-rw-r--r-- | qmake/library/qmakebuiltins.cpp | 11 | ||||
-rw-r--r-- | tests/auto/tools/qmakelib/evaltest.cpp | 12 |
3 files changed, 31 insertions, 2 deletions
diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 4e69fd9897..c22bce3e3e 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -3042,10 +3042,13 @@ See also \l{system_quote(arg)}{system_quote()}. + \target fn_size \section2 size(variablename) Returns the number of values of \c variablename. + See also \l{str_size()}. + \section2 sort_depends(variablename, prefix) This is an internal function that you will typically not need. @@ -3059,6 +3062,13 @@ \snippet code/doc_src_qmake-manual.pro 168 + \target str_size() + \section2 str_size(arg) + + Returns the number of characters in the argument. + + See also \l{fn_size}{size()}. + \section2 system(command[, mode]) You can use this variant of the \c system function to obtain stdout from the diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index 9e9ebf8cc4..d21bae3060 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -80,8 +80,8 @@ QT_BEGIN_NAMESPACE #define fL1S(s) QString::fromLatin1(s) enum ExpandFunc { - E_INVALID = 0, E_MEMBER, E_FIRST, E_TAKE_FIRST, E_LAST, E_TAKE_LAST, E_SIZE, - E_CAT, E_FROMFILE, E_EVAL, E_LIST, E_SPRINTF, E_FORMAT_NUMBER, + E_INVALID = 0, E_MEMBER, E_FIRST, E_TAKE_FIRST, E_LAST, E_TAKE_LAST, + E_SIZE, E_STR_SIZE, E_CAT, E_FROMFILE, E_EVAL, E_LIST, E_SPRINTF, E_FORMAT_NUMBER, E_NUM_ADD, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION, E_FIND, E_SYSTEM, E_UNIQUE, E_REVERSE, E_QUOTE, E_ESCAPE_EXPAND, E_UPPER, E_LOWER, E_TITLE, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, @@ -110,6 +110,7 @@ void QMakeEvaluator::initFunctionStatics() { "last", E_LAST }, { "take_last", E_TAKE_LAST }, { "size", E_SIZE }, + { "str_size", E_STR_SIZE }, { "cat", E_CAT }, { "fromfile", E_FROMFILE }, { "eval", E_EVAL }, @@ -737,6 +738,12 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( else ret.append(ProString(QString::number(values(map(args.at(0))).size()))); break; + case E_STR_SIZE: + if (args.count() != 1) + evalError(fL1S("str_size(str) requires one argument.")); + else + ret.append(ProString(QString::number(args.at(0).size()))); + break; case E_CAT: if (args.count() < 1 || args.count() > 2) { evalError(fL1S("cat(file, singleline=true) requires one or two arguments.")); diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index a516f91070..f12b11261a 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -826,6 +826,18 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: size(var) requires one argument." << true; + QTest::newRow("$$str_size()") + << "VAR = $$str_size(one two three)" + << "VAR = 13" + << "" + << true; + + QTest::newRow("$$str_size(): bad number of arguments") + << "VAR = $$str_size(1, 2)" + << "VAR =" + << "##:1: str_size(str) requires one argument." + << true; + QTest::newRow("$$fromfile(): right var") << "VAR = $$fromfile(" + qindir + "/fromfile/infile.prx, DEFINES)" << "VAR = QT_DLL" |