@@ -6710,10 +6710,18 @@ void MainWindow::onLogIdle()
67106710 if (!interactionEnabled ()) return ;
67116711 if (interactionMode () != InteractionMode::None) return ;
67126712
6713- static std::map<int , QRegularExpression> patterns;
6713+ struct Item {
6714+ std::string pattern;
6715+ std::regex regex;
6716+ };
6717+
6718+ static std::map<int , Item> patterns;
67146719 if (patterns.empty ()) {
67156720 for (const auto &t : log_inspection_table) {
6716- patterns[t.index ] = QRegularExpression (t.pattern );
6721+ Item item;
6722+ item.pattern = t.pattern ;
6723+ item.regex = std::regex (t.pattern );
6724+ patterns[t.index ] = item;
67176725 }
67186726 }
67196727
@@ -6723,18 +6731,24 @@ void MainWindow::onLogIdle()
67236731 if (lines.empty ()) return ;
67246732
67256733
6726- auto RegExp = [&](LogInspectionIndex i){
6734+ auto RegExp = [&](LogInspectionIndex i)-> std::regex {
6735+ auto it = patterns.find (i);
6736+ return it == patterns.end () ? std::regex () : it->second .regex ;
6737+ };
6738+
6739+ auto Pattern = [&](LogInspectionIndex i){
67276740 auto it = patterns.find (i);
6728- return it == patterns.end () ? QRegularExpression () : it->second ;
6741+ // if (it == patterns.end()) return std::string();
6742+ // return it->second.pattern;
6743+ return it == patterns.end () ? std::string () : it->second .pattern ;
67296744 };
67306745
67316746 auto Equals = [&](std::string const &line, LogInspectionIndex i){
6732- std::string const &str = RegExp (i).pattern ().toStdString ();
6733- return line == str;
6747+ return line == Pattern (i);
67346748 };
67356749
67366750 auto Contains = [&](LogInspectionIndex i){
6737- std::string const & str = RegExp (i). pattern (). toStdString ( );
6751+ std::string str = Pattern (i );
67386752 for (std::string const &line : lines) {
67396753 if (strstr (line.c_str (), str.c_str ())) {
67406754 return true ;
@@ -6744,11 +6758,11 @@ void MainWindow::onLogIdle()
67446758 };
67456759
67466760 auto Match = [&](std::string const &line, LogInspectionIndex i){
6747- return RegExp (i). match ( QString::fromStdString (line)). hasMatch ( );
6761+ return std::regex_match (line, RegExp (i) );
67486762 };
67496763
67506764 auto StartsWith = [&](std::string const &line, LogInspectionIndex i){
6751- std::string const & str = RegExp (i). pattern (). toStdString ( );
6765+ std::string str = Pattern (i );
67526766 char const *p = str.c_str ();
67536767 char const *s = line.c_str ();
67546768 while (*p) {
@@ -6768,7 +6782,7 @@ void MainWindow::onLogIdle()
67686782 }
67696783 }
67706784 TextEditDialog dlg (this );
6771- dlg.setWindowTitle (RegExp (REMOTE_HOST_IDENTIFICATION_HAS_CHANGED). pattern ( ));
6785+ dlg.setWindowTitle ((QS) Pattern (REMOTE_HOST_IDENTIFICATION_HAS_CHANGED ));
67726786 dlg.setText (text, true );
67736787 dlg.exec ();
67746788 return ;
@@ -6844,7 +6858,7 @@ void MainWindow::onLogIdle()
68446858 if (StartsWith (line, ENTER_PASSPHRASE_FOR_KEY)) {
68456859 std::string keyfile;
68466860 {
6847- std::string pattern = RegExp (ENTER_PASSPHRASE_FOR_KEY). pattern (). toStdString ( );
6861+ std::string pattern = Pattern (ENTER_PASSPHRASE_FOR_KEY);
68486862 char const *p = line.c_str () + pattern.size ();
68496863 char const *q = strrchr (p, ' :' );
68506864 if (q && p + 2 < q && q[-1 ] == ' \' ' ) {
0 commit comments