Commit 53783571 authored by Michael Reeves's avatar Michael Reeves

Make CvsIgnoreList::matches always honor bCaseSesitive

parent 90b23192
......@@ -43,14 +43,27 @@ class CvsIgnoreListTest : public QObject
void addEntriesFromString()
{
CvsIgnoreList test;
CvsIgnoreList expected;
QString testString = ". .. core RCSLOG tags TAGS RCS SCCS .make.state";
test.addEntriesFromString(testString);
QVERIFY(!test.m_exactPatterns.isEmpty());
QVERIFY(test.m_exactPatterns == testString.split(' '));
}
void matches()
{
CvsIgnoreList test;
QString testString = ". .. core RCSLOG tags TAGS RCS SCCS .make.state";
test.addEntriesFromString(testString);
expected = test = CvsIgnoreList();
QVERIFY(test.matches(".", false));
QVERIFY(!test.matches("cores core", true));
QVERIFY(test.matches("core", true));
QVERIFY(!test.matches("Core", true));
QVERIFY(test.matches("Core", false));
QVERIFY(!test.matches("a", false));
QVERIFY(test.matches("core", false));
}
void testDefaults()
......
......@@ -135,7 +135,8 @@ void CvsIgnoreList::addEntry(const QString& pattern)
bool CvsIgnoreList::matches(const QString& text, bool bCaseSensitive) const
{
if(m_exactPatterns.indexOf(text) >= 0)
QRegExp regexp(text, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
if(m_exactPatterns.indexOf(regexp) >= 0)
{
return true;
}
......@@ -143,7 +144,7 @@ bool CvsIgnoreList::matches(const QString& text, bool bCaseSensitive) const
for(const QString& startPattern: m_startPatterns)
{
if(text.startsWith(startPattern))
if(text.startsWith(startPattern, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive))
{
return true;
}
......@@ -151,25 +152,12 @@ bool CvsIgnoreList::matches(const QString& text, bool bCaseSensitive) const
for(const QString& endPattern: m_endPatterns)
{
if(text.mid(text.length() - endPattern.length()) == endPattern) //(text.endsWith(*it))
if(text.endsWith(endPattern, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive))
{
Q_ASSERT(text.endsWith(endPattern));
return true;
}
}
/*
for (QValueList<QCString>::const_iterator it(m_generalPatterns.begin()),
itEnd(m_generalPatterns.end());
it != itEnd; ++it)
{
if (::fnmatch(*it, text.local8Bit(), FNM_PATHNAME) == 0)
{
return true;
}
}
*/
for(const QString& globStr : m_generalPatterns)
{
QRegExp pattern(globStr, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive, QRegExp::Wildcard);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment