Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklist ignored? #9

Open
Asher- opened this issue Dec 30, 2017 · 1 comment
Open

Blacklist ignored? #9

Asher- opened this issue Dec 30, 2017 · 1 comment

Comments

@Asher-
Copy link

Asher- commented Dec 30, 2017

I'm attempting to remove anything in ::testing (gtest) from my profile when using templight-convert, but nothing that I try results in filtering out the entries. I have tried both examples for std namspace: 1. "context std" and 2. "context ^std(::|$)". Neither work.

I am invoking with --blacklist=profile.blacklist, where profile.blacklist is a file in the current directory with the contents specified above as #1 and #2.

What must be done?

@yiding
Copy link

yiding commented Apr 14, 2018

I'd be surprised if the blacklist ever worked. regex_match matches whole string, but it's clear from usage that the author means to match substrings. Here's a patch that makes this somewhat usable.

diff --git a/src/EntryPrinter.cpp b/src/EntryPrinter.cpp
index 407a3dd..ef83dcd 100644
--- a/src/EntryPrinter.cpp
+++ b/src/EntryPrinter.cpp
@@ -45,8 +45,8 @@ bool EntryPrinter::shouldIgnoreEntry(const PrintableEntryBegin &Entry) {
     return true;
   }
   // (2) Regexes:
-  if ( ( CoRegex && ( std::regex_match(Entry.Name, *CoRegex) ) ) || 
-       ( IdRegex && ( std::regex_match(Entry.Name, *IdRegex) ) ) ) {
+  if ( ( CoRegex && ( std::regex_search(Entry.Name, *CoRegex) ) ) ||
+       ( IdRegex && ( std::regex_search(Entry.Name, *IdRegex) ) ) ) {
     skipEntry();
     return true;
   }
@@ -146,13 +146,13 @@ void EntryPrinter::readBlacklists(const std::string& BLFilename) {
   std::string curLine, CoPattern, IdPattern;
 
   while( std::getline(file_in, curLine) ) {
-    if( std::regex_match(curLine, findCo) ) {
+    if( std::regex_search(curLine, findCo) ) {
       if(!CoPattern.empty())
         CoPattern += '|';
       CoPattern += '(';
       CoPattern.append(curLine.begin()+8, curLine.end());
       CoPattern += ')';
-    } else if( std::regex_match(curLine, findId) ) {
+    } else if( std::regex_search(curLine, findId) ) {
       if(!IdPattern.empty())
         IdPattern += '|';
       IdPattern += '(';
@@ -161,11 +161,14 @@ void EntryPrinter::readBlacklists(const std::string& BLFilename) {
     }
   }
 
+  if (!CoPattern.empty()) {
     CoRegex.reset(new std::regex(CoPattern));
+  }
+  if (!IdPattern.empty()) {
     IdRegex.reset(new std::regex(IdPattern));
+  }
   return;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants