diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp index afc0d48be5a8947b9546bc3df43a490b520bbe41..d3ca9ed6cec886675dd15cc63d2d525aa0485382 100644 --- a/src/linguist/lupdate/main.cpp +++ b/src/linguist/lupdate/main.cpp @@ -305,6 +305,23 @@ static QStringList getSources(const ProFileEvaluator &visitor, const QString &pr sourceFiles.removeDuplicates(); sourceFiles.sort(); + QStringList excludes; + foreach (QString ex, visitor.values(QLatin1String("TR_EXCLUDE"))) { + if (!QFileInfo(ex).isAbsolute()) + ex = QDir(projectDir).absoluteFilePath(ex); + excludes << QDir::cleanPath(ex); + } + foreach (const QString &ex, excludes) { + // TODO: take advantage of the file list being sorted + QRegExp rx(ex, Qt::CaseSensitive, QRegExp::Wildcard); + for (QStringList::Iterator it = sourceFiles.begin(); it != sourceFiles.end(); ) { + if (rx.exactMatch(*it)) + it = sourceFiles.erase(it); + else + ++it; + } + } + return sourceFiles; } diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/excluded.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/excluded.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f21ad4e00b5f663a380a0db250b87aca6ee4781 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/excluded.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +int main(char **argv, int argc) +{ + QString fake = QApplication::tr("fake", "This message will not be collected"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro index 37df00f4098f18cd9cd92f8199def87d19ab90f4..d0dd914d463c42e8cbb88160487343e55dd69fa2 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro @@ -1,5 +1,8 @@ SOURCES += main.cpp SOURCES += finddialog.cpp +SOURCES += excluded.cpp + +TR_EXCLUDE = $$PWD/excluded.* TRANSLATIONS = project.ts DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0