JBoolean CBSearchTextDialog::BuildSearchFileList ( JPtrArray<JString>* fileList, JPtrArray<JString>* nameList ) const { (JXGetApplication())->DisplayBusyCursor(); fileList->SetCleanUpAction(JPtrArrayT::kDeleteAll); fileList->SetCompareFunction(JCompareStringsCaseSensitive); nameList->SetCleanUpAction(JPtrArrayT::kDeleteAll); nameList->SetCompareFunction(JCompareStringsCaseSensitive); if (itsMultifileCB->IsChecked()) { const JPtrArray<JString>& fullNameList = itsFileList->GetFullNameList(); const JSize count = fullNameList.GetElementCount(); for (JIndex i=1; i<=count; i++) { SaveFileForSearch(*(fullNameList.NthElement(i)), fileList, nameList); } } JBoolean ok = kJTrue; JString path, fileFilter, pathFilter; if (GetSearchDirectory(&path, &fileFilter, &pathFilter)) { JRegex* fileRegex = NULL; JString regexStr; if (JDirInfo::BuildRegexFromWildcardFilter(fileFilter, ®exStr)) { fileRegex = jnew JRegex(regexStr); assert( fileRegex != NULL ); fileRegex->SetCaseSensitive(kJFalse); } JRegex* pathRegex = NULL; if (JDirInfo::BuildRegexFromWildcardFilter(pathFilter, ®exStr)) { pathRegex = jnew JRegex(regexStr); assert( pathRegex != NULL ); pathRegex->SetCaseSensitive(kJFalse); } JLatentPG pg(100); pg.VariableLengthProcessBeginning("Collecting files...", kJTrue, kJFalse); ok = SearchDirectory(path, fileRegex, pathRegex, fileList, nameList, pg); pg.ProcessFinished(); jdelete fileRegex; jdelete pathRegex; } return JI2B( ok && !fileList->IsEmpty() ); }
const JString& GMessageHeader::GetBaseSubject() { if (itsHasBaseSubject) { return itsBaseSubject; } itsHasBaseSubject = kJTrue; itsBaseSubject = GetSubject(); kFixSubjectRegex.SetCaseSensitive(kJFalse); JArray<JIndexRange> subList; while (kFixSubjectRegex.Match(itsBaseSubject, &subList)) { itsBaseSubject = itsBaseSubject.GetSubstring(subList.GetElement(subList.GetElementCount())); itsBaseSubject.TrimWhitespace(); subList.RemoveAll(); } const JSize length = itsBaseSubject.GetLength(); JIndex findex = 1; while (findex <= length && !isalnum(itsBaseSubject.GetCharacter(findex))) { findex++; } if (findex > 1 && findex <= length) { itsBaseSubject = itsBaseSubject.GetSubstring(findex, length); } return itsBaseSubject; }
JBoolean CBHTMLScanner::IsScript ( JString* language ) const { scriptTagPattern1.SetCaseSensitive(kJFalse); scriptTagPattern2.SetCaseSensitive(kJFalse); scriptTagPattern3.SetCaseSensitive(kJFalse); language->Clear(); const JString& text = GetScannedText(); const JCharacter* s = text.GetCString() + itsCurrentRange.first - 1; JIndexRange r = itsCurrentRange - (itsCurrentRange.first - 1); JArray<JIndexRange> matchList; if (scriptTagPattern1.MatchWithin(s, r, &matchList)) { *language = text.GetSubstring(matchList.GetElement(2) + (itsCurrentRange.first - 1)); return kJTrue; } else if (scriptTagPattern2.MatchWithin(s, r, &matchList)) { *language = text.GetSubstring(matchList.GetElement(2) + (itsCurrentRange.first - 1)); return kJTrue; } else if (scriptTagPattern3.MatchWithin(s, r)) { *language = "JavaScript"; return kJTrue; } else { return kJFalse; } }
void JDirInfo::SetWildcardFilter ( const JCharacter* filterStr, const JBoolean negate, const JBoolean caseSensitive ) { JString regexStr; if (!BuildRegexFromWildcardFilter(filterStr, ®exStr)) { ClearWildcardFilter(); return; } JRegex* r = new JRegex(regexStr); assert( r != NULL ); r->SetCaseSensitive(caseSensitive); SetWildcardFilter(r, kJTrue, negate); }