| 90 | } |
| 91 | |
| 92 | void CvsIgnoreList::addEntry(const QString& dir, const QString& pattern) |
| 93 | { |
| 94 | if(pattern != QString("!")) |
| 95 | { |
| 96 | if(pattern.isEmpty()) return; |
| 97 | |
| 98 | // The general match is general but slow. |
| 99 | // Special tests for '*' and '?' at the beginning or end of a pattern |
| 100 | // allow fast checks. |
| 101 | |
| 102 | // Count number of '*' and '?' |
| 103 | quint32 nofMetaCharacters = 0; |
| 104 | |
| 105 | const QChar* pos; |
| 106 | pos = pattern.unicode(); |
| 107 | const QChar* posEnd; |
| 108 | posEnd = pos + pattern.length(); |
| 109 | while(pos < posEnd) |
| 110 | { |
| 111 | if(*pos == QChar('*') || *pos == QChar('?')) ++nofMetaCharacters; |
| 112 | ++pos; |
| 113 | } |
| 114 | |
| 115 | if(nofMetaCharacters == 0) |
| 116 | { |
| 117 | m_ignorePatterns[dir].m_exactPatterns.append(pattern); |
| 118 | } |
| 119 | else if(nofMetaCharacters == 1) |
| 120 | { |
| 121 | if(pattern.at(0) == QChar('*')) |
| 122 | { |
| 123 | m_ignorePatterns[dir].m_endPatterns.append(pattern.right(pattern.length() - 1)); |
| 124 | } |
| 125 | else if(pattern.at(pattern.length() - 1) == QChar('*')) |
| 126 | { |
| 127 | m_ignorePatterns[dir].m_startPatterns.append(pattern.left(pattern.length() - 1)); |
| 128 | } |
| 129 | else |
| 130 | { |
| 131 | m_ignorePatterns[dir].m_generalPatterns.append(pattern); |
| 132 | } |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | m_ignorePatterns[dir].m_generalPatterns.append(pattern); |
| 137 | } |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | m_ignorePatterns.erase(dir); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | bool CvsIgnoreList::matches(const QString& dir, const QString& text, bool bCaseSensitive) const |
| 146 | { |