Changeset 5696


Ignore:
Timestamp:
Oct 18, 2017, 3:12:32 PM (20 months ago)
Author:
cameron
Message:

Fix missing filename as line output prefix

Location:
icGREP/icgrep-devel/icgrep
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5695 r5696  
    3737#include <fcntl.h>
    3838#include <errno.h>
     39#include <llvm/ADT/STLExtras.h> // for make_unique
    3940
    4041using namespace parabix;
     
    166167    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
    167168   
    168     uint64_t grepResult = f(fileDescriptor, reinterpret_cast<intptr_t>(resultAccums[fileIdx]));
     169    uint64_t grepResult = f(fileDescriptor, reinterpret_cast<intptr_t>(resultAccums[fileIdx].get()));
    169170    if (grepResult > 0) grepMatchFound = true;
    170171    else if ((Mode == NormalMode) && !resultAccums[fileIdx]->mResultStr.str().empty()) grepMatchFound = true;
     
    218219            }
    219220        }
    220         resultAccums.push_back(new NonNormalizingReportMatch(linePrefix));
     221        resultAccums.push_back(make_unique<NonNormalizingReportMatch>(linePrefix));
    221222    }
    222223}
  • icGREP/icgrep-devel/icgrep/grep_engine.h

    r5695 r5696  
    2727void *DoGrepThreadFunction(void *args);
    2828   
     29
     30class NonNormalizingReportMatch : public MatchAccumulator {
     31public:
     32    NonNormalizingReportMatch(std::string linePrefix) : mLinePrefix(linePrefix), mLineCount(0), mPrevious_line_end(nullptr) {}
     33    void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
     34    void finalize_match(char * buffer_end) override;
     35    std::string mLinePrefix;
     36    size_t mLineCount;
     37    char * mPrevious_line_end;
     38    std::stringstream mResultStr;
    2939   
    30    
    31     class NonNormalizingReportMatch : public MatchAccumulator {
    32     public:
    33         NonNormalizingReportMatch(std::string linePrefix) : mLineCount(0), mPrevious_line_end(nullptr) {}
    34         void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
    35         void finalize_match(char * buffer_end) override;
    36         std::string mLinePrefix;
    37         size_t mLineCount;
    38         char * mPrevious_line_end;
    39         std::stringstream mResultStr;
    40        
    41     };
    42    
    43    
    44    
     40};
     41
     42
    4543class GrepEngine {
    4644public:
     
    6664    bool grepMatchFound;
    6765
    68     std::vector<NonNormalizingReportMatch *> resultAccums;
     66    std::vector<std::unique_ptr<NonNormalizingReportMatch>> resultAccums;
    6967    std::vector<std::string> inputFiles;
    7068   
Note: See TracChangeset for help on using the changeset viewer.